MCUXpresso SDK API Reference Manual  Rev 2.16.000
NXP Semiconductors
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
WAKETIMER: WAKETIMER Driver

Overview

The MCUXpresso SDK provides a peripheral driver for the WAKETIMER module of MCUXpresso SDK devices. WAKETIMER driver is created to help user to operate the WAKETIMER module. The WAKETIMER timer can be used as a low power timer. The APIs can be used to enable the WAKETIMER module, initialize it, start the countdown timer, get the current timer count. WAKETIMER can be used as a wake up source from low power mode.

Function groups

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

Initialization and deinitialization

The WAKETIMER_GetDefaultConfig() will generate the default config. The WAKETIMER_Init() function will initialize the WAKETIMER. The WAKETIMER_Deinit() function will deinitialize WAKETIMER.

WAKETIMER interrupt

The function WAKETIMER_EnableInterrupts() enable timeout interrupt. The function WAKETIMER_DisableInterrupts() disable timeout interrupt. The function WAKETIMER_ClearInterruptFlags() clear the timeout interrupt flag. The function WAKETIMER_SetCallback() set the timeout user callback function.

WAKETIMER set match value

The function WAKETIMER_HaltTimer() halt the counter and stop the timer. The function WAKETIMER_StartTimer() stop the timer with a given countdown value. The function WAKETIMER_GetCurrentTimerValue() return current counter value.

Typical use case

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

Files

file  fsl_waketimer.h
 

Data Structures

struct  waketimer_config_t
 WAKETIMER configuration structure. More...
 

Typedefs

typedef void(* waketimer_callback_t )(void)
 waketimer callback function. More...
 

Enumerations

enum  _waketimer_status_flags { kWAKETIMER_WakeFlag }
 WAKETIMER status flags. More...
 
enum  _waketimer_interrupt_enable { kWAKETIMER_WakeInterruptEnable = WAKETIMER_WAKE_TIMER_CTRL_INTR_EN_MASK }
 Define interrupt switchers of the module. More...
 

Driver version

#define FSL_WAKETIMER_DRIVER_VERSION   (MAKE_VERSION(2, 0, 1))
 WAKETIMER driver version. More...
 

Initialization and deinitialization

void WAKETIMER_Init (WAKETIMER_Type *base, const waketimer_config_t *config)
 Initializes an WAKETIMER. More...
 
void WAKETIMER_Deinit (WAKETIMER_Type *base)
 Deinitializes a WAKETIMER instance. More...
 
void WAKETIMER_GetDefaultConfig (waketimer_config_t *config)
 Fills in the WAKETIMER configuration structure with the default settings. More...
 

Interrupt Interface

void WAKETIMER_EnableInterrupts (WAKETIMER_Type *base, uint32_t mask)
 Enables the selected WAKETIMER interrupts. More...
 
void WAKETIMER_DisableInterrupts (WAKETIMER_Type *base, uint32_t mask)
 Enables the selected WAKETIMER interrupts. More...
 
void WAKETIMER_ClearStatusFlags (WAKETIMER_Type *base, uint32_t mask)
 Clear Status Interrupt Flag. More...
 
void WAKETIMER_SetCallback (WAKETIMER_Type *base, waketimer_callback_t callback)
 Receive noticification when waketime countdown. More...
 

Timer Start and Stop

static void WAKETIMER_HaltTimer (WAKETIMER_Type *base)
 Halt and clear timer counter. More...
 
static void WAKETIMER_StartTimer (WAKETIMER_Type *base, uint32_t value)
 Set timer counter. More...
 
uint32_t WAKETIMER_GetCurrentTimerValue (WAKETIMER_Type *base)
 Get current timer count value from WAKETIMER. More...
 

Data Structure Documentation

struct waketimer_config_t

This structure holds the configuration settings for the WAKETIMER peripheral. To initialize this structure to reasonable defaults, call the WAKETIMER_GetDefaultConfig() function and pass a pointer to the configuration structure instance.

The configuration structure can be made constant so as to reside in flash.

Data Fields

bool enableOSCDivide
 true: Enable OSC Divide. More...
 
bool enableInterrupt
 true: Enable interrupt. More...
 
waketimer_callback_t callback
 timer countdown callback. More...
 

Field Documentation

bool waketimer_config_t::enableOSCDivide

false: Disable OSC Divide.

bool waketimer_config_t::enableInterrupt

false: Disable interrupt.

waketimer_callback_t waketimer_config_t::callback

Macro Definition Documentation

#define FSL_WAKETIMER_DRIVER_VERSION   (MAKE_VERSION(2, 0, 1))

Typedef Documentation

typedef void(* waketimer_callback_t)(void)

Enumeration Type Documentation

Enumerator
kWAKETIMER_WakeFlag 

Wake Timer Status Flag, sets wake timer has timed out.

Enumerator
kWAKETIMER_WakeInterruptEnable 

Generate interrupt requests when WAKE_FLAG is asserted.

Function Documentation

void WAKETIMER_Init ( WAKETIMER_Type *  base,
const waketimer_config_t config 
)

This function initializes the WAKETIMER.

Parameters
baseWAKETIMER peripheral base address.
configPointer to the user configuration structure.
void WAKETIMER_Deinit ( WAKETIMER_Type *  base)

This function deinitialize the WAKETIMER.

Parameters
baseWAKETIMER peripheral base address.
void WAKETIMER_GetDefaultConfig ( waketimer_config_t config)

The default values are:

* config->enableInterrupt = true;
* config->enableOSCDivide = true;
* config->callback = NULL;
*
Parameters
configPointer to the user configuration structure.
void WAKETIMER_EnableInterrupts ( WAKETIMER_Type *  base,
uint32_t  mask 
)
Parameters
baseWAKETIMER peripheral base address
maskMask value for interrupt events. See to _waketimer_interrupt_enable
void WAKETIMER_DisableInterrupts ( WAKETIMER_Type *  base,
uint32_t  mask 
)
Parameters
baseWAKETIMER peripheral base address
maskMask value for interrupt events. See to _waketimer_interrupt_enable
void WAKETIMER_ClearStatusFlags ( WAKETIMER_Type *  base,
uint32_t  mask 
)

This clears intrrupt status flag. Currently, only match interrupt flag can be cleared.

Parameters
baseWAKETIMER peripheral base address.
maskMask value for flags to be cleared. See to _waketimer_status_flags.
Returns
none
void WAKETIMER_SetCallback ( WAKETIMER_Type *  base,
waketimer_callback_t  callback 
)

If the interrupt for the waketime countdown is enabled, then a callback can be registered which will be invoked when the event is triggered

Parameters
baseWAKETIMER peripheral base address
callbackFunction to invoke when the event is triggered
static void WAKETIMER_HaltTimer ( WAKETIMER_Type *  base)
inlinestatic

This halt and clear timer counter.

Parameters
baseWAKETIMER peripheral base address.
Returns
none
static void WAKETIMER_StartTimer ( WAKETIMER_Type *  base,
uint32_t  value 
)
inlinestatic

This set the timer counter and start the timer countdown.

Parameters
baseWAKETIMER peripheral base address.
valuecountdown value.
Returns
none
uint32_t WAKETIMER_GetCurrentTimerValue ( WAKETIMER_Type *  base)

This function will get a decimal timer count value. The RAW value of timer count is gray code format, will be translated to decimal data internally.

Parameters
baseWAKETIMER peripheral base address.
Returns
Value of WAKETIMER which will be formated to decimal value.