The MCUXpresso SDK provides a driver for the Repetitive Interrupt Timer (RIT) of MCUXpresso SDK devices.
Function groups
The RIT driver supports operating the module as a time counter.
Initialization and deinitialization
The function RIT_Init() initializes the RIT with specified configurations. The function RIT_GetDefaultConfig() gets the default configurations. The initialization function configures the RIT operation normally in debug mode.
The function RIT_Deinit() disables the RIT timers and disables the module clock.
Timer read and write Operations
The function RIT_SetTimerCompare() sets the timer period in units of count. Timers counts from 0 to the count value set here. The function RIT_SetMaskBit() sets some bit which will be ignored in comparison between the compare and counter register.
The function RIT_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 RIT_StartTimer() starts the timer counting. After calling this function, the timer counts up to the counter value set earlier by using the RIT_SetTimerCompare() function. Each time the timer reaches the count value, it generates a trigger pulse and sets the interrupt flag and set the counter to zero/continue counting when RIT_ClearCounter() set the Timer clear enable/disable.
The function RIT_StopTimer() stops the timer counting.// resets the timer's counter register.
clear the count operations
The function RIT_ClearCounter() set the cuonter register to continue counting or clear the counter to zero when the the counter value equals the masked compare value specified by the contents of COMPVAL/COMPVAL_H and MASK/MASK_H registers.
Status
Provides functions to get and clear the RIT status.
Typical use case
RIT tick example
Refer to the driver examples codes located at <SDK_ROOT>/boards/<BOARD>/driver_examples/rit
This structure holds the configuration settings for the RIT peripheral. To initialize this structure to reasonable defaults, call the RIT_GetDefaultConfig() function and pass a pointer to your config structure instance.
The config struct can be made const so it resides in flash
bool rit_config_t::enableRunInDebug |
; false: Debug has no effect on the timer operation.
Enumerator |
---|
kRIT_TimerFlag |
Timer flag.
|
void RIT_Init |
( |
RIT_Type * |
base, |
|
|
const rit_config_t * |
config |
|
) |
| |
- Note
- This API should be called at the beginning of the application using the RIT driver.
- Parameters
-
base | RIT peripheral base address |
config | Pointer to the user's RIT config structure |
void RIT_Deinit |
( |
RIT_Type * |
base | ) |
|
- Parameters
-
base | RIT peripheral base address |
The default values are as follows.
* config->enableRunInDebug = false;
*
- Parameters
-
config | Pointer to the onfiguration structure. |
static uint32_t RIT_GetStatusFlags |
( |
RIT_Type * |
base | ) |
|
|
inlinestatic |
- Parameters
-
base | RIT peripheral base address |
- Returns
- The status flags. This is the logical OR of members of the enumeration rit_status_flags_t
static void RIT_ClearStatusFlags |
( |
RIT_Type * |
base, |
|
|
uint32_t |
mask |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | RIT peripheral base address |
mask | The status flags to clear. This is a logical OR of members of the enumeration rit_status_flags_t |
void RIT_SetTimerCompare |
( |
RIT_Type * |
base, |
|
|
uint64_t |
count |
|
) |
| |
Timers begin counting from the value set by this function until it XXXXXXX, then it counting the value again. Software must stop the counter before reloading it with a new value..
- Note
- Users can call the utility macros provided in fsl_common.h to convert to ticks
- Parameters
-
base | RIT peripheral base address |
count | Timer period in units of ticks |
void RIT_SetMaskBit |
( |
RIT_Type * |
base, |
|
|
uint64_t |
count |
|
) |
| |
Timers begin counting from the value set by this function until it XXXXXXX, then it counting the value again. Software must stop the counter before reloading it with a new value..
- Note
- Users can call the utility macros provided in fsl_common.h to convert to ticks
- Parameters
-
base | RIT peripheral base address |
count | Timer period in units of ticks |
uint64_t RIT_GetCompareTimerCount |
( |
RIT_Type * |
base | ) |
|
This function returns the real-time timer counting value, in a range from 0 to a timer period.
- Note
- Users can call the utility macros provided in fsl_common.h to convert ticks to usec or msec
- Parameters
-
base | RIT peripheral base address |
- Returns
- Current timer counting value in ticks
uint64_t RIT_GetCounterTimerCount |
( |
RIT_Type * |
base | ) |
|
This function returns the real-time timer counting value, in a range from 0 to a timer period.
- Note
- Users can call the utility macros provided in fsl_common.h to convert ticks to usec or msec
- Parameters
-
base | RIT peripheral base address |
- Returns
- Current timer counting value in ticks
uint64_t RIT_GetMaskTimerCount |
( |
RIT_Type * |
base | ) |
|
This function returns the real-time timer counting value, in a range from 0 to a timer period.
- Note
- Users can call the utility macros provided in fsl_common.h to convert ticks to usec or msec
- Parameters
-
base | RIT peripheral base address |
- Returns
- Current timer counting value in ticks
static void RIT_StartTimer |
( |
RIT_Type * |
base | ) |
|
|
inlinestatic |
After calling this function, timers load initial value(0U), count up to desired value or over-flow then the counter will count up again. Each time a timer reaches desired value, it generates a XXXXXXX and sets XXXXXXX.
- Parameters
-
base | RIT peripheral base address |
static void RIT_StopTimer |
( |
RIT_Type * |
base | ) |
|
|
inlinestatic |
This function stop timer counting. Timer reload their new value after the next time they call the RIT_StartTimer.
- Parameters
-
base | RIT peripheral base address |
channel | Timer channel number. |