[wdt] add "force reset" function

This commit is contained in:
stnolting 2025-04-07 18:38:07 +02:00
parent d4e1280c2e
commit 6c05583b41
2 changed files with 16 additions and 0 deletions

View file

@ -69,6 +69,7 @@ int neorv32_wdt_available(void);
void neorv32_wdt_setup(uint32_t timeout, int lock, int strict);
int neorv32_wdt_disable(void);
void neorv32_wdt_feed(uint32_t password);
void neorv32_wdt_force_hwreset(void);
int neorv32_wdt_get_cause(void);
/**@}*/

View file

@ -90,6 +90,21 @@ void neorv32_wdt_feed(uint32_t password) {
}
/**********************************************************************//**
* Force a hardware reset triggered by the watchdog.
**************************************************************************/
void neorv32_wdt_force_hwreset(void) {
// enable strict mode; if strict mode is already enabled and the WDT
// is locked this will already trigger a hardware reset
NEORV32_WDT->CTRL |= (uint32_t)(1 << WDT_CTRL_STRICT);
// try to reset the WDT using an incorrect password;
// this will finally trigger a hardware reset
NEORV32_WDT->RESET = 0;
}
/**********************************************************************//**
* Get cause of last system reset.
*