diff --git a/ports/esp32s2/common-hal/watchdog/WatchDogTimer.c b/ports/esp32s2/common-hal/watchdog/WatchDogTimer.c index 59b9dafcf0..b51a391b7f 100644 --- a/ports/esp32s2/common-hal/watchdog/WatchDogTimer.c +++ b/ports/esp32s2/common-hal/watchdog/WatchDogTimer.c @@ -27,12 +27,19 @@ #include "py/runtime.h" #include "common-hal/watchdog/WatchDogTimer.h" +#include "shared-bindings/watchdog/__init__.h" #include "shared-bindings/microcontroller/__init__.h" #include "esp_task_wdt.h" void esp_task_wdt_isr_user_handler(void) { - + mp_obj_exception_clear_traceback(MP_OBJ_FROM_PTR(&mp_watchdog_timeout_exception)); + MP_STATE_VM(mp_pending_exception) = &mp_watchdog_timeout_exception; +#if MICROPY_ENABLE_SCHEDULER + if (MP_STATE_VM(sched_state) == MP_SCHED_IDLE) { + MP_STATE_VM(sched_state) = MP_SCHED_PENDING; + } +#endif } void common_hal_watchdog_feed(watchdog_watchdogtimer_obj_t *self) { diff --git a/ports/esp32s2/common-hal/watchdog/WatchDogTimer.h b/ports/esp32s2/common-hal/watchdog/WatchDogTimer.h index 05e0e954d2..04d9aeee6c 100644 --- a/ports/esp32s2/common-hal/watchdog/WatchDogTimer.h +++ b/ports/esp32s2/common-hal/watchdog/WatchDogTimer.h @@ -37,8 +37,7 @@ struct _watchdog_watchdogtimer_obj_t { watchdog_watchdogmode_t mode; }; -// This needs to be called in order to disable the watchdog if it's set to -// "RAISE". If set to "RESET", then the watchdog cannot be reset. +// This needs to be called in order to disable the watchdog void watchdog_reset(void); #endif // MICROPY_INCLUDED_ESP32S2_COMMON_HAL_WATCHDOG_WATCHDOGTIMER_H diff --git a/ports/esp32s2/supervisor/port.c b/ports/esp32s2/supervisor/port.c index 0b9c03f747..1b6f5ef7cb 100644 --- a/ports/esp32s2/supervisor/port.c +++ b/ports/esp32s2/supervisor/port.c @@ -41,6 +41,7 @@ #include "common-hal/busio/UART.h" #include "common-hal/pulseio/PulseIn.h" #include "common-hal/pwmio/PWMOut.h" +#include "common-hal/watchdog/WatchDogTimer.h" #include "common-hal/wifi/__init__.h" #include "supervisor/memory.h" #include "supervisor/shared/tick.h" @@ -119,6 +120,10 @@ void reset_port(void) { rtc_reset(); #endif +#if CIRCUITPY_WATCHDOG + watchdog_reset(); +#endif + #if CIRCUITPY_WIFI wifi_reset(); #endif