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

@@ -32,6 +32,7 @@
#include "user_interface.h"
#include "ets_alt_task.h"
#include "py/runtime.h"
#include "py/stream.h"
#include "extmod/misc.h"
#include "lib/utils/pyexec.h"
@@ -56,6 +57,14 @@ void mp_hal_delay_us(uint32_t us) {
}
}
uintptr_t mp_hal_stdio_poll(uintptr_t poll_flags) {
uintptr_t ret = 0;
if ((poll_flags & MP_STREAM_POLL_RD) && stdin_ringbuf.iget != stdin_ringbuf.iput) {
ret |= MP_STREAM_POLL_RD;
}
return ret;
}
int mp_hal_stdin_rx_chr(void) {
for (;;) {
int c = ringbuf_get(&stdin_ringbuf);