Mistake on this page?
Report an issue in GitHub or email us
Public Member Functions | Static Public Member Functions
Watchdog Class Reference

A hardware watchdog timer that resets the system in the case of system failures or malfunctions. More...

#include <Watchdog.h>

Inheritance diagram for Watchdog:
NonCopyable< Watchdog >

Public Member Functions

bool start ()
 Start the Watchdog timer with the maximum timeout value available for the target. More...
 
bool start (uint32_t timeout)
 Start the Watchdog timer. More...
 
bool stop ()
 Stop the Watchdog timer. More...
 
uint32_t get_timeout () const
 Get the Watchdog timer refresh value. More...
 
uint32_t get_max_timeout () const
 Get the maximum Watchdog refresh value for this platform. More...
 
bool is_running () const
 Check if the Watchdog timer is already running. More...
 
void kick ()
 Refresh the Watchdog timer. More...
 

Static Public Member Functions

static Watchdogget_instance ()
 Get a reference to the single Watchdog instance in the system. More...
 

Detailed Description

A hardware watchdog timer that resets the system in the case of system failures or malfunctions.

If you fail to refresh the Watchdog timer periodically, it resets the system after a set period of time.

There is only one instance of the Watchdog class in the system, which directly maps to the hardware. Use Watchdog::get_instance to obtain a reference.

Watchdog::start initializes a system timer with a time period specified in timeout param. This timer counts down and triggers a system reset when it wraps. To prevent the system reset, you must periodically kick or refresh the timer by calling Watchdog::kick, which resets the countdown to the initial value.

Example:

Watchdog &watchdog = Watchdog::get_instance();
watchdog.start(500);
while (true) {
// kick watchdog regularly within provided timeout
watchdog.kick();
// Application code
}
Note
Synchronization level: Interrupt safe

Definition at line 64 of file Watchdog.h.

Member Function Documentation

static Watchdog& get_instance ( )
static

Get a reference to the single Watchdog instance in the system.

Returns
A reference to the single Watchdog instance present in the system.

Definition at line 71 of file Watchdog.h.

uint32_t get_max_timeout ( ) const

Get the maximum Watchdog refresh value for this platform.

Returns
Maximum reload value supported by the Watchdog timer for this platform in milliseconds.
uint32_t get_timeout ( ) const

Get the Watchdog timer refresh value.

This function returns the refresh timeout of the watchdog peripheral.

Returns
Reload value for the Watchdog timer in milliseconds.
bool is_running ( ) const

Check if the Watchdog timer is already running.

Returns
true if the Watchdog timer is running and false otherwise.
void kick ( )

Refresh the Watchdog timer.

Call this function periodically before the Watchdog times out. Otherwise, the system resets.

If the Watchdog timer is not running, this function does nothing.

bool start ( )

Start the Watchdog timer with the maximum timeout value available for the target.

Note
The timeout is set to a value returned by Watchdog::get_max_timeout.

If the Watchdog timer is already running, this function does nothing.

Returns
true if the Watchdog timer was started successfully; false if the Watchdog timer was not started or if the Watchdog timer is already running.
bool start ( uint32_t  timeout)

Start the Watchdog timer.

Note
Asset that the timeout param is supported by the target (0 < timeout <= Watchdog::get_max_timeout).
Parameters
timeoutWatchdog timeout in milliseconds.
Returns
true if the Watchdog timer was started successfully; false if Watchdog timer was not started or if the Watchdog timer is already running.
bool stop ( )

Stop the Watchdog timer.

Calling this function disables a running Watchdog peripheral if the platform supports it.

Returns
true if the Watchdog timer was successfully stopped; false if the Watchdog timer cannot be disabled on this platform or if the Watchdog timer has not been started.
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.