diff options
| author | Damien George | 2018-04-27 23:51:00 +1000 |
|---|---|---|
| committer | Damien George | 2018-04-27 23:51:45 +1000 |
| commit | 98b05e36148655ac53383f4ccea37e15445a5c54 (patch) | |
| tree | 041aceb075f52c4b83bb41808f4de45476ce3d52 | |
| parent | 04dc4a5034bc9bbf8dbb21bd6767ea9d5053abcf (diff) | |
esp32: Add support for and enable uos.dupterm().
| -rw-r--r-- | ports/esp32/moduos.c | 12 | ||||
| -rw-r--r-- | ports/esp32/mpconfigport.h | 1 | ||||
| -rw-r--r-- | ports/esp32/mphalport.c | 1 |
3 files changed, 11 insertions, 3 deletions
diff --git a/ports/esp32/moduos.c b/ports/esp32/moduos.c index 9f0e291a6..dc85136f3 100644 --- a/ports/esp32/moduos.c +++ b/ports/esp32/moduos.c @@ -31,11 +31,11 @@ #include "esp_system.h" -#include "py/mpconfig.h" -#include "py/obj.h" #include "py/objstr.h" #include "py/runtime.h" #include "py/mperrno.h" +#include "py/mphal.h" +#include "extmod/misc.h" #include "extmod/vfs.h" #include "extmod/vfs_fat.h" #include "genhdr/mpversion.h" @@ -87,7 +87,13 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(os_urandom_obj, os_urandom); #if MICROPY_PY_OS_DUPTERM STATIC mp_obj_t os_dupterm_notify(mp_obj_t obj_in) { (void)obj_in; - mp_hal_signal_dupterm_input(); + for (;;) { + int c = mp_uos_dupterm_rx_chr(); + if (c < 0) { + break; + } + ringbuf_put(&stdin_ringbuf, c); + } return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_1(os_dupterm_notify_obj, os_dupterm_notify); diff --git a/ports/esp32/mpconfigport.h b/ports/esp32/mpconfigport.h index 80594b114..2f4acaf12 100644 --- a/ports/esp32/mpconfigport.h +++ b/ports/esp32/mpconfigport.h @@ -127,6 +127,7 @@ #define MICROPY_PY_UBINASCII_CRC32 (1) #define MICROPY_PY_URANDOM (1) #define MICROPY_PY_URANDOM_EXTRA_FUNCS (1) +#define MICROPY_PY_OS_DUPTERM (1) #define MICROPY_PY_MACHINE (1) #define MICROPY_PY_MACHINE_PIN_MAKE_NEW mp_pin_make_new #define MICROPY_PY_MACHINE_PULSE (1) diff --git a/ports/esp32/mphalport.c b/ports/esp32/mphalport.c index 6cc2621ca..353e1343b 100644 --- a/ports/esp32/mphalport.c +++ b/ports/esp32/mphalport.c @@ -63,6 +63,7 @@ void mp_hal_stdout_tx_strn(const char *str, uint32_t len) { uart_tx_one_char(str[i]); } MP_THREAD_GIL_ENTER(); + mp_uos_dupterm_tx_strn(str, len); } // Efficiently convert "\n" to "\r\n" |
