mirror of
https://github.com/micropython/micropython.git
synced 2026-01-04 19:20:22 +01:00
ports: Provide mp_hal_stdio_poll for sys.stdio polling where needed.
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user