Watchdog Timer Peripheral Driver.
In order to be able to use the Watchdog in your application, the first thing to do is initializing it with the desired configuration. This is done by calling the WDOG_DRV_Init function. One of the arguments passed to this function is the configuration which will be used for the Watchdog, specified by the wdog_user_config_t structure.
The wdog_user_config_t structure allows you to configure the following:
Please note that if the updates are disabled the Watchdog cannot be later modified without forcing a reset (this implies that further calls of the WDOG_DRV_Init, WDOG_DRV_Deinit or WDOG_DRV_SetInt functions will lead to a reset).
As mentioned before, a timeout interrupt may be enabled by specifying it at the module initialization. The WDOG_DRV_Init only allows enabling/disabling the interrupt, and it does not set up the ISR to be used for the interrupt request. In order to set up a function to be called after a reset-triggering event (and also enable/disable the interrupt), the WDOG_DRV_SetInt function may be used. Please note that, due to the 128 bus clocks delay before the reset, a limited amount of job can be done in the ISR.
Data Structures | |
struct | wdog_op_mode_t |
WDOG option mode configuration structure Implements : wdog_op_mode_t_Class. More... | |
struct | wdog_user_config_t |
WDOG user configuration structure Implements : wdog_user_config_t_Class. More... | |
Enumerations | |
enum | wdog_clk_source_t { WDOG_BUS_CLOCK = 0x00U, WDOG_LPO_CLOCK = 0x01U, WDOG_SOSC_CLOCK = 0x02U, WDOG_SIRC_CLOCK = 0x03U } |
Clock sources for the WDOG. Implements : wdog_clk_source_t_Class. More... | |
enum | wdog_test_mode_t { WDOG_TST_DISABLED = 0x00U, WDOG_TST_USER = 0x01U, WDOG_TST_LOW = 0x02U, WDOG_TST_HIGH = 0x03U } |
Test modes for the WDOG. Implements : wdog_test_mode_t_Class. More... | |
enum | wdog_set_mode_t { WDOG_DEBUG_MODE = 0x00U, WDOG_WAIT_MODE = 0x01U, WDOG_STOP_MODE = 0x02U } |
set modes for the WDOG. Implements : wdog_set_mode_t_Class More... | |
WDOG Driver API | |
status_t | WDOG_DRV_Init (uint32_t instance, const wdog_user_config_t *userConfigPtr) |
Initializes the WDOG driver. More... | |
status_t | WDOG_DRV_Deinit (uint32_t instance) |
De-initializes the WDOG driver. More... | |
void | WDOG_DRV_GetConfig (uint32_t instance, wdog_user_config_t *const config) |
Gets the current configuration of the WDOG. More... | |
void | WDOG_DRV_GetDefaultConfig (wdog_user_config_t *const config) |
Gets default configuration of the WDOG. More... | |
status_t | WDOG_DRV_SetInt (uint32_t instance, bool enable) |
Enables/Disables the WDOG timeout interrupt and sets a function to be called when a timeout interrupt is received, before reset. More... | |
void | WDOG_DRV_ClearIntFlag (uint32_t instance) |
Clear interrupt flag of the WDOG. More... | |
void | WDOG_DRV_Trigger (uint32_t instance) |
Refreshes the WDOG counter. More... | |
uint16_t | WDOG_DRV_GetCounter (uint32_t instance) |
Gets the value of the WDOG counter. More... | |
status_t | WDOG_DRV_SetWindow (uint32_t instance, bool enable, uint16_t windowvalue) |
Set window mode and window value of the WDOG. More... | |
status_t | WDOG_DRV_SetMode (uint32_t instance, bool enable, wdog_set_mode_t Setmode) |
Sets the mode operation of the WDOG. More... | |
status_t | WDOG_DRV_SetTimeout (uint32_t instance, uint16_t timeout) |
Sets the value of the WDOG timeout. More... | |
status_t | WDOG_DRV_SetTestMode (uint32_t instance, wdog_test_mode_t testMode) |
Changes the WDOG test mode. More... | |
wdog_test_mode_t | WDOG_DRV_GetTestMode (uint32_t instance) |
Gets the WDOG test mode. More... | |
enum wdog_clk_source_t |
Clock sources for the WDOG. Implements : wdog_clk_source_t_Class.
Enumerator | |
---|---|
WDOG_BUS_CLOCK |
Bus clock |
WDOG_LPO_CLOCK |
LPO clock |
WDOG_SOSC_CLOCK |
SOSC clock |
WDOG_SIRC_CLOCK |
SIRC clock |
Definition at line 52 of file wdog_driver.h.
enum wdog_set_mode_t |
set modes for the WDOG. Implements : wdog_set_mode_t_Class
Enumerator | |
---|---|
WDOG_DEBUG_MODE |
Debug mode |
WDOG_WAIT_MODE |
Wait mode |
WDOG_STOP_MODE |
Stop mode |
Definition at line 76 of file wdog_driver.h.
enum wdog_test_mode_t |
Test modes for the WDOG. Implements : wdog_test_mode_t_Class.
Definition at line 64 of file wdog_driver.h.
void WDOG_DRV_ClearIntFlag | ( | uint32_t | instance | ) |
Clear interrupt flag of the WDOG.
[in] | instance | WDOG peripheral instance number |
Definition at line 273 of file wdog_driver.c.
status_t WDOG_DRV_Deinit | ( | uint32_t | instance | ) |
De-initializes the WDOG driver.
[in] | instance | WDOG peripheral instance number |
Definition at line 163 of file wdog_driver.c.
void WDOG_DRV_GetConfig | ( | uint32_t | instance, |
wdog_user_config_t *const | config | ||
) |
Gets the current configuration of the WDOG.
[in] | instance | WDOG peripheral instance number |
[out] | configures | the current configuration |
Definition at line 198 of file wdog_driver.c.
uint16_t WDOG_DRV_GetCounter | ( | uint32_t | instance | ) |
Gets the value of the WDOG counter.
[in] | instance | WDOG peripheral instance number. |
Definition at line 304 of file wdog_driver.c.
void WDOG_DRV_GetDefaultConfig | ( | wdog_user_config_t *const | config | ) |
Gets default configuration of the WDOG.
[out] | configures | the default configuration |
Definition at line 215 of file wdog_driver.c.
wdog_test_mode_t WDOG_DRV_GetTestMode | ( | uint32_t | instance | ) |
Gets the WDOG test mode.
This function verifies the test mode of the WDOG.
[in] | instance | WDOG peripheral instance number |
Definition at line 462 of file wdog_driver.c.
status_t WDOG_DRV_Init | ( | uint32_t | instance, |
const wdog_user_config_t * | userConfigPtr | ||
) |
Initializes the WDOG driver.
[in] | instance | WDOG peripheral instance number |
[in] | userConfigPtr | pointer to the WDOG user configuration structure |
Definition at line 105 of file wdog_driver.c.
status_t WDOG_DRV_SetInt | ( | uint32_t | instance, |
bool | enable | ||
) |
Enables/Disables the WDOG timeout interrupt and sets a function to be called when a timeout interrupt is received, before reset.
[in] | instance | WDOG peripheral instance number |
[in] | enable | enable/disable interrupt |
Definition at line 241 of file wdog_driver.c.
status_t WDOG_DRV_SetMode | ( | uint32_t | instance, |
bool | enable, | ||
wdog_set_mode_t | Setmode | ||
) |
Sets the mode operation of the WDOG.
This function changes the mode operation of the WDOG.
[in] | instance | WDOG peripheral instance number. |
[in] | enable | enable/disable mode of the WDOG. |
[in] | Setmode | select mode of the WDOG. |
Definition at line 355 of file wdog_driver.c.
status_t WDOG_DRV_SetTestMode | ( | uint32_t | instance, |
wdog_test_mode_t | testMode | ||
) |
Changes the WDOG test mode.
This function changes the test mode of the WDOG. If the WDOG is tested in mode, software should set this field to 0x01U in order to indicate that the WDOG is functioning normally.
[in] | instance | WDOG peripheral instance number |
[in] | testMode | Test modes for the WDOG. |
Definition at line 429 of file wdog_driver.c.
status_t WDOG_DRV_SetTimeout | ( | uint32_t | instance, |
uint16_t | timeout | ||
) |
Sets the value of the WDOG timeout.
This function sets the value of the WDOG timeout.
[in] | instance | WDOG peripheral instance number. |
[in] | timeout | the value of the WDOG timeout. |
Definition at line 400 of file wdog_driver.c.
status_t WDOG_DRV_SetWindow | ( | uint32_t | instance, |
bool | enable, | ||
uint16_t | windowvalue | ||
) |
Set window mode and window value of the WDOG.
This function set window mode, window value is set when window mode enabled.
[in] | instance | WDOG peripheral instance number. |
[in] | enable | enable/disable window mode and window value. |
[in] | windowvalue | the value of the WDOG window. |
Definition at line 319 of file wdog_driver.c.
void WDOG_DRV_Trigger | ( | uint32_t | instance | ) |
Refreshes the WDOG counter.
[in] | instance | WDOG peripheral instance number |
Definition at line 289 of file wdog_driver.c.