MCUXpresso SDK API Reference Manual  Rev. 0
NXP Semiconductors
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
WKT: Self-wake-up Timer

Overview

The MCUXpresso SDK provides a driver for the Self-wake-up Timer (WKT) of MCUXpresso SDK devices.

Function groups

The WKT driver supports operating the module as a time counter.

Initialization and deinitialization

The function WKT_Init() initializes the WKT with specified configurations. The function WKT_GetDefaultConfig() gets the default configurations. The initialization function configures the WKT operating mode.

The function WKT_Deinit() stops the WKT timers and disables the module clock.

Read actual WKT counter value

The function WKT_GetCounterValue() reads the current timer counting value. This function returns the real-time timer counting value, in a range from 0 to a timer period.

Start and Stop timer operations

The function WKT_StartTimer() starts the timer counting. After calling this function, the timer loads the period value, counts down to 0. When the timer reaches 0, it stops and generates a trigger pulse and sets the timeout interrupt flag.

The function WKT_StopTimer() stops the timer counting.

Status

Provides functions to get and clear the WKT status flags.

Typical use case

WKT tick example

Updates the WKT period and toggles an LED periodically. Refer to the driver examples codes located at <SDK_ROOT>/boards/<BOARD>/driver_examples/wkt

Files

file  fsl_wkt.h
 

Data Structures

struct  wkt_config_t
 Describes WKT configuration structure. More...
 

Enumerations

enum  wkt_clock_source_t {
  kWKT_DividedFROClockSource = 0U,
  kWKT_LowPowerClockSource = 1U,
  kWKT_ExternalClockSource = 2U
}
 Describes WKT clock source. More...
 
enum  wkt_status_flags_t { kWKT_AlarmFlag = WKT_CTRL_ALARMFLAG_MASK }
 List of WKT flags. More...
 

Driver version

#define FSL_WKT_DRIVER_VERSION   (MAKE_VERSION(2, 0, 1))
 Version 2.0.1.
 

Initialization and deinitialization

void WKT_Init (WKT_Type *base, const wkt_config_t *config)
 Ungates the WKT clock and configures the peripheral for basic operation. More...
 
void WKT_Deinit (WKT_Type *base)
 Gate the WKT clock. More...
 
static void WKT_GetDefaultConfig (wkt_config_t *config)
 Initializes the WKT configuration structure. More...
 

Read the counter value.

static uint32_t WKT_GetCounterValue (WKT_Type *base)
 Read actual WKT counter value. More...
 

Status Interface

static uint32_t WKT_GetStatusFlags (WKT_Type *base)
 Gets the WKT status flags. More...
 
static void WKT_ClearStatusFlags (WKT_Type *base, uint32_t mask)
 Clears the WKT status flags. More...
 

Timer Start and Stop

static void WKT_StartTimer (WKT_Type *base, uint32_t count)
 Starts the timer counting. More...
 
static void WKT_StopTimer (WKT_Type *base)
 Stops the timer counting. More...
 

Data Structure Documentation

struct wkt_config_t

Data Fields

wkt_clock_source_t clockSource
 External or internal clock source select.
 

Enumeration Type Documentation

Enumerator
kWKT_DividedFROClockSource 

WKT clock sourced from the divided FRO clock.

kWKT_LowPowerClockSource 

WKT clock sourced from the Low power clock Use this clock, LPOSCEN bit of DPDCTRL register must be enabled.

kWKT_ExternalClockSource 

WKT clock sourced from the Low power clock Use this clock, WAKECLKPAD_DISABLE bit of DPDCTRL register must be enabled.

Enumerator
kWKT_AlarmFlag 

Alarm flag.

Function Documentation

void WKT_Init ( WKT_Type *  base,
const wkt_config_t config 
)
Note
This API should be called at the beginning of the application using the WKT driver.
Parameters
baseWKT peripheral base address
configPointer to user's WKT config structure.
void WKT_Deinit ( WKT_Type *  base)
Parameters
baseWKT peripheral base address
static void WKT_GetDefaultConfig ( wkt_config_t config)
inlinestatic

This function initializes the WKT configuration structure to default values. The default values are as follows.

* config->clockSource = kWKT_DividedFROClockSource;
*
Parameters
configPointer to the WKT configuration structure.
See Also
wkt_config_t
static uint32_t WKT_GetCounterValue ( WKT_Type *  base)
inlinestatic
Parameters
baseWKT peripheral base address
static uint32_t WKT_GetStatusFlags ( WKT_Type *  base)
inlinestatic
Parameters
baseWKT peripheral base address
Returns
The status flags. This is the logical OR of members of the enumeration wkt_status_flags_t
static void WKT_ClearStatusFlags ( WKT_Type *  base,
uint32_t  mask 
)
inlinestatic
Parameters
baseWKT peripheral base address
maskThe status flags to clear. This is a logical OR of members of the enumeration wkt_status_flags_t
static void WKT_StartTimer ( WKT_Type *  base,
uint32_t  count 
)
inlinestatic

After calling this function, timer loads a count value, counts down to 0, then stops.

Note
User can call the utility macros provided in fsl_common.h to convert to ticks Do not write to Counter register while the counting is in progress
Parameters
baseWKT peripheral base address.
countThe value to be loaded into the WKT Count register
static void WKT_StopTimer ( WKT_Type *  base)
inlinestatic

This function Clears the counter and stops the timer from counting.

Parameters
baseWKT peripheral base address