diff options
| author | Jeff Epler <jeff@adafruit.com> | 2020-08-25 21:01:33 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-08-25 21:01:33 -0500 |
| commit | 2e0a10933116e69d6dacc67d3180ea52ca32509d (patch) | |
| tree | d2fc35b092bc147682cf701f323f3201ef5348d6 /supervisor | |
| parent | 78c512e86b5c61d337e10cb5ec598cecd728c5f6 (diff) | |
| parent | c0753c1afb09dab873da02e6f98a492cb913f0e9 (diff) | |
Merge pull request #3318 from jepler/interrupt-serial-rx
supervisor: check for interrupt during rx_chr
Diffstat (limited to 'supervisor')
| -rw-r--r-- | supervisor/shared/micropython.c | 10 | ||||
| -rw-r--r-- | supervisor/shared/tick.c | 13 |
2 files changed, 12 insertions, 11 deletions
diff --git a/supervisor/shared/micropython.c b/supervisor/shared/micropython.c index 245db11d4..bbc4807f9 100644 --- a/supervisor/shared/micropython.c +++ b/supervisor/shared/micropython.c @@ -29,14 +29,24 @@ #include "supervisor/serial.h" #include "lib/oofatfs/ff.h" #include "py/mpconfig.h" +#include "py/mpstate.h" +#include "py/runtime.h" #include "supervisor/shared/status_leds.h" +#if CIRCUITPY_WATCHDOG +#include "shared-bindings/watchdog/__init__.h" +#define WATCHDOG_EXCEPTION_CHECK() (MP_STATE_VM(mp_pending_exception) == &mp_watchdog_timeout_exception) +#else +#define WATCHDOG_EXCEPTION_CHECK() 0 +#endif + int mp_hal_stdin_rx_chr(void) { for (;;) { #ifdef MICROPY_VM_HOOK_LOOP MICROPY_VM_HOOK_LOOP #endif + mp_handle_pending(); if (serial_bytes_available()) { toggle_rx_led(); return serial_read(); diff --git a/supervisor/shared/tick.c b/supervisor/shared/tick.c index 4af59f78e..f26e1e79d 100644 --- a/supervisor/shared/tick.c +++ b/supervisor/shared/tick.c @@ -27,6 +27,7 @@ #include "supervisor/shared/tick.h" #include "py/mpstate.h" +#include "py/runtime.h" #include "supervisor/linker.h" #include "supervisor/filesystem.h" #include "supervisor/background_callback.h" @@ -149,17 +150,7 @@ void mp_hal_delay_ms(mp_uint_t delay) { while (remaining > 0) { RUN_BACKGROUND_TASKS; // Check to see if we've been CTRL-Ced by autoreload or the user. - if(MP_STATE_VM(mp_pending_exception) == MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_kbd_exception))) - { - // clear exception and generate stacktrace - MP_STATE_VM(mp_pending_exception) = MP_OBJ_NULL; - nlr_raise(&MP_STATE_VM(mp_kbd_exception)); - } - if( MP_STATE_VM(mp_pending_exception) == MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_reload_exception)) || - WATCHDOG_EXCEPTION_CHECK()) { - // stop sleeping immediately - break; - } + mp_handle_pending(); remaining = end_tick - port_get_raw_ticks(NULL); // We break a bit early so we don't risk setting the alarm before the time when we call // sleep. |
