Skip to content

Commit 3c94bc8

Browse files
authored
Change _watchdog_enable to trigger immediate reboot when no delay set (#561)
1 parent f808b5f commit 3c94bc8

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/rp2_common/hardware_watchdog/watchdog.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,19 @@ void _watchdog_enable(uint32_t delay_ms, bool pause_on_debug) {
4949
hw_clear_bits(&watchdog_hw->ctrl, dbg_bits);
5050
}
5151

52-
if (!delay_ms) delay_ms = 50;
53-
54-
// Note, we have x2 here as the watchdog HW currently decrements twice per tick
55-
load_value = delay_ms * 1000 * 2;
56-
57-
if (load_value > 0xffffffu)
58-
load_value = 0xffffffu;
52+
if (!delay_ms) {
53+
hw_set_bits(&watchdog_hw->ctrl, WATCHDOG_CTRL_TRIGGER_BITS);
54+
} else {
55+
// Note, we have x2 here as the watchdog HW currently decrements twice per tick
56+
load_value = delay_ms * 1000 * 2;
5957

58+
if (load_value > 0xffffffu)
59+
load_value = 0xffffffu;
6060

61-
watchdog_update();
61+
watchdog_update();
6262

63-
hw_set_bits(&watchdog_hw->ctrl, WATCHDOG_CTRL_ENABLE_BITS);
63+
hw_set_bits(&watchdog_hw->ctrl, WATCHDOG_CTRL_ENABLE_BITS);
64+
}
6465
}
6566
// end::watchdog_enable[]
6667

0 commit comments

Comments
 (0)