WDOGEMLIB

Detailed 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
 

Macros

#define DEFAULT_WDOG   WDOG
 
#define WDOG_INIT_DEFAULT
 

Enumerations

enum  WDOG_ClkSel_TypeDef {
  wdogClkSelULFRCO = _WDOG_CTRL_CLKSEL_ULFRCO,
  wdogClkSelLFRCO = _WDOG_CTRL_CLKSEL_LFRCO,
  wdogClkSelLFXO = _WDOG_CTRL_CLKSEL_LFXO
}
 
enum  WDOG_PeriodSel_TypeDef {
  wdogPeriod_9 = 0x0,
  wdogPeriod_17 = 0x1,
  wdogPeriod_33 = 0x2,
  wdogPeriod_65 = 0x3,
  wdogPeriod_129 = 0x4,
  wdogPeriod_257 = 0x5,
  wdogPeriod_513 = 0x6,
  wdogPeriod_1k = 0x7,
  wdogPeriod_2k = 0x8,
  wdogPeriod_4k = 0x9,
  wdogPeriod_8k = 0xA,
  wdogPeriod_16k = 0xB,
  wdogPeriod_32k = 0xC,
  wdogPeriod_64k = 0xD,
  wdogPeriod_128k = 0xE,
  wdogPeriod_256k = 0xF
}
 

Functions

__STATIC_INLINE void WDOG_Enable (bool enable)
 Enable/disable the watchdog timer.
 
__STATIC_INLINE void WDOG_Feed (void)
 Feed the watchdog.
 
__STATIC_INLINE void WDOG_Init (const WDOG_Init_TypeDef *init)
 Initialize watchdog (assuming the watchdog configuration has not been locked).
 
__STATIC_INLINE void WDOG_Lock (void)
 Lock the watchdog configuration.
 
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.
 

Macro Definition Documentation

#define DEFAULT_WDOG   WDOG

Default WDOG instance for deprecated functions.

Definition at line 321 of file em_wdog.h.

Referenced by WDOG_Enable(), WDOG_Feed(), WDOG_Init(), and WDOG_Lock().

#define WDOG_INIT_DEFAULT
Value:
{ \
true, /* Start watchdog when initialization is done. */ \
false, /* WDOG is not counting during debug halt. */ \
false, /* WDOG is not counting when in EM2. */ \
false, /* WDOG is not counting when in EM3. */ \
false, /* EM4 can be entered. */ \
false, /* Do not block disabling LFRCO/LFXO in CMU. */ \
false, /* Do not lock WDOG configuration (if locked,
reset is needed to unlock). */ \
wdogClkSelULFRCO, /* Select 1 kHZ WDOG oscillator. */ \
wdogPeriod_256k /* Set longest possible timeout period. */ \
}

Suggested default configuration for WDOG initialization structure.

Definition at line 180 of file em_wdog.h.

Enumeration Type Documentation

Watchdog clock selection.

Enumerator
wdogClkSelULFRCO 

Ultra low frequency (1 kHz) clock

wdogClkSelLFRCO 

Low frequency RC oscillator

wdogClkSelLFXO 

Low frequency crystal oscillator

Definition at line 60 of file em_wdog.h.

Watchdog period selection.

Enumerator
wdogPeriod_9 

9 clock periods

wdogPeriod_17 

17 clock periods

wdogPeriod_33 

33 clock periods

wdogPeriod_65 

65 clock periods

wdogPeriod_129 

129 clock periods

wdogPeriod_257 

257 clock periods

wdogPeriod_513 

513 clock periods

wdogPeriod_1k 

1025 clock periods

wdogPeriod_2k 

2049 clock periods

wdogPeriod_4k 

4097 clock periods

wdogPeriod_8k 

8193 clock periods

wdogPeriod_16k 

16385 clock periods

wdogPeriod_32k 

32769 clock periods

wdogPeriod_64k 

65537 clock periods

wdogPeriod_128k 

131073 clock periods

wdogPeriod_256k 

262145 clock periods

Definition at line 67 of file em_wdog.h.

Function Documentation

__STATIC_INLINE void WDOG_Enable ( bool  enable)

Enable/disable the watchdog timer.

Deprecated:
Deprecated function. New code should use WDOGn_Enable(). This function uses DEFAULT_WDOG.
Parameters
[in]enableSet to true to enable watchdog, false to disable. Watchdog cannot be disabled if watchdog has been locked.

Definition at line 339 of file em_wdog.h.

References DEFAULT_WDOG, and WDOGn_Enable().

__STATIC_INLINE void WDOG_Feed ( void  )

Feed the watchdog.

Deprecated:
Deprecated function. New code should use WDOGn_Feed(). This function uses DEFAULT_WDOG.

Definition at line 352 of file em_wdog.h.

References DEFAULT_WDOG, and WDOGn_Feed().

__STATIC_INLINE void WDOG_Init ( const WDOG_Init_TypeDef init)

Initialize watchdog (assuming the watchdog configuration has not been locked).

Deprecated:
Deprecated function. New code should use WDOGn_Init(). This function uses DEFAULT_WDOG.
Parameters
[in]initStructure holding watchdog configuration. A default setting WDOG_INIT_DEFAULT is available for initialization.

Definition at line 370 of file em_wdog.h.

References DEFAULT_WDOG, and WDOGn_Init().

__STATIC_INLINE void WDOG_Lock ( void  )

Lock the watchdog configuration.

Deprecated:
Deprecated function. New code should use WDOGn_Lock(). This function uses DEFAULT_WDOG.

Definition at line 383 of file em_wdog.h.

References DEFAULT_WDOG, and WDOGn_Lock().

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]wdogA pointer to the WDOG peripheral register block.
[in]enableTrue to enable Watchdog, false to disable. Watchdog cannot be disabled if it's been locked.

Definition at line 75 of file em_wdog.c.

References _WDOG_CTRL_EN_SHIFT, BUS_RegBitRead(), BUS_RegBitWrite(), WDOG_TypeDef::CTRL, WDOG_TypeDef::SYNCBUSY, WDOG_CTRL_LOCK, and WDOG_SYNCBUSY_CTRL.

Referenced by WDOG_Enable().

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.

Parameters
[in]wdogA pointer to the WDOG peripheral register block.

Definition at line 109 of file em_wdog.c.

References WDOG_TypeDef::CMD, WDOG_TypeDef::CTRL, WDOG_TypeDef::SYNCBUSY, WDOG_CMD_CLEAR, WDOG_CTRL_EN, WDOG_SYNCBUSY_CMD, and WDOG_SYNCBUSY_CTRL.

Referenced by WDOG_Feed().

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]wdogPointer to the WDOG peripheral register block.
[in]initThe structure holding the WDOG configuration. A default setting WDOG_INIT_DEFAULT is available for initialization.

Definition at line 149 of file em_wdog.c.

References _WDOG_CTRL_CLKSEL_SHIFT, _WDOG_CTRL_PERSEL_SHIFT, WDOG_Init_TypeDef::clkSel, WDOG_TypeDef::CTRL, WDOG_Init_TypeDef::debugRun, WDOG_Init_TypeDef::em2Run, WDOG_Init_TypeDef::em3Run, WDOG_Init_TypeDef::em4Block, WDOG_Init_TypeDef::enable, WDOG_Init_TypeDef::lock, WDOG_Init_TypeDef::perSel, WDOG_Init_TypeDef::swoscBlock, WDOG_TypeDef::SYNCBUSY, WDOG_CTRL_DEBUGRUN, WDOG_CTRL_EM2RUN, WDOG_CTRL_EM3RUN, WDOG_CTRL_EM4BLOCK, WDOG_CTRL_EN, WDOG_CTRL_LOCK, WDOG_CTRL_SWOSCBLOCK, and WDOG_SYNCBUSY_CTRL.

Referenced by WDOG_Init().

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]wdogA pointer to WDOG peripheral register block.

Definition at line 223 of file em_wdog.c.

References _WDOG_CTRL_LOCK_SHIFT, BUS_RegBitWrite(), WDOG_TypeDef::CTRL, WDOG_TypeDef::SYNCBUSY, and WDOG_SYNCBUSY_CTRL.

Referenced by WDOG_Lock().