Mbed OS Reference
Loading...
Searching...
No Matches
Watchdog HAL API

Low-level interface to the Independent Watchdog Timer of a target. More...

Modules

 Watchdog HAL tests
 Greentea tests for the Watchdog HAL.
 

Data Structures

struct  watchdog_config_t
 Watchdog configuration. More...
 
struct  watchdog_features_t
 Watchdog features. More...
 

Enumerations

enum  watchdog_status_t { WATCHDOG_STATUS_OK , WATCHDOG_STATUS_NOT_SUPPORTED , WATCHDOG_STATUS_INVALID_ARGUMENT }
 Status of a watchdog operation. More...
 

Functions

watchdog_status_t hal_watchdog_init (const watchdog_config_t *config)
 Initialize and start a watchdog timer with the given configuration. More...
 
void hal_watchdog_kick (void)
 Refreshes the watchdog timer. More...
 
watchdog_status_t hal_watchdog_stop (void)
 Stops the watchdog timer. More...
 
uint32_t hal_watchdog_get_reload_value (void)
 Get the watchdog timer refresh value. More...
 
watchdog_features_t hal_watchdog_get_platform_features (void)
 Get information on the current platforms supported watchdog functionality. More...
 

Detailed Description

Low-level interface to the Independent Watchdog Timer of a target.

This module provides platform independent access to the system watchdog timer which is an embedded peripheral that will reset the system in the case of system failures or malfunctions.

The watchdog timer initializes a system timer with a time period specified in the configuration. This timer counts down and triggers a system reset when it wraps. To prevent the system reset the timer must be continually kicked/refreshed by calling hal_watchdog_kick which will reset the countdown to the user specified reset value.

Defined behavior

Undefined behavior

Notes

Enumeration Type Documentation

◆ watchdog_status_t

Status of a watchdog operation.

Enumerator
WATCHDOG_STATUS_OK 

Operation successful.

WATCHDOG_STATUS_NOT_SUPPORTED 

Operation not supported.

WATCHDOG_STATUS_INVALID_ARGUMENT 

Invalid argument.

Definition at line 117 of file watchdog_api.h.

Function Documentation

◆ hal_watchdog_init()

watchdog_status_t hal_watchdog_init ( const watchdog_config_t config)

Initialize and start a watchdog timer with the given configuration.

If the watchdog timer is configured and starts successfully, this function returns WATCHDOG_STATUS_OK.

If the timeout specified is outside the range supported by the platform, it returns WATCHDOG_STATUS_INVALID_ARGUMENT.

Parameters
[in]configConfiguration settings for the watchdog timer
Returns
WATCHDOG_STATUS_OK if the watchdog is configured correctly and has started. Otherwise a status indicating the fault.

◆ hal_watchdog_kick()

void hal_watchdog_kick ( void  )

Refreshes the watchdog timer.

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

If a watchdog is not running, this function does nothing.

◆ hal_watchdog_stop()

watchdog_status_t hal_watchdog_stop ( void  )

Stops the watchdog timer.

Calling this function disables any running watchdog timers if the current platform supports them.

Returns
Returns WATCHDOG_STATUS_OK if the watchdog timer was succesfully stopped, or if the timer was never started. Returns WATCHDOG_STATUS_NOT_SUPPORTED if the watchdog cannot be disabled on the current platform.

◆ hal_watchdog_get_reload_value()

uint32_t hal_watchdog_get_reload_value ( void  )

Get the watchdog timer refresh value.

This function returns the configured refresh timeout of the watchdog timer.

Returns
Reload value for the watchdog timer in milliseconds.

◆ hal_watchdog_get_platform_features()

watchdog_features_t hal_watchdog_get_platform_features ( void  )

Get information on the current platforms supported watchdog functionality.

Returns
watchdog_feature_t indicating supported watchdog features on the current platform