MCUXpresso SDK API Reference Manual  Rev. 0
NXP Semiconductors
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
WDOG: Watchdog Timer Driver

Overview

The MCUXpresso SDK provides a peripheral driver for the Watchdog module (WDOG) of MCUXpresso SDK devices.

Typical use case

Refer to the driver examples codes located at <SDK_ROOT>/boards/<BOARD>/driver_examples/wdog

Data Structures

struct  wdog_work_mode_t
 Defines WDOG work mode. More...
 
struct  wdog_config_t
 Describes WDOG configuration structure. More...
 

Enumerations

enum  _wdog_interrupt_enable { kWDOG_InterruptEnable = WDOG_WICR_WIE_MASK }
 WDOG interrupt configuration structure, default settings all disabled. More...
 
enum  _wdog_status_flags {
  kWDOG_RunningFlag = WDOG_WCR_WDE_MASK,
  kWDOG_PowerOnResetFlag = WDOG_WRSR_POR_MASK,
  kWDOG_TimeoutResetFlag = WDOG_WRSR_TOUT_MASK,
  kWDOG_SoftwareResetFlag = WDOG_WRSR_SFTW_MASK,
  kWDOG_InterruptFlag = WDOG_WICR_WTIS_MASK
}
 WDOG status flags. More...
 

Driver version

#define FSL_WDOG_DRIVER_VERSION   (MAKE_VERSION(2, 1, 1))
 Defines WDOG driver version.
 

Refresh sequence

#define WDOG_REFRESH_KEY   (0xAAAA5555U)
 

WDOG Initialization and De-initialization.

void WDOG_GetDefaultConfig (wdog_config_t *config)
 Initializes the WDOG configuration structure. More...
 
void WDOG_Init (WDOG_Type *base, const wdog_config_t *config)
 Initializes the WDOG. More...
 
void WDOG_Deinit (WDOG_Type *base)
 Shuts down the WDOG. More...
 
static void WDOG_Enable (WDOG_Type *base)
 Enables the WDOG module. More...
 
static void WDOG_Disable (WDOG_Type *base)
 Disables the WDOG module. More...
 
static void WDOG_TriggerSystemSoftwareReset (WDOG_Type *base)
 Trigger the system software reset. More...
 
static void WDOG_TriggerSoftwareSignal (WDOG_Type *base)
 Trigger an output assertion. More...
 
static void WDOG_EnableInterrupts (WDOG_Type *base, uint16_t mask)
 Enables the WDOG interrupt. More...
 
uint16_t WDOG_GetStatusFlags (WDOG_Type *base)
 Gets the WDOG all reset status flags. More...
 
void WDOG_ClearInterruptStatus (WDOG_Type *base, uint16_t mask)
 Clears the WDOG flag. More...
 
static void WDOG_SetTimeoutValue (WDOG_Type *base, uint16_t timeoutCount)
 Sets the WDOG timeout value. More...
 
static void WDOG_SetInterrputTimeoutValue (WDOG_Type *base, uint16_t timeoutCount)
 Sets the WDOG interrupt count timeout value. More...
 
static void WDOG_DisablePowerDownEnable (WDOG_Type *base)
 Disable the WDOG power down enable bit. More...
 
void WDOG_Refresh (WDOG_Type *base)
 Refreshes the WDOG timer. More...
 

Data Structure Documentation

struct wdog_work_mode_t

Data Fields

bool enableWait
 continue or suspend WDOG in wait mode
 
bool enableStop
 continue or suspend WDOG in stop mode
 
bool enableDebug
 continue or suspend WDOG in debug mode
 
struct wdog_config_t

Data Fields

bool enableWdog
 Enables or disables WDOG.
 
wdog_work_mode_t workMode
 Configures WDOG work mode in debug stop and wait mode.
 
bool enableInterrupt
 Enables or disables WDOG interrupt.
 
uint16_t timeoutValue
 Timeout value.
 
uint16_t interruptTimeValue
 Interrupt count timeout value.
 
bool softwareResetExtension
 software reset extension
 
bool enablePowerDown
 power down enable bit
 
bool enableTimeOutAssert
 Enable WDOG_B timeout assertion. More...
 

Field Documentation

bool wdog_config_t::enableTimeOutAssert

Enumeration Type Documentation

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_PowerOnResetFlag 

Power On flag, set when reset is the result of a powerOnReset.

kWDOG_TimeoutResetFlag 

Timeout flag, set when reset is the result of a timeout.

kWDOG_SoftwareResetFlag 

Software flag, set when reset is the result of a software.

kWDOG_InterruptFlag 

interrupt flag,whether interrupt has occurred or not

Function Documentation

void WDOG_GetDefaultConfig ( wdog_config_t config)

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->enableInterrupt = false;
* wdogConfig->enablePowerdown = false;
* wdogConfig->resetExtension = flase;
* wdogConfig->timeoutValue = 0xFFU;
* wdogConfig->interruptTimeValue = 0x04u;
*
Parameters
configPointer 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.

This is an example.

* wdog_config_t config;
* config.timeoutValue = 0xffU;
* config->interruptTimeValue = 0x04u;
* WDOG_Init(wdog_base,&config);
*
Parameters
baseWDOG peripheral base address
configThe configuration of WDOG
void WDOG_Deinit ( WDOG_Type *  base)

This function shuts down the WDOG. Watchdog Enable bit is a write one once only bit. It is not possible to clear this bit by a software write, once the bit is set. This bit(WDE) can be set/reset only in debug mode(exception).

static void WDOG_Enable ( WDOG_Type *  base)
inlinestatic

This function writes a value into the WDOG_WCR register to enable the WDOG. This is a write one once only bit. It is not possible to clear this bit by a software write, once the bit is set. only debug mode exception.

Parameters
baseWDOG peripheral base address
static void WDOG_Disable ( WDOG_Type *  base)
inlinestatic

This function writes a value into the WDOG_WCR register to disable the WDOG. This is a write one once only bit. It is not possible to clear this bit by a software write,once the bit is set. only debug mode exception

Parameters
baseWDOG peripheral base address
static void WDOG_TriggerSystemSoftwareReset ( WDOG_Type *  base)
inlinestatic

This function will write to the WCR[SRS] bit to trigger a software system reset. This bit will automatically resets to "1" after it has been asserted to "0". Note: Calling this API will reset the system right now, please using it with more attention.

Parameters
baseWDOG peripheral base address
static void WDOG_TriggerSoftwareSignal ( WDOG_Type *  base)
inlinestatic

This function will write to the WCR[WDA] bit to trigger WDOG_B signal assertion. The WDOG_B signal can be routed to external pin of the chip, the output pin will turn to assertion along with WDOG_B signal. Note: The WDOG_B signal will remain assert until a power on reset occurred, so, please take more attention while calling it.

Parameters
baseWDOG peripheral base address
static void WDOG_EnableInterrupts ( WDOG_Type *  base,
uint16_t  mask 
)
inlinestatic

This bit is a write once only bit. Once the software does a write access to this bit, it will get locked and cannot be reprogrammed until the next system reset assertion

Parameters
baseWDOG peripheral base address
maskThe interrupts to enable The parameter can be combination of the following source if defined.
  • kWDOG_InterruptEnable
uint16_t WDOG_GetStatusFlags ( WDOG_Type *  base)

This function gets all reset status flags.

* uint16_t status;
* status = WDOG_GetStatusFlags (wdog_base);
*
Parameters
baseWDOG peripheral base address
Returns
State of the status flag: asserted (true) or not-asserted (false).
See Also
_wdog_status_flags
  • true: a related status flag has been set.
  • false: a related status flag is not set.
void WDOG_ClearInterruptStatus ( WDOG_Type *  base,
uint16_t  mask 
)

This function clears the WDOG status flag.

This is an example for clearing the interrupt flag.

* WDOG_ClearStatusFlags(wdog_base,KWDOG_InterruptFlag);
*
Parameters
baseWDOG peripheral base address
maskThe status flags to clear. The parameter could be any combination of the following values. kWDOG_TimeoutFlag
static void WDOG_SetTimeoutValue ( WDOG_Type *  base,
uint16_t  timeoutCount 
)
inlinestatic

This function sets the timeout value. This function writes a value into WCR registers. The time-out value can be written at any point of time but it is loaded to the counter at the time when WDOG is enabled or after the service routine has been performed.

Parameters
baseWDOG peripheral base address
timeoutCountWDOG timeout value; count of WDOG clock tick.
static void WDOG_SetInterrputTimeoutValue ( WDOG_Type *  base,
uint16_t  timeoutCount 
)
inlinestatic

This function sets the interrupt count timeout value. This function writes a value into WIC registers which are wirte-once. This field is write once only. Once the software does a write access to this field, it will get locked and cannot be reprogrammed until the next system reset assertion.

Parameters
baseWDOG peripheral base address
timeoutCountWDOG timeout value; count of WDOG clock tick.
static void WDOG_DisablePowerDownEnable ( WDOG_Type *  base)
inlinestatic

This function disable the WDOG power down enable(PDE). This function writes a value into WMCR registers which are wirte-once. This field is write once only. Once software sets this bit it cannot be reset until the next system reset.

Parameters
baseWDOG 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
baseWDOG peripheral base address