objc

Typedefs | Functions

Watchdog timer abstraction, which can be used to respond to dead processes, and also reset the system programmatically. More...

Collaboration diagram for Watchdog:

Typedefs

typedef struct hw_watchdog_t hw_watchdog_t
 Watchdog adapter.
 

Functions

hw_watchdog_thw_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...
 

Detailed Description

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.

Function Documentation

◆ hw_watchdog_did_reset()

bool hw_watchdog_did_reset ( hw_watchdog_t watchdog)

Check if the watchdog triggered a system reset.

Parameters
watchdogPointer to the watchdog structure
Returns
true if the last reboot was triggered by the watchdog, false otherwise

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.

Examples:
examples/runtime/watchdog/main.c.

◆ hw_watchdog_enable()

void hw_watchdog_enable ( hw_watchdog_t watchdog,
bool  enable 
)

Enable or disable the watchdog timer.

Parameters
watchdogPointer to the watchdog structure
enableIf 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()

◆ hw_watchdog_finalize()

void hw_watchdog_finalize ( hw_watchdog_t watchdog)

Finalize the watchdog timer subsystem.

Parameters
watchdogPointer to the watchdog structure to finalize

Disables the watchdog. After this call, the watchdog cannot be used until re-initialized.

Examples:
examples/runtime/watchdog/main.c.

◆ hw_watchdog_init()

hw_watchdog_t* hw_watchdog_init ( )

Initialize the watchdog timer subsystem.

Parameters
timeout_msWatchdog timeout in milliseconds
Returns
Pointer to a hw_watchdog_t handle, or NULL if watchdog is not supported

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.

Examples:
examples/runtime/watchdog/main.c.

◆ hw_watchdog_maxtimeout()

uint32_t hw_watchdog_maxtimeout ( void  )

Return the maximum supported watchdog timeout.

Returns
The maximum supported watchdog timeout in milliseconds, or 0 if watchdogs are not supported on this platform.
Examples:
examples/runtime/watchdog/main.c.

◆ hw_watchdog_reset()

void hw_watchdog_reset ( hw_watchdog_t watchdog,
uint32_t  delay_ms 
)

Cause a reset after a delay.

Parameters
watchdogPointer to the watchdog structure
delay_msDelay 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.

Examples:
examples/runtime/watchdog/main.c.

◆ hw_watchdog_valid()

bool hw_watchdog_valid ( hw_watchdog_t watchdog)

Check if the watchdog is in a valid state.

Parameters
watchdogPointer to the watchdog structure
Returns
true if the watchdog is valid, false otherwise
Examples:
examples/runtime/watchdog/main.c.