diff options
| author | Damien George | 2019-06-19 14:02:38 +1000 |
|---|---|---|
| committer | Damien George | 2019-07-01 17:10:12 +1000 |
| commit | c80614dfc8b6454819380e4886d49dfd93193691 (patch) | |
| tree | cdeec4bafad4cf8ed74efd8d2a6a39f44186143b /ports/teensy | |
| parent | 964ae328cd00260d9a017a4e67909694fded9902 (diff) | |
ports: Provide mp_hal_stdio_poll for sys.stdio polling where needed.
Diffstat (limited to 'ports/teensy')
| -rw-r--r-- | ports/teensy/teensy_hal.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/ports/teensy/teensy_hal.c b/ports/teensy/teensy_hal.c index 7ce82f1d2..e9cc6778d 100644 --- a/ports/teensy/teensy_hal.c +++ b/ports/teensy/teensy_hal.c @@ -2,6 +2,7 @@ #include <string.h> #include "py/runtime.h" +#include "py/stream.h" #include "py/mphal.h" #include "usb.h" #include "uart.h" @@ -21,6 +22,19 @@ void mp_hal_set_interrupt_char(int c) { // you can't press Control-C and get your python script to stop. } +uintptr_t mp_hal_stdio_poll(uintptr_t poll_flags) { + uintptr_t ret = 0; + if (poll_flags & MP_STREAM_POLL_RD) { + if (usb_vcp_rx_num()) { + ret |= MP_STREAM_POLL_RD; + } + if (MP_STATE_PORT(pyb_stdio_uart) != NULL && uart_rx_any(MP_STATE_PORT(pyb_stdio_uart))) { + ret |= MP_STREAM_POLL_RD; + } + } + return ret; +} + int mp_hal_stdin_rx_chr(void) { for (;;) { byte c; |
