summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Cross <sean@xobs.io>2020-05-22 18:43:23 +0800
committerSean Cross <sean@xobs.io>2020-05-27 11:28:49 +0800
commit15530a69c79ded8b38cdb1d87a4e2515a4e12510 (patch)
treedfd9e0412f82752c63adaac1fcd1a6e06ebe6d60
parentbd086a102e515765b55b50db9f3e45a23164b840 (diff)
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 <sean@xobs.io>
-rw-r--r--supervisor/shared/tick.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/supervisor/shared/tick.c b/supervisor/shared/tick.c
index 0e2adf216..ba12e1e8c 100644
--- a/supervisor/shared/tick.c
+++ b/supervisor/shared/tick.c
@@ -86,6 +86,13 @@ void PLACE_IN_ITCM(supervisor_run_background_tasks_if_tick)() {
run_background_tasks();
}
+#ifdef CIRCUITPY_WATCHDOG
+extern mp_obj_exception_t mp_watchdog_timeout_exception;
+#define WATCHDOG_EXCEPTION_CHECK() (MP_STATE_VM(mp_pending_exception) == &mp_watchdog_timeout_exception)
+#else
+#define WATCHDOG_EXCEPTION_CHECK() 0
+#endif
+
void mp_hal_delay_ms(mp_uint_t delay) {
uint64_t start_tick = port_get_raw_ticks(NULL);
// Adjust the delay to ticks vs ms.
@@ -97,7 +104,7 @@ void mp_hal_delay_ms(mp_uint_t delay) {
// 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)) ||
MP_STATE_VM(mp_pending_exception) == MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_reload_exception)) ||
- MP_STATE_VM(mp_pending_exception) == MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_watchdog_exception))) {
+ WATCHDOG_EXCEPTION_CHECK()) {
break;
}
remaining = end_tick - port_get_raw_ticks(NULL);