extmod/modos: Factor os.dupterm_notify() function to common extmod code.

esp8266 doesn't need ets task because the notify is now scheduled (see
commits 7d57037906 and
c60caf1995 for relevant history).

Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
Damien George
2023-12-14 17:06:56 +11:00
parent 0e706a62b1
commit 395886caa3
8 changed files with 27 additions and 92 deletions

View File

@@ -29,6 +29,9 @@
* THE SOFTWARE.
*/
// This file is never compiled standalone, it's included directly from
// extmod/modos.c via MICROPY_PY_OS_INCLUDEFILE.
#include "py/runtime.h"
#include "py/mphal.h"
#include "modmachine.h"
@@ -96,18 +99,3 @@ bool mp_os_dupterm_is_builtin_stream(mp_const_obj_t stream) {
return type == &machine_uart_type;
}
#endif
#if MICROPY_PY_OS_DUPTERM_NOTIFY
STATIC mp_obj_t mp_os_dupterm_notify(mp_obj_t obj_in) {
(void)obj_in;
for (;;) {
int c = mp_os_dupterm_rx_chr();
if (c < 0) {
break;
}
ringbuf_put(&stdin_ringbuf, c);
}
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_os_dupterm_notify_obj, mp_os_dupterm_notify);
#endif