The MCUXpresso SDK provides a peripheral driver for the General purpose timer(GPT) module of MCUXpresso SDK devices. The GPT module contains 4 timers, timer0/1/2/3, each timer support free running mode and one-shot mode.
|
| enum | gpt_timer_id_t {
kGPT_Timer0 = 0U,
kGPT_Timer1 = 1U,
kGPT_Timer2 = 2U,
kGPT_Timer3 = 3U,
kGPT_TimerInvalid = 0xFFU
} |
| | gpt timer id More...
|
| |
| enum | gpt_timer_mode_t {
kGPT_TimerModeSingleShot = 0U,
kGPT_TimerModeSingleFreeRunning = 1U
} |
| | gpt timer mode More...
|
| |
| enum | gpt_counter_resolution_t {
kGPT_CounterResolutionInvalid = 0U,
kGPT_CounterResolution1us = 1U,
kGPT_CounterResolution2us = 2U,
kGPT_CounterResolution3us = 3U,
kGPT_CounterResolution4us = 4U,
kGPT_CounterResolution5us = 5U,
kGPT_CounterResolutionMax = 6U
} |
| | GPT counter resolution. More...
|
| |
|
| static void | GPT_SetPrescalerFactor (TIMERS_Type *base, uint8_t prescalerFactor) |
| | GPT prescaler factor configuration. More...
|
| |
| static uint8_t | GPT_GetPrescalerFactor (TIMERS_Type *base) |
| | GPT get prescaler factor configuration. More...
|
| |
| void | GPT_StartTimer (TIMERS_Type *base, gpt_timer_id_t timer, uint32_t timeoutCount) |
| | Timer start specific timer. More...
|
| |
| void | GPT_StopTimer (TIMERS_Type *base, gpt_timer_id_t timer) |
| | Timer stop specific timers. More...
|
| |
| static void | GPT_SetTimerMode (TIMERS_Type *base, gpt_timer_id_t timer, gpt_timer_mode_t mode) |
| | Timer set timers mode. More...
|
| |
| static void | GPT_EnableTimeoutStatus (TIMERS_Type *base, gpt_timer_id_t timer) |
| | Timer timeout status enable/disable. More...
|
| |
| static void | GPT_ClearTimeoutStatus (TIMERS_Type *base, gpt_timer_id_t timer) |
| | Timer clear timeout status. More...
|
| |
| static bool | GPT_GetTimeoutStatus (TIMERS_Type *base, gpt_timer_id_t timer) |
| | Timer timeout status enable/disable. More...
|
| |
| static void | GPT_EnableTimeoutInterrupt (TIMERS_Type *base, gpt_timer_id_t timer, bool enable) |
| | Timer timeout interrupt enable/disable. More...
|
| |
| static uint32_t | GPT_GetRemainCount (TIMERS_Type *base, gpt_timer_id_t timer) |
| | Timer get timers remain count. More...
|
| |
| struct gpt_timer_config_t |
Data Fields |
| uint8_t | prescalerFactor |
| | The prescalerFactor will count at system frequency and generates a tick signal used by the different timers to decrement their counter. More...
|
| |
| uint8_t gpt_timer_config_t::prescalerFactor |
As soon as a non-zero value is loaded into field PRESCALING_VALUE of the TIMERS_PRESCALER_REG, the prescaler will decrement a counter at every clock cycle, starting from the prescalerFactor. Once the counter reaches zero, it generates a one cycle tick signal which will be used by the timers to decrement their TIMERS_[TIMER]_COUNT_REG. It will then start again counting from the prescalerFactor. The prescaler will stop counting if prescalerFactor is set to 0
| uint32_t gpt_handle_t::timerPeriod |
| void* gpt_handle_t::cbParam |
| bool gpt_handle_t::enableInterrupt |
| #define FSL_GPT_DRIVER_VERSION (MAKE_VERSION(2, 1, 0)) |
| typedef void(* gpt_timer_callback_t)(void *param) |
| Enumerator |
|---|
| kGPT_Timer0 |
timer 0
|
| kGPT_Timer1 |
timer 1
|
| kGPT_Timer2 |
timer 2
|
| kGPT_Timer3 |
timer 3
|
| kGPT_TimerInvalid |
Invalid timer.
|
| Enumerator |
|---|
| kGPT_TimerModeSingleShot |
Single shot mode.
|
| kGPT_TimerModeSingleFreeRunning |
Free running mode.
|
| Enumerator |
|---|
| kGPT_CounterResolutionInvalid |
Invalid parameter.
|
| kGPT_CounterResolution1us |
Prescalar corresponding to 1us resolution.
|
| kGPT_CounterResolution2us |
Prescalar corresponding to 2us resolution.
|
| kGPT_CounterResolution3us |
Prescalar corresponding to 3us resolution.
|
| kGPT_CounterResolution4us |
Prescalar corresponding to 4us resolution.
|
| kGPT_CounterResolution5us |
Prescalar corresponding to 5us resolution.
|
| kGPT_CounterResolutionMax |
Invalid parameter.
|
- Parameters
-
| base | timer base pointer. |
| config | timer configuration pointer |
| void GPT_Deinit |
( |
TIMERS_Type * |
base | ) |
|
| static void GPT_SetPrescalerFactor |
( |
TIMERS_Type * |
base, |
|
|
uint8_t |
prescalerFactor |
|
) |
| |
|
inlinestatic |
The prescalerFactor will count at system frequency and generates a tick signal used by the different timers to decrement their counter. As soon as a non-zero value is loaded into field PRESCALING_VALUE of the TIMERS_PRESCALER_REG, the prescaler will decrement a counter at every clock cycle, starting from the prescalerFactor. Once the counter reaches zero, it generates a one cycle tick signal which will be used by the timers to decrement their TIMERS_[TIMERx|WDG]_COUNT_REG. It will then start again counting from the prescalerFactor. The prescaler will stop counting if prescalerFactor is set to 0
- Parameters
-
| base | timer base pointer. |
| prescalerFactor | The prescaler factor value. |
| static uint8_t GPT_GetPrescalerFactor |
( |
TIMERS_Type * |
base | ) |
|
|
inlinestatic |
| void GPT_StartTimer |
( |
TIMERS_Type * |
base, |
|
|
gpt_timer_id_t |
timer, |
|
|
uint32_t |
timeoutCount |
|
) |
| |
- Parameters
-
| base | timer base pointer. |
| timer | the specific timer to be start. |
| timeoutCount | the initial timeout count of the timer. The total timeout time is determined by (1 / timerCountingFreq_Hz) * timeoutCount. |
- Parameters
-
| base | timer base pointer. |
| timer | the specific timer to be stop. |
- Parameters
-
| base | timer base pointer. |
| timer | the specific timer to be configured. |
| mode | timers mode. |
| static void GPT_EnableTimeoutStatus |
( |
TIMERS_Type * |
base, |
|
|
gpt_timer_id_t |
timer |
|
) |
| |
|
inlinestatic |
- Parameters
-
| base | timer base pointer. |
| timer | the specific timer to be stop. |
| static void GPT_ClearTimeoutStatus |
( |
TIMERS_Type * |
base, |
|
|
gpt_timer_id_t |
timer |
|
) |
| |
|
inlinestatic |
- Parameters
-
| base | timer base pointer. |
| timer | the specific timer to be stop. |
| static bool GPT_GetTimeoutStatus |
( |
TIMERS_Type * |
base, |
|
|
gpt_timer_id_t |
timer |
|
) |
| |
|
inlinestatic |
- Parameters
-
| base | timer base pointer. |
| timer | the specific timer to be stop. |
- Return values
-
| true | is the timer timeout, false is the timeout still not timeout. |
| static void GPT_EnableTimeoutInterrupt |
( |
TIMERS_Type * |
base, |
|
|
gpt_timer_id_t |
timer, |
|
|
bool |
enable |
|
) |
| |
|
inlinestatic |
- Parameters
-
| base | timer base pointer. |
| timer | the specific timer to be stop. |
| static uint32_t GPT_GetRemainCount |
( |
TIMERS_Type * |
base, |
|
|
gpt_timer_id_t |
timer |
|
) |
| |
|
inlinestatic |
- Parameters
-
| base | timer base pointer. |
| timer | the specific timer id. |
| void GPT_MGR_Init |
( |
void |
| ) |
|
Initializes the GPT registers and driver internal state.
| void GPT_MGR_Deinit |
( |
void |
| ) |
|
Deinitialize the GPT registers and driver internal state.
- Parameters
-
| handle | The handle for the timer channel. |
- Return values
-
| kStatus_Success | Requested successfully. |
| kStatus_Busy | Request failed because all channels are busy. |
After configuration, call GPT_MGR_Start to start the time channel.
- Parameters
-
| handle | The handle for the timer channel. |
| enableInterrupt | Pass true to use interrupt mode, pass false to use polling mode. |
| requestTime | Timer period in microsecond. |
| callback | Callback function when timer hit, only used in interrupt mode. |
| cbParam | Parameter of the callback function. |
- Return values
-
| kStatus_Success | Configured successfully. |
| kStatus_InvalidArgument | Failed because of invalid argument. |
- Parameters
-
| handle | The handle for the timer channel. |
- Return values
-
| kStatus_Success | Configured successfully. |
| kStatus_InvalidArgument | Failed because of invalid argument. |
If the channel works in interrupt mode, this function disables the channel interrupt too.
- Parameters
-
| handle | The handle for the timer channel. |
- Return values
-
| kStatus_Success | Configured successfully. |
| kStatus_InvalidArgument | Failed because of invalid argument. |
- Parameters
-
| handle | The handle for the timer channel. |
- Return values
-
| kStatus_Success | Configured successfully. |
| kStatus_InvalidArgument | Failed because of invalid argument. |
- Parameters
-
| handle | The handle for the timer channel. |
- Return values
-
| kStatus_Success | Configured successfully. |
| kStatus_InvalidArgument | Failed because of invalid argument. |
- Parameters
-
| handle | The handle for the timer channel. |
- Return values
-
| kStatus_Success | Configured successfully. |
| kStatus_InvalidArgument | Failed because of invalid argument. |
- Parameters
-
| handle | The handle for the timer channel. |
- Return values
-
| kStatus_Success | Timer expired. |
| kStatus_Busy | Timer is still running. |
| kStatus_InvalidArgument | Failed because of invalid argument. |
- Parameters
-
| handle | The handle for the timer channel. |
- Returns
- Return true if the channel is free, otherwise returns false.
- Parameters
-
| resolution | The new resolution to set. |
- Return values
-
| kStatus_Success | Configured successfully. |
| kStatus_Busy | Could not change the resolution because some channels are running. |
| kStatus_InvalidArgument | Failed because of invalid argument. |
- Returns
- Current resolution.