12#include "fsl_common.h"
25#define FSL_GPT_DRIVER_VERSION (MAKE_VERSION(2, 0, 4))
116#if defined(__cplusplus)
168static inline void GPT_SoftwareReset(
GPT_Type *base)
170 base->CR |= GPT_CR_SWR_MASK;
172 while ((base->CR & GPT_CR_SWR_MASK) == GPT_CR_SWR_MASK)
192 base->CR = (base->CR & ~GPT_CR_CLKSRC_MASK) | GPT_CR_EN_24M_MASK |
GPT_CR_CLKSRC(gptClkSource);
196 base->CR = (base->CR & ~(GPT_CR_CLKSRC_MASK | GPT_CR_EN_24M_MASK)) |
GPT_CR_CLKSRC(gptClkSource);
208 return (
gpt_clock_source_t)(uint8_t)((base->CR & GPT_CR_CLKSRC_MASK) >> GPT_CR_CLKSRC_SHIFT);
217static inline void GPT_SetClockDivider(
GPT_Type *base, uint32_t divider)
219 assert(divider - 1U <= GPT_PR_PRESCALER_MASK);
221 base->PR = (base->PR & ~GPT_PR_PRESCALER_MASK) |
GPT_PR_PRESCALER(divider - 1U);
230static inline uint32_t GPT_GetClockDivider(
GPT_Type *base)
232 return ((base->PR & GPT_PR_PRESCALER_MASK) >> GPT_PR_PRESCALER_SHIFT) + 1U;
241static inline void GPT_SetOscClockDivider(
GPT_Type *base, uint32_t divider)
243 assert(divider - 1U <= (GPT_PR_PRESCALER24M_MASK >> GPT_PR_PRESCALER24M_SHIFT));
254static inline uint32_t GPT_GetOscClockDivider(
GPT_Type *base)
256 return ((base->PR & GPT_PR_PRESCALER24M_MASK) >> GPT_PR_PRESCALER24M_SHIFT) + 1U;
270static inline void GPT_StartTimer(
GPT_Type *base)
272 base->CR |= GPT_CR_EN_MASK;
280static inline void GPT_StopTimer(
GPT_Type *base)
282 base->CR &= ~GPT_CR_EN_MASK;
296static inline uint32_t GPT_GetCurrentTimerCount(
GPT_Type *base)
315static inline void GPT_SetInputOperationMode(
GPT_Type *base,
322 (base->CR & ~(GPT_CR_IM1_MASK << ((uint32_t)channel * 2UL))) | (GPT_CR_IM1(mode) << ((uint32_t)channel * 2UL));
337 (GPT_CR_IM1_MASK >> GPT_CR_IM1_SHIFT));
351 return base->ICR[(uint32_t)channel];
361static inline void GPT_SetOutputOperationMode(
GPT_Type *base,
368 (base->CR & ~(GPT_CR_OM1_MASK << ((uint32_t)channel * 3UL))) | (GPT_CR_OM1(mode) << ((uint32_t)channel * 3UL));
384 (GPT_CR_OM1_MASK >> GPT_CR_OM1_SHIFT));
398 base->OCR[(uint32_t)channel] = value;
412 return base->OCR[(uint32_t)channel];
425 base->CR |= (GPT_CR_FO1_MASK << (uint32_t)channel);
442static inline void GPT_EnableInterrupts(
GPT_Type *base, uint32_t mask)
454static inline void GPT_DisableInterrupts(
GPT_Type *base, uint32_t mask)
467static inline uint32_t GPT_GetEnabledInterrupts(
GPT_Type *base)
469 return (base->IR & (GPT_IR_OF1IE_MASK | GPT_IR_OF2IE_MASK | GPT_IR_OF3IE_MASK | GPT_IR_IF1IE_MASK |
470 GPT_IR_IF2IE_MASK | GPT_IR_ROVIE_MASK));
487 return base->SR & (uint32_t)flags;
498 base->SR = (uint32_t)flags;
503#if defined(__cplusplus)
#define GPT_PR_PRESCALER(x)
Definition: MIMXRT1052.h:23137
#define GPT_PR_PRESCALER24M(x)
Definition: MIMXRT1052.h:23146
#define GPT_CR_CLKSRC(x)
Definition: MIMXRT1052.h:23051
void GPT_GetDefaultConfig(gpt_config_t *config)
Fills in the GPT configuration structure with default settings.
Definition: fsl_gpt.c:112
enum _gpt_interrupt_enable gpt_interrupt_enable_t
List of GPT interrupts.
_gpt_output_operation_mode
List of output compare operation mode.
Definition: fsl_gpt.h:68
enum _gpt_clock_source gpt_clock_source_t
List of clock sources.
_gpt_interrupt_enable
List of GPT interrupts.
Definition: fsl_gpt.h:78
bool enableRunInWait
Definition: fsl_gpt.h:104
enum _gpt_input_capture_channel gpt_input_capture_channel_t
List of input capture channel number.
void GPT_Init(GPT_Type *base, const gpt_config_t *initConfig)
Initialize GPT to reset state and initialize running mode.
Definition: fsl_gpt.c:58
enum _gpt_input_operation_mode gpt_input_operation_mode_t
List of input capture operation mode.
void GPT_Deinit(GPT_Type *base)
Disables the module and gates the GPT clock.
Definition: fsl_gpt.c:85
bool enableRunInDoze
Definition: fsl_gpt.h:106
gpt_clock_source_t clockSource
Definition: fsl_gpt.h:101
_gpt_input_capture_channel
List of input capture channel number.
Definition: fsl_gpt.h:44
_gpt_clock_source
List of clock sources.
Definition: fsl_gpt.h:33
_gpt_status_flag
Status flag.
Definition: fsl_gpt.h:89
bool enableMode
Definition: fsl_gpt.h:108
bool enableRunInStop
Definition: fsl_gpt.h:105
enum _gpt_status_flag gpt_status_flag_t
Status flag.
enum _gpt_output_compare_channel gpt_output_compare_channel_t
List of output compare channel number.
enum _gpt_output_operation_mode gpt_output_operation_mode_t
List of output compare operation mode.
struct _gpt_init_config gpt_config_t
Structure to configure the running mode.
_gpt_input_operation_mode
List of input capture operation mode.
Definition: fsl_gpt.h:51
uint32_t divider
Definition: fsl_gpt.h:102
_gpt_output_compare_channel
List of output compare channel number.
Definition: fsl_gpt.h:60
bool enableFreeRun
Definition: fsl_gpt.h:103
bool enableRunInDbg
Definition: fsl_gpt.h:107
@ kGPT_OutputOperation_Activelow
Definition: fsl_gpt.h:73
@ kGPT_OutputOperation_Set
Definition: fsl_gpt.h:72
@ kGPT_OutputOperation_Clear
Definition: fsl_gpt.h:71
@ kGPT_OutputOperation_Toggle
Definition: fsl_gpt.h:70
@ kGPT_OutputOperation_Disconnected
Definition: fsl_gpt.h:69
@ kGPT_InputCapture1InterruptEnable
Definition: fsl_gpt.h:82
@ kGPT_RollOverFlagInterruptEnable
Definition: fsl_gpt.h:84
@ kGPT_OutputCompare2InterruptEnable
Definition: fsl_gpt.h:80
@ kGPT_OutputCompare3InterruptEnable
Definition: fsl_gpt.h:81
@ kGPT_OutputCompare1InterruptEnable
Definition: fsl_gpt.h:79
@ kGPT_InputCapture2InterruptEnable
Definition: fsl_gpt.h:83
@ kGPT_InputCapture_Channel1
Definition: fsl_gpt.h:45
@ kGPT_InputCapture_Channel2
Definition: fsl_gpt.h:46
@ kGPT_ClockSource_HighFreq
Definition: fsl_gpt.h:36
@ kGPT_ClockSource_Off
Definition: fsl_gpt.h:34
@ kGPT_ClockSource_Periph
Definition: fsl_gpt.h:35
@ kGPT_ClockSource_Osc
Definition: fsl_gpt.h:39
@ kGPT_ClockSource_Ext
Definition: fsl_gpt.h:37
@ kGPT_ClockSource_LowFreq
Definition: fsl_gpt.h:38
@ kGPT_OutputCompare1Flag
Definition: fsl_gpt.h:90
@ kGPT_InputCapture2Flag
Definition: fsl_gpt.h:94
@ kGPT_OutputCompare2Flag
Definition: fsl_gpt.h:91
@ kGPT_OutputCompare3Flag
Definition: fsl_gpt.h:92
@ kGPT_RollOverFlag
Definition: fsl_gpt.h:95
@ kGPT_InputCapture1Flag
Definition: fsl_gpt.h:93
@ kGPT_InputOperation_RiseEdge
Definition: fsl_gpt.h:53
@ kGPT_InputOperation_BothEdge
Definition: fsl_gpt.h:55
@ kGPT_InputOperation_FallEdge
Definition: fsl_gpt.h:54
@ kGPT_InputOperation_Disabled
Definition: fsl_gpt.h:52
@ kGPT_OutputCompare_Channel2
Definition: fsl_gpt.h:62
@ kGPT_OutputCompare_Channel3
Definition: fsl_gpt.h:63
@ kGPT_OutputCompare_Channel1
Definition: fsl_gpt.h:61
Definition: MIMXRT1052.h:22971
Structure to configure the running mode.
Definition: fsl_gpt.h:100
Definition: deflate.c:114