Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Embed: (wiki syntax)

« Back to documentation index

Watchdog Class Reference

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

#include <Watchdog.h>

Inherits NonCopyable< Watchdog >.

Public Member Functions

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

Static Public Member Functions

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

Private Member Functions

 MBED_DEPRECATED ("Invalid copy construction of a NonCopyable resource.") NonCopyable(const NonCopyable &)
 NonCopyable copy constructor.
 MBED_DEPRECATED ("Invalid copy assignment of a NonCopyable resource.") NonCopyable &operator
 NonCopyable copy assignment operator.

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.

Definition at line 94 of file Watchdog.cpp.

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.

Definition at line 89 of file Watchdog.cpp.

bool is_running (  ) const

Check if the Watchdog timer is already running.

Returns:
true if the Watchdog timer is running and false otherwise.

Definition at line 84 of file Watchdog.cpp.

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.

Definition at line 77 of file Watchdog.cpp.

bool start ( void   )

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.

Definition at line 51 of file Watchdog.cpp.

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.

Definition at line 31 of file Watchdog.cpp.

bool stop ( void   )

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.

Definition at line 57 of file Watchdog.cpp.