Skip to content

Commit 146adca

Browse files
committed
Add watchdog mode raise
1 parent 10e8b8c commit 146adca

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

ports/esp32s2/common-hal/watchdog/WatchDogTimer.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,19 @@
2727
#include "py/runtime.h"
2828
#include "common-hal/watchdog/WatchDogTimer.h"
2929

30+
#include "shared-bindings/watchdog/__init__.h"
3031
#include "shared-bindings/microcontroller/__init__.h"
3132

3233
#include "esp_task_wdt.h"
3334

3435
void esp_task_wdt_isr_user_handler(void) {
35-
36+
mp_obj_exception_clear_traceback(MP_OBJ_FROM_PTR(&mp_watchdog_timeout_exception));
37+
MP_STATE_VM(mp_pending_exception) = &mp_watchdog_timeout_exception;
38+
#if MICROPY_ENABLE_SCHEDULER
39+
if (MP_STATE_VM(sched_state) == MP_SCHED_IDLE) {
40+
MP_STATE_VM(sched_state) = MP_SCHED_PENDING;
41+
}
42+
#endif
3643
}
3744

3845
void common_hal_watchdog_feed(watchdog_watchdogtimer_obj_t *self) {

ports/esp32s2/common-hal/watchdog/WatchDogTimer.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ struct _watchdog_watchdogtimer_obj_t {
3737
watchdog_watchdogmode_t mode;
3838
};
3939

40-
// This needs to be called in order to disable the watchdog if it's set to
41-
// "RAISE". If set to "RESET", then the watchdog cannot be reset.
40+
// This needs to be called in order to disable the watchdog
4241
void watchdog_reset(void);
4342

4443
#endif // MICROPY_INCLUDED_ESP32S2_COMMON_HAL_WATCHDOG_WATCHDOGTIMER_H

ports/esp32s2/supervisor/port.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#include "common-hal/busio/UART.h"
4242
#include "common-hal/pulseio/PulseIn.h"
4343
#include "common-hal/pwmio/PWMOut.h"
44+
#include "common-hal/watchdog/WatchDogTimer.h"
4445
#include "common-hal/wifi/__init__.h"
4546
#include "supervisor/memory.h"
4647
#include "supervisor/shared/tick.h"
@@ -119,6 +120,10 @@ void reset_port(void) {
119120
rtc_reset();
120121
#endif
121122

123+
#if CIRCUITPY_WATCHDOG
124+
watchdog_reset();
125+
#endif
126+
122127
#if CIRCUITPY_WIFI
123128
wifi_reset();
124129
#endif

0 commit comments

Comments
 (0)