summaryrefslogtreecommitdiffstatshomepage
path: root/shared
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2024-08-09 13:54:14 +1000
committerDamien George <damien@micropython.org>2024-08-28 11:52:08 +1000
commit70a6791b09f9fad55b99e5996433888cee0a7a64 (patch)
treeb5de0b886ead821f6743c178cb3634f1c610eb9e /shared
parent9f9c283ef48950487bb566e9717819e8a2a29ac6 (diff)
downloadmicropython-70a6791b09f9fad55b99e5996433888cee0a7a64.tar.gz
micropython-70a6791b09f9fad55b99e5996433888cee0a7a64.zip
shared/runtime/semihosting_arm: Add mp_semihosting_rx_chars.
Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'shared')
-rw-r--r--shared/runtime/semihosting_arm.c15
-rw-r--r--shared/runtime/semihosting_arm.h3
2 files changed, 18 insertions, 0 deletions
diff --git a/shared/runtime/semihosting_arm.c b/shared/runtime/semihosting_arm.c
index 5cfaaa3c6b..d44124faab 100644
--- a/shared/runtime/semihosting_arm.c
+++ b/shared/runtime/semihosting_arm.c
@@ -34,6 +34,7 @@
#define SYS_OPEN 0x01
#define SYS_WRITEC 0x03
#define SYS_WRITE 0x05
+#define SYS_READ 0x06
#define SYS_READC 0x07
// Constants:
@@ -91,6 +92,20 @@ int mp_semihosting_rx_char() {
return mp_semihosting_call(SYS_READC, NULL);
}
+// Returns 0 on success.
+int mp_semihosting_rx_chars(char *str, size_t len) {
+ struct {
+ uint32_t fd;
+ const char *str;
+ uint32_t len;
+ } args = {
+ .fd = mp_semihosting_stdout,
+ .str = str,
+ .len = len,
+ };
+ return mp_semihosting_call(SYS_READ, &args);
+}
+
static void mp_semihosting_tx_char(char c) {
mp_semihosting_call(SYS_WRITEC, &c);
}
diff --git a/shared/runtime/semihosting_arm.h b/shared/runtime/semihosting_arm.h
index 7e90f25ac9..1faaae7fec 100644
--- a/shared/runtime/semihosting_arm.h
+++ b/shared/runtime/semihosting_arm.h
@@ -38,6 +38,8 @@ Then make sure the debugger is attached and enables semihosting. In OpenOCD thi
done with ARM semihosting enable followed by reset. The terminal will need further
configuration to work with MicroPython (bash: stty raw -echo).
+If mp_semihosting_rx_char() doesn't work then try mp_semihosting_rx_chars(str, 1).
+
*/
#include <stddef.h>
@@ -45,6 +47,7 @@ configuration to work with MicroPython (bash: stty raw -echo).
void mp_semihosting_init();
int mp_semihosting_rx_char();
+int mp_semihosting_rx_chars(char *str, size_t len);
uint32_t mp_semihosting_tx_strn(const char *str, size_t len);
uint32_t mp_semihosting_tx_strn_cooked(const char *str, size_t len);