Skip to content

Commit 82d64a1

Browse files
committed
supervisor: tick: check for watchdog exception if enabled
Check to see if the current exception is a Watchdog exception, if it's enabled. This ensures we break out of the current sleep() if a watchdog timeout hits. Signed-off-by: Sean Cross <[email protected]>
1 parent f7854fb commit 82d64a1

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

supervisor/shared/tick.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,13 @@ void PLACE_IN_ITCM(supervisor_run_background_tasks_if_tick)() {
8686
run_background_tasks();
8787
}
8888

89+
#ifdef CIRCUITPY_WATCHDOG
90+
extern mp_obj_exception_t mp_watchdog_timeout_exception;
91+
#define WATCHDOG_EXCEPTION_CHECK() (MP_STATE_VM(mp_pending_exception) == &mp_watchdog_timeout_exception)
92+
#else
93+
#define WATCHDOG_EXCEPTION_CHECK() 0
94+
#endif
95+
8996
void mp_hal_delay_ms(mp_uint_t delay) {
9097
uint64_t start_tick = port_get_raw_ticks(NULL);
9198
// Adjust the delay to ticks vs ms.
@@ -97,7 +104,7 @@ void mp_hal_delay_ms(mp_uint_t delay) {
97104
// Check to see if we've been CTRL-Ced by autoreload or the user.
98105
if(MP_STATE_VM(mp_pending_exception) == MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_kbd_exception)) ||
99106
MP_STATE_VM(mp_pending_exception) == MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_reload_exception)) ||
100-
MP_STATE_VM(mp_pending_exception) == MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_watchdog_exception))) {
107+
WATCHDOG_EXCEPTION_CHECK()) {
101108
break;
102109
}
103110
remaining = end_tick - port_get_raw_ticks(NULL);

0 commit comments

Comments
 (0)