Watchdog timer abstraction, which can be used to respond to dead processes, and also reset the system programmatically. More...
![]() |
Typedefs | |
typedef struct hw_watchdog_t | hw_watchdog_t |
Watchdog adapter. | |
Functions | |
hw_watchdog_t * | hw_watchdog_init () |
Initialize the watchdog timer subsystem. More... | |
void | hw_watchdog_finalize (hw_watchdog_t *watchdog) |
Finalize the watchdog timer subsystem. More... | |
uint32_t | hw_watchdog_maxtimeout (void) |
Return the maximum supported watchdog timeout. More... | |
bool | hw_watchdog_valid (hw_watchdog_t *watchdog) |
Check if the watchdog is in a valid state. More... | |
bool | hw_watchdog_did_reset (hw_watchdog_t *watchdog) |
Check if the watchdog triggered a system reset. More... | |
void | hw_watchdog_enable (hw_watchdog_t *watchdog, bool enable) |
Enable or disable the watchdog timer. More... | |
void | hw_watchdog_reset (hw_watchdog_t *watchdog, uint32_t delay_ms) |
Cause a reset after a delay. More... | |
Watchdog timer abstraction, which can be used to respond to dead processes, and also reset the system programmatically.
The watchdog timer is a critical safety mechanism that can automatically restart the system if software becomes unresponsive.
After enabling the watchdog, applications must periodically "feed" the watchdog to prevent automatic system reset, by calling hw_poll(), usually from the event loop.
The watchdog can also be used to programmatically reset the system after a delay. After calling hw_watchdog_reset(), the system will optionally call the hw_power_callback_t callback and then reset after the specified delay.
bool hw_watchdog_did_reset | ( | hw_watchdog_t * | watchdog | ) |
Check if the watchdog triggered a system reset.
watchdog | Pointer to the watchdog structure |
This function checks if the last system reboot was caused by the watchdog timer. It is useful for debugging and ensuring that the watchdog is functioning correctly.
void hw_watchdog_enable | ( | hw_watchdog_t * | watchdog, |
bool | enable | ||
) |
Enable or disable the watchdog timer.
watchdog | Pointer to the watchdog structure |
enable | If true, enables the watchdog timer; if false, disables it. |
Starts or stops the watchdog countdown timer. Once enabled, the application must call hw_poll() periodically in the event loop to prevent system reset, no less than the value returned by hw_watchdog_maxtimeout()
void hw_watchdog_finalize | ( | hw_watchdog_t * | watchdog | ) |
Finalize the watchdog timer subsystem.
watchdog | Pointer to the watchdog structure to finalize |
Disables the watchdog. After this call, the watchdog cannot be used until re-initialized.
hw_watchdog_t* hw_watchdog_init | ( | ) |
Initialize the watchdog timer subsystem.
timeout_ms | Watchdog timeout in milliseconds |
Performs platform-specific initialization of the watchdog hardware. Returns NULL if watchdog is not supported or initialization failed.
In order for the watchdog to function, hw_poll() must be called periodically.
uint32_t hw_watchdog_maxtimeout | ( | void | ) |
Return the maximum supported watchdog timeout.
void hw_watchdog_reset | ( | hw_watchdog_t * | watchdog, |
uint32_t | delay_ms | ||
) |
Cause a reset after a delay.
watchdog | Pointer to the watchdog structure |
delay_ms | Delay in milliseconds before the reset occurs |
This function configures the watchdog to trigger a system reset after the specified delay. The delay is clamped to the maximum supported timeout. The reset can be cancelled by calling hw_watchdog_enable() with any value.
bool hw_watchdog_valid | ( | hw_watchdog_t * | watchdog | ) |
Check if the watchdog is in a valid state.
watchdog | Pointer to the watchdog structure |