summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ports/nrf/common-hal/watchdog/WatchDogTimer.c16
-rw-r--r--shared-bindings/watchdog/__init__.c16
-rw-r--r--shared-bindings/watchdog/__init__.h2
-rw-r--r--supervisor/shared/tick.c14
4 files changed, 25 insertions, 23 deletions
diff --git a/ports/nrf/common-hal/watchdog/WatchDogTimer.c b/ports/nrf/common-hal/watchdog/WatchDogTimer.c
index 8132ceacc..32af25866 100644
--- a/ports/nrf/common-hal/watchdog/WatchDogTimer.c
+++ b/ports/nrf/common-hal/watchdog/WatchDogTimer.c
@@ -50,22 +50,6 @@ STATIC nrfx_timer_t *timer = NULL;
STATIC nrfx_wdt_t wdt = NRFX_WDT_INSTANCE(0);
STATIC nrfx_wdt_channel_id wdt_channel_id;
-const mp_obj_type_t mp_type_WatchDogTimeout = {
- { &mp_type_type },
- .name = MP_QSTR_WatchDogTimeout,
- .make_new = mp_obj_exception_make_new,
- .attr = mp_obj_exception_attr,
- .parent = &mp_type_Exception,
-};
-
-mp_obj_exception_t mp_watchdog_timeout_exception = {
- .base.type = &mp_type_WatchDogTimeout,
- .traceback_alloc = 0,
- .traceback_len = 0,
- .traceback_data = NULL,
- .args = (mp_obj_tuple_t*)&mp_const_empty_tuple_obj,
-};
-
STATIC void watchdogtimer_timer_event_handler(nrf_timer_event_t event_type, void *p_context) {
watchdog_watchdogtimer_obj_t *self = MP_OBJ_TO_PTR(p_context);
if (event_type != NRF_TIMER_EVENT_COMPARE0) {
diff --git a/shared-bindings/watchdog/__init__.c b/shared-bindings/watchdog/__init__.c
index 36993db93..7f818b226 100644
--- a/shared-bindings/watchdog/__init__.c
+++ b/shared-bindings/watchdog/__init__.c
@@ -55,6 +55,22 @@
//| w.feed()"""
//|
+const mp_obj_type_t mp_type_WatchDogTimeout = {
+ { &mp_type_type },
+ .name = MP_QSTR_WatchDogTimeout,
+ .make_new = mp_obj_exception_make_new,
+ .attr = mp_obj_exception_attr,
+ .parent = &mp_type_Exception,
+};
+
+mp_obj_exception_t mp_watchdog_timeout_exception = {
+ .base.type = &mp_type_WatchDogTimeout,
+ .traceback_alloc = 0,
+ .traceback_len = 0,
+ .traceback_data = NULL,
+ .args = (mp_obj_tuple_t*)&mp_const_empty_tuple_obj,
+};
+
STATIC const mp_rom_map_elem_t watchdog_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_watchdog) },
{ MP_ROM_QSTR(MP_QSTR_WatchDogMode), MP_ROM_PTR(&watchdog_watchdogmode_type) },
diff --git a/shared-bindings/watchdog/__init__.h b/shared-bindings/watchdog/__init__.h
index 7203b8aa5..b5a0ad71d 100644
--- a/shared-bindings/watchdog/__init__.h
+++ b/shared-bindings/watchdog/__init__.h
@@ -28,5 +28,7 @@
#define MICROPY_INCLUDED_SHARED_BINDINGS_WATCHDOG___INIT___H
extern const mp_obj_module_t watchdog_module;
+extern mp_obj_exception_t mp_watchdog_timeout_exception;
+extern const mp_obj_type_t mp_type_WatchDogTimeout;
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_WATCHDOG___INIT___H
diff --git a/supervisor/shared/tick.c b/supervisor/shared/tick.c
index ba12e1e8c..23516799f 100644
--- a/supervisor/shared/tick.c
+++ b/supervisor/shared/tick.c
@@ -44,6 +44,13 @@ static volatile uint64_t PLACE_IN_DTCM_BSS(background_ticks);
#include "shared-bindings/microcontroller/__init__.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
+
void supervisor_tick(void) {
#if CIRCUITPY_FILESYSTEM_FLUSH_INTERVAL_MS > 0
filesystem_tick();
@@ -86,13 +93,6 @@ 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.