From 3c94bc8137499776d47546e9b41f6ed0545fc99b Mon Sep 17 00:00:00 2001 From: Robert Pafford <19439938+rjp5th@users.noreply.github.com> Date: Thu, 14 Oct 2021 12:30:16 -0400 Subject: [PATCH] Change _watchdog_enable to trigger immediate reboot when no delay set (#561) --- src/rp2_common/hardware_watchdog/watchdog.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/rp2_common/hardware_watchdog/watchdog.c b/src/rp2_common/hardware_watchdog/watchdog.c index 36031aa..7421064 100644 --- a/src/rp2_common/hardware_watchdog/watchdog.c +++ b/src/rp2_common/hardware_watchdog/watchdog.c @@ -49,18 +49,19 @@ void _watchdog_enable(uint32_t delay_ms, bool pause_on_debug) { hw_clear_bits(&watchdog_hw->ctrl, dbg_bits); } - if (!delay_ms) delay_ms = 50; + if (!delay_ms) { + hw_set_bits(&watchdog_hw->ctrl, WATCHDOG_CTRL_TRIGGER_BITS); + } else { + // Note, we have x2 here as the watchdog HW currently decrements twice per tick + load_value = delay_ms * 1000 * 2; - // Note, we have x2 here as the watchdog HW currently decrements twice per tick - load_value = delay_ms * 1000 * 2; + if (load_value > 0xffffffu) + load_value = 0xffffffu; - if (load_value > 0xffffffu) - load_value = 0xffffffu; + watchdog_update(); - - watchdog_update(); - - hw_set_bits(&watchdog_hw->ctrl, WATCHDOG_CTRL_ENABLE_BITS); + hw_set_bits(&watchdog_hw->ctrl, WATCHDOG_CTRL_ENABLE_BITS); + } } // end::watchdog_enable[]