The MCUXpresso SDK provides a driver for the Low-Power Interrupt Timer (LPIT) of MCUXpresso SDK devices.
Function groups
The LPIT driver supports operating the module as a time counter.
Initialization and deinitialization
The function LPIT_Init() initializes the LPIT with specified configurations. The function LPIT_GetDefaultConfig() gets the default configurations. The initialization function configures the LPIT operation in doze mode and debug mode.
The function LPIT_SetupChannel() configures the operation of each LPIT channel.
The function LPIT_Deinit() disables the LPIT module and disables the module clock.
Timer period Operations
The function LPITR_SetTimerPeriod() sets the timer period in units of count. Timers begin counting down from the value set by this function until it reaches 0.
The function LPIT_GetCurrentTimerCount() reads the current timer counting value. This function returns the real-time timer counting value, in a range from 0 to a timer period.
The timer period operation functions takes the count value in ticks. User can call the utility macros provided in fsl_common.h to convert to microseconds or milliseconds
Start and Stop timer operations
The function LPIT_StartTimer() starts the timer counting. After calling this function, the timer loads the period value set earlier via the LPIT_SetPeriod() function and starts counting down to 0. When the timer reaches 0, it generates a trigger pulse and sets the timeout interrupt flag.
The function LPIT_StopTimer() stops the timer counting.
Status
Provides functions to get and clear the LPIT status.
Interrupt
Provides functions to enable/disable LPIT interrupts and get current enabled interrupts.
Typical use case
LPIT tick example
Updates the LPIT period and toggles an LED periodically. Refer to the driver examples codes located at <SDK_ROOT>/boards/<BOARD>/driver_examples/lpit
|
static void | LPIT_Reset (LPIT_Type *base) |
| Performs a software reset on the LPIT module. More...
|
|
|
enum | lpit_chnl_t {
kLPIT_Chnl_0 = 0U,
kLPIT_Chnl_1,
kLPIT_Chnl_2,
kLPIT_Chnl_3
} |
| List of LPIT channels. More...
|
|
enum | lpit_timer_modes_t {
kLPIT_PeriodicCounter = 0U,
kLPIT_DualPeriodicCounter,
kLPIT_TriggerAccumulator,
kLPIT_InputCapture
} |
| Mode options available for the LPIT timer. More...
|
|
enum | lpit_trigger_select_t {
kLPIT_Trigger_TimerChn0 = 0U,
kLPIT_Trigger_TimerChn1,
kLPIT_Trigger_TimerChn2,
kLPIT_Trigger_TimerChn3,
kLPIT_Trigger_TimerChn4,
kLPIT_Trigger_TimerChn5,
kLPIT_Trigger_TimerChn6,
kLPIT_Trigger_TimerChn7,
kLPIT_Trigger_TimerChn8,
kLPIT_Trigger_TimerChn9,
kLPIT_Trigger_TimerChn10,
kLPIT_Trigger_TimerChn11,
kLPIT_Trigger_TimerChn12,
kLPIT_Trigger_TimerChn13,
kLPIT_Trigger_TimerChn14,
kLPIT_Trigger_TimerChn15
} |
| Trigger options available. More...
|
|
enum | lpit_trigger_source_t {
kLPIT_TriggerSource_External = 0U,
kLPIT_TriggerSource_Internal
} |
| Trigger source options available. More...
|
|
enum | lpit_interrupt_enable_t {
kLPIT_Channel0TimerInterruptEnable = (1U << 0),
kLPIT_Channel1TimerInterruptEnable = (1U << 1),
kLPIT_Channel2TimerInterruptEnable = (1U << 2),
kLPIT_Channel3TimerInterruptEnable = (1U << 3)
} |
| List of LPIT interrupts. More...
|
|
enum | lpit_status_flags_t {
kLPIT_Channel0TimerFlag = (1U << 0),
kLPIT_Channel1TimerFlag = (1U << 1),
kLPIT_Channel2TimerFlag = (1U << 2),
kLPIT_Channel3TimerFlag = (1U << 3)
} |
| List of LPIT status flags. More...
|
|
#define | FSL_LPIT_DRIVER_VERSION (MAKE_VERSION(2, 0, 2)) |
| Version 2.0.2.
|
|
struct lpit_chnl_params_t |
This structure holds the configuration settings for the LPIT peripheral. To initialize this structure to reasonable defaults, call the LPIT_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 | enableRunInDebug |
| true: Timers run in debug mode; false: Timers stop in debug mode
|
|
bool | enableRunInDoze |
| true: Timers run in doze mode; false: Timers stop in doze mode
|
|
- Note
- Actual number of available channels is SoC-dependent
Enumerator |
---|
kLPIT_Chnl_0 |
LPIT channel number 0.
|
kLPIT_Chnl_1 |
LPIT channel number 1.
|
kLPIT_Chnl_2 |
LPIT channel number 2.
|
kLPIT_Chnl_3 |
LPIT channel number 3.
|
Enumerator |
---|
kLPIT_PeriodicCounter |
Use the all 32-bits, counter loads and decrements to zero.
|
kLPIT_DualPeriodicCounter |
Counter loads, lower 16-bits decrement to zero, then upper 16-bits decrement.
|
kLPIT_TriggerAccumulator |
Counter loads on first trigger and decrements on each trigger.
|
kLPIT_InputCapture |
Counter loads with 0xFFFFFFFF, decrements to zero.
It stores the inverse of the current value when a input trigger is detected
|
This is used for both internal and external trigger sources. The actual trigger options available is SoC-specific, user should refer to the reference manual.
Enumerator |
---|
kLPIT_Trigger_TimerChn0 |
Channel 0 is selected as a trigger source.
|
kLPIT_Trigger_TimerChn1 |
Channel 1 is selected as a trigger source.
|
kLPIT_Trigger_TimerChn2 |
Channel 2 is selected as a trigger source.
|
kLPIT_Trigger_TimerChn3 |
Channel 3 is selected as a trigger source.
|
kLPIT_Trigger_TimerChn4 |
Channel 4 is selected as a trigger source.
|
kLPIT_Trigger_TimerChn5 |
Channel 5 is selected as a trigger source.
|
kLPIT_Trigger_TimerChn6 |
Channel 6 is selected as a trigger source.
|
kLPIT_Trigger_TimerChn7 |
Channel 7 is selected as a trigger source.
|
kLPIT_Trigger_TimerChn8 |
Channel 8 is selected as a trigger source.
|
kLPIT_Trigger_TimerChn9 |
Channel 9 is selected as a trigger source.
|
kLPIT_Trigger_TimerChn10 |
Channel 10 is selected as a trigger source.
|
kLPIT_Trigger_TimerChn11 |
Channel 11 is selected as a trigger source.
|
kLPIT_Trigger_TimerChn12 |
Channel 12 is selected as a trigger source.
|
kLPIT_Trigger_TimerChn13 |
Channel 13 is selected as a trigger source.
|
kLPIT_Trigger_TimerChn14 |
Channel 14 is selected as a trigger source.
|
kLPIT_Trigger_TimerChn15 |
Channel 15 is selected as a trigger source.
|
Enumerator |
---|
kLPIT_TriggerSource_External |
Use external trigger input.
|
kLPIT_TriggerSource_Internal |
Use internal trigger.
|
- Note
- Number of timer channels are SoC-specific. See the SoC Reference Manual.
Enumerator |
---|
kLPIT_Channel0TimerInterruptEnable |
Channel 0 Timer interrupt.
|
kLPIT_Channel1TimerInterruptEnable |
Channel 1 Timer interrupt.
|
kLPIT_Channel2TimerInterruptEnable |
Channel 2 Timer interrupt.
|
kLPIT_Channel3TimerInterruptEnable |
Channel 3 Timer interrupt.
|
- Note
- Number of timer channels are SoC-specific. See the SoC Reference Manual.
Enumerator |
---|
kLPIT_Channel0TimerFlag |
Channel 0 Timer interrupt flag.
|
kLPIT_Channel1TimerFlag |
Channel 1 Timer interrupt flag.
|
kLPIT_Channel2TimerFlag |
Channel 2 Timer interrupt flag.
|
kLPIT_Channel3TimerFlag |
Channel 3 Timer interrupt flag.
|
void LPIT_Init |
( |
LPIT_Type * |
base, |
|
|
const lpit_config_t * |
config |
|
) |
| |
This function issues a software reset to reset all channels and registers except the Module Control register.
- Note
- This API should be called at the beginning of the application using the LPIT driver.
- Parameters
-
base | LPIT peripheral base address. |
config | Pointer to the user configuration structure. |
void LPIT_Deinit |
( |
LPIT_Type * |
base | ) |
|
- Parameters
-
base | LPIT peripheral base address. |
The default values are:
* config->enableRunInDebug = false;
* config->enableRunInDoze = false;
*
- Parameters
-
config | Pointer to the user configuration structure. |
This function sets up the operation mode to one of the options available in the enumeration lpit_timer_modes_t. It sets the trigger source as either internal or external, trigger selection and the timers behaviour when a timeout occurs. It also chains the timer if a prior timer if requested by the user.
- Parameters
-
base | LPIT peripheral base address. |
channel | Channel that is being configured. |
chnlSetup | Configuration parameters. |
static void LPIT_EnableInterrupts |
( |
LPIT_Type * |
base, |
|
|
uint32_t |
mask |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | LPIT peripheral base address. |
mask | The interrupts to enable. This is a logical OR of members of the enumeration lpit_interrupt_enable_t |
static void LPIT_DisableInterrupts |
( |
LPIT_Type * |
base, |
|
|
uint32_t |
mask |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | LPIT peripheral base address. |
mask | The interrupts to enable. This is a logical OR of members of the enumeration lpit_interrupt_enable_t |
static uint32_t LPIT_GetEnabledInterrupts |
( |
LPIT_Type * |
base | ) |
|
|
inlinestatic |
- Parameters
-
base | LPIT peripheral base address. |
- Returns
- The enabled interrupts. This is the logical OR of members of the enumeration lpit_interrupt_enable_t
static uint32_t LPIT_GetStatusFlags |
( |
LPIT_Type * |
base | ) |
|
|
inlinestatic |
- Parameters
-
base | LPIT peripheral base address. |
- Returns
- The status flags. This is the logical OR of members of the enumeration lpit_status_flags_t
static void LPIT_ClearStatusFlags |
( |
LPIT_Type * |
base, |
|
|
uint32_t |
mask |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | LPIT peripheral base address. |
mask | The status flags to clear. This is a logical OR of members of the enumeration lpit_status_flags_t |
static void LPIT_SetTimerPeriod |
( |
LPIT_Type * |
base, |
|
|
lpit_chnl_t |
channel, |
|
|
uint32_t |
ticks |
|
) |
| |
|
inlinestatic |
Timers begin counting down from the value set by this function until it reaches 0, at which point it generates an interrupt and loads this register value again. Writing a new value to this register does not restart the timer. Instead, the value is loaded after the timer expires.
- Note
- User can call the utility macros provided in fsl_common.h to convert to ticks.
- Parameters
-
base | LPIT peripheral base address. |
channel | Timer channel number. |
ticks | Timer period in units of ticks. |
static uint32_t LPIT_GetCurrentTimerCount |
( |
LPIT_Type * |
base, |
|
|
lpit_chnl_t |
channel |
|
) |
| |
|
inlinestatic |
This function returns the real-time timer counting value, in a range from 0 to a timer period.
- Note
- User can call the utility macros provided in fsl_common.h to convert ticks to microseconds or milliseconds.
- Parameters
-
base | LPIT peripheral base address. |
channel | Timer channel number. |
- Returns
- Current timer counting value in ticks.
static void LPIT_StartTimer |
( |
LPIT_Type * |
base, |
|
|
lpit_chnl_t |
channel |
|
) |
| |
|
inlinestatic |
After calling this function, timers load the period value and count down to 0. When the timer reaches 0, it generates a trigger pulse and sets the timeout interrupt flag.
- Parameters
-
base | LPIT peripheral base address. |
channel | Timer channel number. |
static void LPIT_StopTimer |
( |
LPIT_Type * |
base, |
|
|
lpit_chnl_t |
channel |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | LPIT peripheral base address. |
channel | Timer channel number. |
static void LPIT_Reset |
( |
LPIT_Type * |
base | ) |
|
|
inlinestatic |
This resets all channels and registers except the Module Control Register.
- Parameters
-
base | LPIT peripheral base address. |