The MCUXpresso SDK provides a peripheral driver for the Watchdog module (WDOG) of MCUXpresso SDK devices.
Typical use case
|
enum | wdog_clock_source_t {
kWDOG_LpoClockSource = 0U,
kWDOG_AlternateClockSource = 1U
} |
| Describes WDOG clock source. More...
|
|
enum | wdog_clock_prescaler_t {
kWDOG_ClockPrescalerDivide1 = 0x0U,
kWDOG_ClockPrescalerDivide2 = 0x1U,
kWDOG_ClockPrescalerDivide3 = 0x2U,
kWDOG_ClockPrescalerDivide4 = 0x3U,
kWDOG_ClockPrescalerDivide5 = 0x4U,
kWDOG_ClockPrescalerDivide6 = 0x5U,
kWDOG_ClockPrescalerDivide7 = 0x6U,
kWDOG_ClockPrescalerDivide8 = 0x7U
} |
| Describes the selection of the clock prescaler. More...
|
|
enum | wdog_test_mode_t {
kWDOG_QuickTest = 0U,
kWDOG_ByteTest = 1U
} |
| Describes WDOG test mode. More...
|
|
enum | wdog_tested_byte_t {
kWDOG_TestByte0 = 0U,
kWDOG_TestByte1 = 1U,
kWDOG_TestByte2 = 2U,
kWDOG_TestByte3 = 3U
} |
| Describes WDOG tested byte selection in byte test mode. More...
|
|
enum | _wdog_interrupt_enable_t { kWDOG_InterruptEnable = WDOG_STCTRLH_IRQRSTEN_MASK
} |
| WDOG interrupt configuration structure, default settings all disabled. More...
|
|
enum | _wdog_status_flags_t {
kWDOG_RunningFlag = WDOG_STCTRLH_WDOGEN_MASK,
kWDOG_TimeoutFlag = WDOG_STCTRLL_INTFLG_MASK
} |
| WDOG status flags. More...
|
|
Data Fields |
bool | enableWait |
| Enables or disables WDOG in wait mode.
|
|
bool | enableStop |
| Enables or disables WDOG in stop mode.
|
|
bool | enableDebug |
| Enables or disables WDOG in debug mode.
|
|
struct wdog_test_config_t |
Enumerator |
---|
kWDOG_LpoClockSource |
WDOG clock sourced from LPO.
|
kWDOG_AlternateClockSource |
WDOG clock sourced from alternate clock source.
|
Enumerator |
---|
kWDOG_ClockPrescalerDivide1 |
Divided by 1.
|
kWDOG_ClockPrescalerDivide2 |
Divided by 2.
|
kWDOG_ClockPrescalerDivide3 |
Divided by 3.
|
kWDOG_ClockPrescalerDivide4 |
Divided by 4.
|
kWDOG_ClockPrescalerDivide5 |
Divided by 5.
|
kWDOG_ClockPrescalerDivide6 |
Divided by 6.
|
kWDOG_ClockPrescalerDivide7 |
Divided by 7.
|
kWDOG_ClockPrescalerDivide8 |
Divided by 8.
|
Enumerator |
---|
kWDOG_QuickTest |
Selects quick test.
|
kWDOG_ByteTest |
Selects byte test.
|
Enumerator |
---|
kWDOG_TestByte0 |
Byte 0 selected in byte test mode.
|
kWDOG_TestByte1 |
Byte 1 selected in byte test mode.
|
kWDOG_TestByte2 |
Byte 2 selected in byte test mode.
|
kWDOG_TestByte3 |
Byte 3 selected in byte test mode.
|
This structure contains the settings for all of the WDOG interrupt configurations.
Enumerator |
---|
kWDOG_InterruptEnable |
WDOG timeout generates an interrupt before reset.
|
This structure contains the WDOG status flags for use in the WDOG functions.
Enumerator |
---|
kWDOG_RunningFlag |
Running flag, set when WDOG is enabled.
|
kWDOG_TimeoutFlag |
Interrupt flag, set when an exception occurs.
|
This function initializes the WDOG configuration structure to default values. The default values are as follows.
* wdogConfig->enableWdog = true;
* wdogConfig->workMode.enableWait = true;
* wdogConfig->workMode.enableStop = false;
* wdogConfig->workMode.enableDebug = false;
* wdogConfig->enableUpdate = true;
* wdogConfig->enableInterrupt = false;
* wdogConfig->enableWindowMode = false;
* wdogConfig->windowValue = 0;
* wdogConfig->timeoutValue = 0xFFFFU;
*
- Parameters
-
config | Pointer to the WDOG configuration structure. |
- See Also
- wdog_config_t
void WDOG_Init |
( |
WDOG_Type * |
base, |
|
|
const wdog_config_t * |
config |
|
) |
| |
This function initializes the WDOG. When called, the WDOG runs according to the configuration. To reconfigure WDOG without forcing a reset first, enableUpdate must be set to true in the configuration.
This is an example.
- Parameters
-
base | WDOG peripheral base address |
config | The configuration of WDOG |
void WDOG_Deinit |
( |
WDOG_Type * |
base | ) |
|
This function shuts down the WDOG. Ensure that the WDOG_STCTRLH.ALLOWUPDATE is 1 which indicates that the register update is enabled.
This function is used to configure the WDOG functional test. When called, the WDOG goes into test mode and runs according to the configuration. Ensure that the WDOG_STCTRLH.ALLOWUPDATE is 1 which means that the register update is enabled.
This is an example.
- Parameters
-
base | WDOG peripheral base address |
config | The functional test configuration of WDOG |
static void WDOG_Enable |
( |
WDOG_Type * |
base | ) |
|
|
inlinestatic |
This function write value into WDOG_STCTRLH register to enable the WDOG, it is a write-once register, make sure that the WCT window is still open and this register has not been written in this WCT while this function is called.
- Parameters
-
base | WDOG peripheral base address |
static void WDOG_Disable |
( |
WDOG_Type * |
base | ) |
|
|
inlinestatic |
This function writes a value into the WDOG_STCTRLH register to disable the WDOG. It is a write-once register. Ensure that the WCT window is still open and that register has not been written to in this WCT while the function is called.
- Parameters
-
base | WDOG peripheral base address |
static void WDOG_EnableInterrupts |
( |
WDOG_Type * |
base, |
|
|
uint32_t |
mask |
|
) |
| |
|
inlinestatic |
This function writes a value into the WDOG_STCTRLH register to enable the WDOG interrupt. It is a write-once register. Ensure that the WCT window is still open and the register has not been written to in this WCT while the function is called.
- Parameters
-
base | WDOG peripheral base address |
mask | The interrupts to enable The parameter can be combination of the following source if defined.
|
static void WDOG_DisableInterrupts |
( |
WDOG_Type * |
base, |
|
|
uint32_t |
mask |
|
) |
| |
|
inlinestatic |
This function writes a value into the WDOG_STCTRLH register to disable the WDOG interrupt. It is a write-once register. Ensure that the WCT window is still open and the register has not been written to in this WCT while the function is called.
- Parameters
-
base | WDOG peripheral base address |
mask | The interrupts to disable The parameter can be combination of the following source if defined.
|
uint32_t WDOG_GetStatusFlags |
( |
WDOG_Type * |
base | ) |
|
This function gets all status flags.
This is an example for getting the Running Flag.
- Parameters
-
base | WDOG peripheral base address |
- Returns
- State of the status flag: asserted (true) or not-asserted (false).
- See Also
- _wdog_status_flags_t
- true: a related status flag has been set.
- false: a related status flag is not set.
void WDOG_ClearStatusFlags |
( |
WDOG_Type * |
base, |
|
|
uint32_t |
mask |
|
) |
| |
This function clears the WDOG status flag.
This is an example for clearing the timeout (interrupt) flag.
- Parameters
-
base | WDOG peripheral base address |
mask | The status flags to clear. The parameter could be any combination of the following values. kWDOG_TimeoutFlag |
static void WDOG_SetTimeoutValue |
( |
WDOG_Type * |
base, |
|
|
uint32_t |
timeoutCount |
|
) |
| |
|
inlinestatic |
This function sets the timeout value. It should be ensured that the time-out value for the WDOG is always greater than 2xWCT time + 20 bus clock cycles. This function writes a value into WDOG_TOVALH and WDOG_TOVALL registers which are wirte-once. Ensure the WCT window is still open and the two registers have not been written to in this WCT while the function is called.
- Parameters
-
base | WDOG peripheral base address |
timeoutCount | WDOG timeout value; count of WDOG clock tick. |
static void WDOG_SetWindowValue |
( |
WDOG_Type * |
base, |
|
|
uint32_t |
windowValue |
|
) |
| |
|
inlinestatic |
This function sets the WDOG window value. This function writes a value into WDOG_WINH and WDOG_WINL registers which are wirte-once. Ensure the WCT window is still open and the two registers have not been written to in this WCT while the function is called.
- Parameters
-
base | WDOG peripheral base address |
windowValue | WDOG window value. |
static void WDOG_Unlock |
( |
WDOG_Type * |
base | ) |
|
|
inlinestatic |
This function unlocks the WDOG register written. Before starting the unlock sequence and following congfiguration, disable the global interrupts. Otherwise, an interrupt may invalidate the unlocking sequence and the WCT may expire. After the configuration finishes, re-enable the global interrupts.
- Parameters
-
base | WDOG peripheral base address |
void WDOG_Refresh |
( |
WDOG_Type * |
base | ) |
|
This function feeds the WDOG. This function should be called before the WDOG timer is in timeout. Otherwise, a reset is asserted.
- Parameters
-
base | WDOG peripheral base address |
static uint16_t WDOG_GetResetCount |
( |
WDOG_Type * |
base | ) |
|
|
inlinestatic |
This function gets the WDOG reset count value.
- Parameters
-
base | WDOG peripheral base address |
- Returns
- WDOG reset count value.
static void WDOG_ClearResetCount |
( |
WDOG_Type * |
base | ) |
|
|
inlinestatic |
This function clears the WDOG reset count value.
- Parameters
-
base | WDOG peripheral base address |