Watchdog
Examples
#include "abov/hal/wdt.h"
#include "abov/irq.h"
#include "abov/delay.h"
#define OPTIONAL
int main(void)
{
wdt_enable();
#if defined(OPTIONAL)
wdt_set_clock_source(CLK_LSI);
#endif
#if defined(ENABLE_WATCHDOG_INTERRUPT)
wdt_set_interrupt(true);
irq_enable(IRQ_WDT);
#endif
wdt_set_reload_ms(1000);
wdt_start();
for (int i = 0; i < 10; i++) {
wdt_feed();
udelay(500000);
}
while (1) {
/* waiting for watchdog event */
}
return 0;
}
#if defined(ENABLE_WATCHDOG_INTERRUPT)
void ISR_WDT(void)
{
wdt_feed();
}
#endif
HAL
LL
Functions
-
void wdt_reset(void)
Reset WDT unit.
This function makes WDT unit the reset state.
-
uint32_t wdt_get_count(void)
Get the current watchdog count
-
void wdt_set_prescaler(uint32_t div_factor)
-
uint32_t wdt_get_prescaler(void)
-
void wdt_set_reload_ms(uint32_t period_ms)
-
void wdt_set_reload(uint32_t timeout)
-
uint32_t wdt_get_reload(void)
-
void wdt_feed(void)
-
void wdt_start(void)
-
void wdt_stop(void)
-
void wdt_set_debug_stop_mode(bool enable)
Stop watchdog counter clock when core is halted.
- Parameters
enable – [in] counter clock stopped when true. Otherwise continues
-
void wdt_set_interrupt(bool enable)
Set watchdog interrupt.
The default behavior is to reset the system if not interrupt set
- Parameters
enable – [in] enables interrupt when true. disables when false
-
bool wdt_is_event_raised(void)
-
void wdt_set_clock_source(clk_source_t clk)
-
clk_source_t wdt_get_clock_source(void)