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. The timers count from 0 to the count value set here. The function RIT_SetMaskBit() sets some bit which is 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_SetCountAutoClear() set the Timer clear enable/disable.
The function RIT_StopTimer() stops the timer counting./* resets the timer's counter register.
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::enableRunInDebug |
; false: Debug has no effect on the timer operation.
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
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 |
|
) |
| |
This function sets the RI compare value. If the counter value equals to the compare value, it will generate an interrupt.
- 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 |
|
) |
| |
This function sets the RI mask value. A 1 written to any bit will force the compare to be true for the corresponding bit of the counter and compare register (causes the comparison of the register bits to be always true).
- 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 | ) |
|
- 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 RI compare value
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 | ) |
|
- 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 RI mask value
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.
- 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 |
static void RIT_ClearCounter |
( |
RIT_Type * |
base, |
|
|
bool |
enable |
|
) |
| |
|
inlinestatic |
This function set the counter auto clear or not whenever the counter value equals the masked compare value specified by the contents of COMPVAL/COMPVAL_H and MASK/MASK_H registers..
- Deprecated:
- Do not use this function. It has been superceded by RIT_SetCountAutoClear.
static void RIT_SetCountAutoClear |
( |
RIT_Type * |
base, |
|
|
bool |
enable |
|
) |
| |
|
inlinestatic |
This function set the counter auto clear or not whenever the counter value equals the masked compare value specified by the contents of COMPVAL/COMPVAL_H and MASK/MASK_H registers..
- Parameters
-
base | RIT peripheral base address |
enable | Enable/disable Counter auto clear when value equals the compare value.
- true: Enable Counter auto clear.
- false: Disable Counter auto clear.
|