Change _watchdog_enable to trigger immediate reboot when no delay set (#561)

This commit is contained in:
Robert Pafford 2021-10-14 12:30:16 -04:00 committed by GitHub
parent f808b5f2dc
commit 3c94bc8137
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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[]