Kinetis SDK v.1.3 API Reference Manual  Rev. 0
Freescale Semiconductor, Inc.
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
WDOG HAL driver

Overview

This section describes the programming interface of the WDOG HAL driver.

Data Structures

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

Enumerations

enum  wdog_clk_src_t {
  kWdogLpoClkSrc = 0U,
  kWdogAlternateClkSrc = 1U
}
 Describes WDOG clock source structure. More...
 
enum  wdog_clk_prescaler_t {
  kWdogClkPrescalerDivide1 = 0x0U,
  kWdogClkPrescalerDivide2 = 0x1U,
  kWdogClkPrescalerDivide3 = 0x2U,
  kWdogClkPrescalerDivide4 = 0x3U,
  kWdogClkPrescalerDivide5 = 0x4U,
  kWdogClkPrescalerDivide6 = 0x5U,
  kWdogClkPrescalerDivide7 = 0x6U,
  kWdogClkPrescalerDivide8 = 0x7U
}
 Describes the selection of the clock prescaler. More...
 
enum  wdog_status_t {
  kStatus_WDOG_Success = 0x0U,
  kStatus_WDOG_Fail = 0x1U,
  kStatus_WDOG_NotInitlialized = 0x2U,
  kStatus_WDOG_NullArgument = 0x3U
}
 WDOG status return codes. More...
 

Watchdog HAL.

static void WDOG_HAL_Enable (WDOG_Type *base)
 Enables the Watchdog module. More...
 
static void WDOG_HAL_Disable (WDOG_Type *base)
 Disables the Watchdog module. More...
 
static bool WDOG_HAL_IsEnable (WDOG_Type *base)
 Checks whether the WDOG is enabled. More...
 
void WDOG_HAL_SetConfig (WDOG_Type *base, const wdog_config_t *configPtr)
 Sets the WDOG common configuration. More...
 
static void WDOG_HAL_SetIntCmd (WDOG_Type *base, bool enable)
 Enables and disables the Watchdog interrupt. More...
 
static bool WDOG_HAL_GetIntFlag (WDOG_Type *base)
 Gets the Watchdog interrupt status. More...
 
static void WDOG_HAL_ClearIntStatusFlag (WDOG_Type *base)
 Clears the Watchdog interrupt flag. More...
 
static void WDOG_HAL_SetTimeoutValue (WDOG_Type *base, uint32_t timeoutCount)
 Sets the Watchdog timeout value. More...
 
static uint32_t WDOG_HAL_GetTimerOutputValue (WDOG_Type *base)
 Gets the Watchdog timer output. More...
 
static void WDOG_HAL_SetWindowValue (WDOG_Type *base, uint32_t windowValue)
 Sets the Watchdog window value. More...
 
static void WDOG_HAL_Unlock (WDOG_Type *base)
 Unlocks the Watchdog register written. More...
 
static void WDOG_HAL_Refresh (WDOG_Type *base)
 Refreshes the Watchdog timer. More...
 
static void WDOG_HAL_ResetSystem (WDOG_Type *base)
 Resets the chip using the Watchdog. More...
 
void WDOG_HAL_Init (WDOG_Type *base)
 Restores the WDOG module to reset value. More...
 

Data Structure Documentation

struct wdog_work_mode_t

Data Fields

bool kWdogEnableInStopMode
 Enables or disables WDOG in stop mode.
 
bool kWdogEnableInDebugMode
 Enables or disables WDOG in debug mode.
 
struct wdog_config_t

Data Fields

bool wdogEnable
 Enables or disables WDOG.
 
wdog_clk_src_t clkSrc
 Clock source select.
 
wdog_clk_prescaler_t prescaler
 Clock prescaler value.
 
wdog_work_mode_t workMode
 Configures WDOG work mode in debug stop and wait mode.
 
bool updateEnable
 Update write-once register enable.
 
bool intEnable
 Enables or disables WDOG interrupt.
 
bool winEnable
 Enables or disables WDOG window mode.
 
uint32_t windowValue
 Window value.
 
uint32_t timeoutValue
 Timeout value.
 

Enumeration Type Documentation

Enumerator
kWdogLpoClkSrc 

WDOG clock sourced from the LPO.

kWdogAlternateClkSrc 

WDOG clock sourced from the alternate clock source.

Enumerator
kWdogClkPrescalerDivide1 

Divided by 1.

kWdogClkPrescalerDivide2 

Divided by 2.

kWdogClkPrescalerDivide3 

Divided by 3.

kWdogClkPrescalerDivide4 

Divided by 4.

kWdogClkPrescalerDivide5 

Divided by 5.

kWdogClkPrescalerDivide6 

Divided by 6.

kWdogClkPrescalerDivide7 

Divided by 7.

kWdogClkPrescalerDivide8 

Divided by 8.

Enumerator
kStatus_WDOG_Success 

WDOG operation Succeed.

kStatus_WDOG_Fail 

WDOG operation Failed.

kStatus_WDOG_NotInitlialized 

WDOG is not initialized yet.

kStatus_WDOG_NullArgument 

Argument is NULL.

Function Documentation

static void WDOG_HAL_Enable ( WDOG_Type *  base)
inlinestatic

This function enables the WDOG. Ensure that the WDOG registers are unlocked by the WDOG_HAL_Unlock, that the WCT window is still open, and that the WDOG_STCTRLH register is not written in this WCT while this function is called.

Parameters
baseThe WDOG peripheral base address
static void WDOG_HAL_Disable ( WDOG_Type *  base)
inlinestatic

This function disables the WDOG. Ensure that the WDOG registers are unlocked by the WDOG_HAL_Unlock, that the WCT window is still open, and that the WDOG_STCTRLH register is not written in this WCT while this function is called.

Parameters
baseThe WDOG peripheral base address
static bool WDOG_HAL_IsEnable ( WDOG_Type *  base)
inlinestatic

This function checks whether the WDOG is enabled.

Parameters
baseThe WDOG peripheral base address
Returns
false means WDOG is disabled, true means WODG is enabled.
void WDOG_HAL_SetConfig ( WDOG_Type *  base,
const wdog_config_t configPtr 
)

This function is used to set the WDOG common configuration. Ensure WDOG registers are unlocked by the WDOG_HAL_Unlock, that the WCT window is still open, and that the WDOG_STCTRLH register is not written in this WCT while this function is called. Additionally, ensure that the WDOG_STCTRLH.ALLOWUPDATE is 1, which means that the register update is enabled. The common configuration is controlled by the WDOG_STCTRLH. This is a write-once register and this interface is used to set all field of the WDOG_STCTRLH registers at the same time. If only one field needs to be set, the API can be used. These API write to the WDOG_STCTRLH register: WDOG_HAL_Enable,WDOG_HAL_Disable,WDOG_HAL_SetIntCmd,#WDOG_HAL_SetClockSourceMode,#WDOG_HAL_SetWindowModeCmd, #WDOG_HAL_SetRegisterUpdateCmd,#WDOG_HAL_SetWorkInDebugModeCmd,#WDOG_HAL_SetWorkInStopModeCmd, #WDOG_HAL_SetWorkInWaitModeCmd

Parameters
baseThe WDOG peripheral base address
configPtrThe common configure of the WDOG
static void WDOG_HAL_SetIntCmd ( WDOG_Type *  base,
bool  enable 
)
inlinestatic

This function enables or disables the WDOG interrupt. Ensure that the WDOG registers are unlocked by the WDOG_HAL_Unlock, that the WCT window is still open, and that the WDOG_STCTRLH register is not written in this WCT while this function is called. Additionally, ensure that the WDOG_STCTRLH.ALLOWUPDATE is 1, which means that the register update is enabled.

Parameters
baseThe WDOG peripheral base address
enablefalse means disable watchdog interrupt and true means enable watchdog interrupt.
static bool WDOG_HAL_GetIntFlag ( WDOG_Type *  base)
inlinestatic

This function gets the WDOG interrupt flag.

Parameters
baseThe WDOG peripheral base address
Returns
Watchdog interrupt status, false means interrupt not asserted, true means interrupt asserted.
static void WDOG_HAL_ClearIntStatusFlag ( WDOG_Type *  base)
inlinestatic

This function clears the WDOG interrupt flag.

Parameters
baseThe WDOG peripheral base address
static void WDOG_HAL_SetTimeoutValue ( WDOG_Type *  base,
uint32_t  timeoutCount 
)
inlinestatic

This function sets the WDOG_TOVAL value. Ensure that the timeout value for the Watchdog is always greater than 2xWCT time + 20 bus clock cycles. Additionally, ensure that the WDOG registers are unlocked by the WDOG_HAL_Unlock, that the WCT window is still open, and that the WDOG_STCTRLH register is not written in this WCT while this function is called. Make sure that the WDOG_STCTRLH.ALLOWUPDATE is 1, which means that the register update is enabled.

Parameters
baseThe WDOG peripheral base address
timeoutCountwatchdog timeout value, count of watchdog clock tick.
static uint32_t WDOG_HAL_GetTimerOutputValue ( WDOG_Type *  base)
inlinestatic

This function gets the WDOG_TMROUT value.

Parameters
baseThe WDOG peripheral base address
Returns
Current value of watchdog timer counter.
static void WDOG_HAL_SetWindowValue ( WDOG_Type *  base,
uint32_t  windowValue 
)
inlinestatic

This function sets the WDOG_WIN value. Ensure that the WDOG registers are unlocked by the WDOG_HAL_Unlock, that the WCT window is still open, and that the WDOG_STCTRLH register is not written in this WCT while this function is called. Additionally, ensure that the WDOG_STCTRLH.ALLOWUPDATE is 1, which means that the register update is enabled.

Parameters
baseThe WDOG peripheral base address
windowValuewatchdog window value.
static void WDOG_HAL_Unlock ( WDOG_Type *  base)
inlinestatic

This function unlocks the WDOG register written. This function must be called before any configuration is set because watchdog register is locked automatically after a WCT(256 bus cycles).

Parameters
baseThe WDOG peripheral base address
static void WDOG_HAL_Refresh ( WDOG_Type *  base)
inlinestatic

This function feeds the WDOG. This function should be called before watchdog timer is in timeout. Otherwise, a reset is asserted.

Parameters
baseThe WDOG peripheral base address
static void WDOG_HAL_ResetSystem ( WDOG_Type *  base)
inlinestatic

This function resets the chip using WDOG.

Parameters
baseThe WDOG peripheral base address
void WDOG_HAL_Init ( WDOG_Type *  base)

This function restores the WDOG module to reset value.

Parameters
baseThe WDOG peripheral base address