WDOG - Watchdog
Description
Watchdog (WDOG) Peripheral API.
This module contains functions to control the WDOG peripheral of Silicon Labs 32-bit MCUs and SoCs. The WDOG resets the system in case of a fault condition.
Data Structures |
|
struct | WDOG_Init_TypeDef |
Watchdog initialization structure.
|
|
Functions |
|
void | WDOGn_Enable (WDOG_TypeDef *wdog, bool enable) |
Enable/disable the watchdog timer.
|
|
void | WDOGn_Feed (WDOG_TypeDef *wdog) |
Feed WDOG.
|
|
void | WDOGn_Init (WDOG_TypeDef *wdog, const WDOG_Init_TypeDef *init) |
Initialize WDOG (assuming the WDOG configuration has not been locked).
|
|
void | WDOGn_Lock (WDOG_TypeDef *wdog) |
Lock the WDOG configuration.
|
|
void | WDOGn_SyncWait (WDOG_TypeDef *wdog) |
Wait for the WDOG to complete all synchronization of register changes and commands.
|
|
void | WDOGn_Unlock (WDOG_TypeDef *wdog) |
Unlock the WDOG configuration.
|
|
void | WDOGn_IntClear (WDOG_TypeDef *wdog, uint32_t flags) |
Clear one or more pending WDOG interrupts.
|
|
void | WDOGn_IntDisable (WDOG_TypeDef *wdog, uint32_t flags) |
Disable one or more WDOG interrupts.
|
|
void | WDOGn_IntEnable (WDOG_TypeDef *wdog, uint32_t flags) |
Enable one or more WDOG interrupts.
|
|
uint32_t | WDOGn_IntGet (WDOG_TypeDef *wdog) |
Get pending WDOG interrupt flags.
|
|
uint32_t | WDOGn_IntGetEnabled (WDOG_TypeDef *wdog) |
Get enabled and pending WDOG interrupt flags.
|
|
void | WDOGn_IntSet (WDOG_TypeDef *wdog, uint32_t flags) |
Set one or more pending WDOG interrupts from SW.
|
|
bool | WDOGn_IsEnabled (WDOG_TypeDef *wdog) |
Get enabled status of the watchdog.
|
|
bool | WDOGn_IsLocked (WDOG_TypeDef *wdog) |
Get locked status of the watchdog.
|
|
void | WDOG_Enable (bool enable) |
Enable/disable the watchdog timer.
|
|
void | WDOG_Feed (void) |
Feed the watchdog.
|
|
void | WDOG_Init (const WDOG_Init_TypeDef *init) |
Initialize watchdog (assuming the watchdog configuration has not been locked).
|
|
void | WDOG_Lock (void) |
Lock the watchdog configuration.
|
|
bool | WDOG_IsEnabled (void) |
Get enabled status of the watchdog.
|
|
bool | WDOG_IsLocked (void) |
Get locked status of the watchdog.
|
|
Macros |
|
#define | WDOG_SYNC_TIMEOUT 30000 |
In some scenarioes when the watchdog is disabled the synchronization register might be set and not be cleared until the watchdog is enabled again.
|
|
#define | DEFAULT_WDOG WDOG0 |
Default WDOG instance for deprecated functions.
|
|
#define | WDOG_INIT_DEFAULT |
Suggested default configuration for WDOG initialization structure.
|
|
Function Documentation
◆ WDOGn_Enable()
void WDOGn_Enable | ( | WDOG_TypeDef * |
wdog,
|
bool |
enable
|
||
) |
Enable/disable the watchdog timer.
- Note
- This function modifies the WDOG CTRL register which requires synchronization into the low-frequency domain. If this register is modified before a previous update to the same register has completed, this function will stall until the previous synchronization has completed.
- Parameters
-
[in] wdog
A pointer to the WDOG peripheral register block. [in] enable
True to enable Watchdog, false to disable. Watchdog cannot be disabled if it's been locked.
◆ WDOGn_Feed()
void WDOGn_Feed | ( | WDOG_TypeDef * |
wdog
|
) |
Feed WDOG.
When WDOG is activated, it must be fed (i.e., clearing the counter) before it reaches the defined timeout period. Otherwise, WDOG will generate a reset.
- Note
- Note that WDOG is an asynchronous peripheral and when calling the WDOGn_Feed() function the hardware starts the process of clearing the counter. This process takes some time before it completes depending on the selected oscillator (up to 4 peripheral clock cycles). When using the ULFRCO for instance as the oscillator the watchdog runs on a 1 kHz clock and a watchdog clear operation might take up to 4 ms.
If the device enters EM2 or EM3 while a command is in progress then that command will be aborted. An application can use WDOGn_SyncWait() to wait for a command to complete.
- Parameters
-
[in] wdog
A pointer to the WDOG peripheral register block.
◆ WDOGn_Init()
void WDOGn_Init | ( | WDOG_TypeDef * |
wdog,
|
const WDOG_Init_TypeDef * |
init
|
||
) |
Initialize WDOG (assuming the WDOG configuration has not been locked).
- Note
- This function modifies the WDOG CTRL register which requires synchronization into the low-frequency domain. If this register is modified before a previous update to the same register has completed, this function will stall until the previous synchronization has completed.
- Parameters
-
[in] wdog
Pointer to the WDOG peripheral register block. [in] init
The structure holding the WDOG configuration. A default setting WDOG_INIT_DEFAULT is available for initialization.
◆ WDOGn_Lock()
void WDOGn_Lock | ( | WDOG_TypeDef * |
wdog
|
) |
Lock the WDOG configuration.
This prevents errors from overwriting the WDOG configuration, possibly disabling it. Only a reset can unlock the WDOG configuration once locked.
If the LFRCO or LFXO clocks are used to clock WDOG, consider using the option of inhibiting those clocks to be disabled. See the WDOG_Enable() initialization structure.
- Note
- This function modifies the WDOG CTRL register which requires synchronization into the low-frequency domain. If this register is modified before a previous update to the same register has completed, this function will stall until the previous synchronization has completed.
- Parameters
-
[in] wdog
A pointer to WDOG peripheral register block.
◆ WDOGn_SyncWait()
void WDOGn_SyncWait | ( | WDOG_TypeDef * |
wdog
|
) |
Wait for the WDOG to complete all synchronization of register changes and commands.
- Parameters
-
[in] wdog
A pointer to WDOG peripheral register block.
◆ WDOGn_Unlock()
void WDOGn_Unlock | ( | WDOG_TypeDef * |
wdog
|
) |
Unlock the WDOG configuration.
Note that this function will have no effect on devices where a reset is the only way to unlock the watchdog.
- Parameters
-
[in] wdog
A pointer to WDOG peripheral register block.
◆ WDOGn_IntClear()
|
inline |
Clear one or more pending WDOG interrupts.
- Parameters
-
[in] wdog
Pointer to WDOG peripheral register block. [in] flags
WDOG interrupt sources to clear. Use a set of interrupt flags OR-ed together to clear multiple interrupt sources.
◆ WDOGn_IntDisable()
|
inline |
Disable one or more WDOG interrupts.
- Parameters
-
[in] wdog
Pointer to WDOG peripheral register block. [in] flags
WDOG interrupt sources to disable. Use a set of interrupt flags OR-ed together to disable multiple interrupt.
◆ WDOGn_IntEnable()
|
inline |
Enable one or more WDOG interrupts.
- Note
- Depending on the use, a pending interrupt may already be set prior to enabling the interrupt. To ignore a pending interrupt, consider using WDOG_IntClear() prior to enabling the interrupt.
- Parameters
-
[in] wdog
Pointer to WDOG peripheral register block. [in] flags
WDOG interrupt sources to enable. Use a set of interrupt flags OR-ed together to set multiple interrupt.
◆ WDOGn_IntGet()
|
inline |
Get pending WDOG interrupt flags.
- Note
- The event bits are not cleared by the use of this function.
- Parameters
-
[in] wdog
Pointer to WDOG peripheral register block.
- Returns
- Pending WDOG interrupt sources. Returns a set of interrupt flags OR-ed together for the interrupt sources set.
◆ WDOGn_IntGetEnabled()
|
inline |
Get enabled and pending WDOG interrupt flags.
Useful for handling more interrupt sources in the same interrupt handler.
- Parameters
-
[in] wdog
Pointer to WDOG peripheral register block.
- Returns
- Pending and enabled WDOG interrupt sources. Returns a set of interrupt flags OR-ed together for the interrupt sources set.
◆ WDOGn_IntSet()
|
inline |
Set one or more pending WDOG interrupts from SW.
- Parameters
-
[in] wdog
Pointer to WDOG peripheral register block. [in] flags
WDOG interrupt sources to set to pending. Use a set of interrupt flags (WDOG_IFS_nnn).
◆ WDOGn_IsEnabled()
|
inline |
Get enabled status of the watchdog.
- Parameters
-
[in] wdog
Pointer to WDOG peripheral register block.
- Returns
- True if watchdog is enabled.
◆ WDOGn_IsLocked()
|
inline |
Get locked status of the watchdog.
- Parameters
-
[in] wdog
Pointer to WDOG peripheral register block.
- Returns
- True if watchdog is locked.
◆ WDOG_Enable()
|
inline |
Enable/disable the watchdog timer.
- Parameters
-
[in] enable
Set to true to enable watchdog, false to disable. Watchdog cannot be disabled if watchdog has been locked.
◆ WDOG_Feed()
|
inline |
Feed the watchdog.
◆ WDOG_Init()
|
inline |
Initialize watchdog (assuming the watchdog configuration has not been locked).
- Parameters
-
[in] init
Structure holding watchdog configuration. A default setting WDOG_INIT_DEFAULT is available for initialization.
◆ WDOG_Lock()
|
inline |
Lock the watchdog configuration.
◆ WDOG_IsEnabled()
|
inline |
Get enabled status of the watchdog.
- Returns
- True if watchdog is enabled.
◆ WDOG_IsLocked()
|
inline |
Get locked status of the watchdog.
- Returns
- True if watchdog is locked.
Macro Definition Documentation
◆ WDOG_SYNC_TIMEOUT
#define WDOG_SYNC_TIMEOUT 30000 |
In some scenarioes when the watchdog is disabled the synchronization register might be set and not be cleared until the watchdog is enabled again.
This will happen when for instance some watchdog register is modified while the watchdog clock is disabled. In these scenarioes we need to make sure that the software does not wait forever.
◆ DEFAULT_WDOG
#define DEFAULT_WDOG WDOG0 |
Default WDOG instance for deprecated functions.
◆ WDOG_INIT_DEFAULT
#define WDOG_INIT_DEFAULT |
Suggested default configuration for WDOG initialization structure.
Enumeration Type Documentation
◆ WDOG_ClkSel_TypeDef
enum WDOG_ClkSel_TypeDef |
◆ WDOG_PeriodSel_TypeDef
Watchdog period selection.
◆ WDOG_WarnSel_TypeDef
enum WDOG_WarnSel_TypeDef |
Select watchdog warning timeout period as percentage of timeout.
◆ WDOG_WinSel_TypeDef
enum WDOG_WinSel_TypeDef |
Select watchdog illegal window limit.