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/
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.
bool waketimer_config_t::enableOSCDivide |
false: Disable OSC Divide.
bool waketimer_config_t::enableInterrupt |
false: Disable interrupt.
#define FSL_WAKETIMER_DRIVER_VERSION (MAKE_VERSION(2, 0, 1)) |
typedef void(* waketimer_callback_t)(void) |
Enumerator |
---|
kWAKETIMER_WakeFlag |
Wake Timer Status Flag, sets wake timer has timed out.
|
Enumerator |
---|
kWAKETIMER_WakeInterruptEnable |
Generate interrupt requests when WAKE_FLAG is asserted.
|
This function initializes the WAKETIMER.
- Parameters
-
base | WAKETIMER peripheral base address. |
config | Pointer to the user configuration structure. |
void WAKETIMER_Deinit |
( |
WAKETIMER_Type * |
base | ) |
|
This function deinitialize the WAKETIMER.
- Parameters
-
base | WAKETIMER peripheral base address. |
The default values are:
* config->enableInterrupt = true;
* config->enableOSCDivide = true;
* config->callback = NULL;
*
- Parameters
-
config | Pointer to the user configuration structure. |
void WAKETIMER_EnableInterrupts |
( |
WAKETIMER_Type * |
base, |
|
|
uint32_t |
mask |
|
) |
| |
void WAKETIMER_DisableInterrupts |
( |
WAKETIMER_Type * |
base, |
|
|
uint32_t |
mask |
|
) |
| |
void WAKETIMER_ClearStatusFlags |
( |
WAKETIMER_Type * |
base, |
|
|
uint32_t |
mask |
|
) |
| |
This clears intrrupt status flag. Currently, only match interrupt flag can be cleared.
- Parameters
-
- Returns
- none
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
-
base | WAKETIMER peripheral base address |
callback | Function to invoke when the event is triggered |
static void WAKETIMER_HaltTimer |
( |
WAKETIMER_Type * |
base | ) |
|
|
inlinestatic |
This halt and clear timer counter.
- Parameters
-
base | WAKETIMER 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
-
base | WAKETIMER peripheral base address. |
value | countdown 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
-
base | WAKETIMER peripheral base address. |
- Returns
- Value of WAKETIMER which will be formated to decimal value.