nrf52 wdt: pause wdt in Sleep and Halt, set timeout to 90 s

The 90 seconds wdt timeout matches the esp32 wdt timeout.
This commit is contained in:
Sebastian Kuzminsky
2025-11-06 22:22:58 -07:00
parent 10de230dba
commit 7232dddd69

View File

@@ -5,6 +5,7 @@
#include <SPI.h> #include <SPI.h>
#include <Wire.h> #include <Wire.h>
#define APP_WATCHDOG_SECS 90
#define NRFX_WDT_ENABLED 1 #define NRFX_WDT_ENABLED 1
#define NRFX_WDT0_ENABLED 1 #define NRFX_WDT0_ENABLED 1
#define NRFX_WDT_CONFIG_NO_IRQ 1 #define NRFX_WDT_CONFIG_NO_IRQ 1
@@ -296,15 +297,17 @@ void nrf52Setup()
// the first time through the main loop), so that other threads can // the first time through the main loop), so that other threads can
// allocate their own wdt channel to protect themselves from hangs. // allocate their own wdt channel to protect themselves from hangs.
nrfx_wdt_config_t wdt0_config = { nrfx_wdt_config_t wdt0_config = {
.behaviour = NRF_WDT_BEHAVIOUR_RUN_SLEEP, .reload_value = 2000, .behaviour = NRF_WDT_BEHAVIOUR_PAUSE_SLEEP_HALT, .reload_value = APP_WATCHDOG_SECS * 1000,
// Note: Not using wdt interrupts. // Note: Not using wdt interrupts.
// .interrupt_priority = NRFX_WDT_DEFAULT_CONFIG_IRQ_PRIORITY // .interrupt_priority = NRFX_WDT_DEFAULT_CONFIG_IRQ_PRIORITY
}; };
nrfx_err_t r = nrfx_wdt_init(&nrfx_wdt, &wdt0_config, nrfx_err_t r = nrfx_wdt_init(&nrfx_wdt, &wdt0_config,
nullptr // Watchdog event handler, not used, we just reset. nullptr // Watchdog event handler, not used, we just reset.
); );
assert(r == NRFX_SUCCESS);
r = nrfx_wdt_channel_alloc(&nrfx_wdt, &nrfx_wdt_channel_id_nrf52_main); r = nrfx_wdt_channel_alloc(&nrfx_wdt, &nrfx_wdt_channel_id_nrf52_main);
assert(r == NRFX_SUCCESS);
} }
void cpuDeepSleep(uint32_t msecToWake) void cpuDeepSleep(uint32_t msecToWake)