ports: Provide mp_hal_stdio_poll for sys.stdio polling where needed.

This commit is contained in:
Damien George
2019-06-19 14:02:38 +10:00
parent 964ae328cd
commit c80614dfc8
6 changed files with 53 additions and 0 deletions

View File

@@ -25,6 +25,7 @@
*/
#include <string.h>
#include "py/stream.h"
#include "py/mphal.h"
#include "board.h"
@@ -51,6 +52,14 @@ void mp_hal_set_interrupt_char(int c) {
interrupt_char = c;
}
uintptr_t mp_hal_stdio_poll(uintptr_t poll_flags) {
uintptr_t ret = 0;
if ((poll_flags & MP_STREAM_POLL_RD) && uart_rx_any()) {
ret |= MP_STREAM_POLL_RD;
}
return ret;
}
int mp_hal_stdin_rx_chr(void) {
for (;;) {
if (uart_rx_any()) {