summaryrefslogtreecommitdiff
path: root/ports/zephyr/src
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2025-06-23 12:56:04 +1000
committerDamien George <damien@micropython.org>2025-07-08 10:10:16 +1000
commit4951a06bbb5b3987a8ac922c06b8764c083d168c (patch)
treeefbc2a27cc67cab83770236bc8cb29fee5e2299d /ports/zephyr/src
parent6b82eb75bef70d44ef583385301b7c483ac9ae94 (diff)
zephyr: Enable sys.stdin/out/err.
This change enables `sys.stdin`, `sys.stdout` and `sys.stderr` objects. They are useful for general IO, and also help with testing zephyr boards. Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'ports/zephyr/src')
-rw-r--r--ports/zephyr/src/zephyr_getchar.c5
-rw-r--r--ports/zephyr/src/zephyr_getchar.h1
2 files changed, 6 insertions, 0 deletions
diff --git a/ports/zephyr/src/zephyr_getchar.c b/ports/zephyr/src/zephyr_getchar.c
index 94e35e2e8..7660e3cc1 100644
--- a/ports/zephyr/src/zephyr_getchar.c
+++ b/ports/zephyr/src/zephyr_getchar.c
@@ -49,6 +49,11 @@ static int console_irq_input_hook(uint8_t ch) {
return 1;
}
+// Returns true if a char is available for reading.
+int zephyr_getchar_check(void) {
+ return i_get != i_put;
+}
+
int zephyr_getchar(void) {
mp_hal_wait_sem(&uart_sem, 0);
if (k_sem_take(&uart_sem, K_MSEC(0)) == 0) {
diff --git a/ports/zephyr/src/zephyr_getchar.h b/ports/zephyr/src/zephyr_getchar.h
index fee899e1b..3f31c4317 100644
--- a/ports/zephyr/src/zephyr_getchar.h
+++ b/ports/zephyr/src/zephyr_getchar.h
@@ -17,4 +17,5 @@
#include <stdint.h>
void zephyr_getchar_init(void);
+int zephyr_getchar_check(void);
int zephyr_getchar(void);