Change _watchdog_enable to trigger immediate reboot when no delay set (#561)
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 @@
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[]