NetBurner 3.5.6
PDF Version
fsl_qtmr.h
1/*
2 * Copyright 2017-2022 NXP
3 * All rights reserved.
4 *
5 * SPDX-License-Identifier: BSD-3-Clause
6 */
7#ifndef FSL_QTMR_H_
8#define FSL_QTMR_H_
9
10#include "fsl_common.h"
11
26/*******************************************************************************
27 * Definitions
28 ******************************************************************************/
29#ifndef TMR_CSCTRL_OFLAG_MASK
30#define TMR_CSCTRL_OFLAG_MASK (0x100UL)
31#endif
32
33#ifndef TMR_CSCTRL_OFLAG_SHIFT
34#define TMR_CSCTRL_OFLAG_SHIFT (8UL)
35#endif
36
39#define FSL_QTMR_DRIVER_VERSION (MAKE_VERSION(2, 2, 2))
62
71
84
91
104
113
121
130
132// typedef enum _qtmr_interrupt_enable
141
151
160
168
190
191/*******************************************************************************
192 * API
193 ******************************************************************************/
194
195#if defined(__cplusplus)
196extern "C" {
197#endif
198
213void QTMR_Init(TMR_Type *base, qtmr_channel_selection_t channel, const qtmr_config_t *config);
214
221void QTMR_Deinit(TMR_Type *base, qtmr_channel_selection_t channel);
222
239
259status_t QTMR_SetupPwm(TMR_Type *base,
261 uint32_t pwmFreqHz,
262 uint8_t dutyCyclePercent,
263 bool outputPolarity,
264 uint32_t srcClock_Hz);
265
278void QTMR_SetupInputCapture(TMR_Type *base,
280 qtmr_input_source_t capturePin,
281 bool inputPolarity,
282 bool reloadOnCapture,
283 qtmr_input_capture_edge_t captureMode);
284
298void QTMR_EnableInterrupts(TMR_Type *base, qtmr_channel_selection_t channel, uint32_t mask);
299
308void QTMR_DisableInterrupts(TMR_Type *base, qtmr_channel_selection_t channel, uint32_t mask);
309
319uint32_t QTMR_GetEnabledInterrupts(TMR_Type *base, qtmr_channel_selection_t channel);
320
337uint32_t QTMR_GetStatus(TMR_Type *base, qtmr_channel_selection_t channel);
338
347void QTMR_ClearStatusFlags(TMR_Type *base, qtmr_channel_selection_t channel, uint32_t mask);
348
372void QTMR_SetTimerPeriod(TMR_Type *base, qtmr_channel_selection_t channel, uint16_t ticks);
373
383void QTMR_SetCompareValue(TMR_Type *base, qtmr_channel_selection_t channel, uint16_t ticks);
384
394static inline void QTMR_SetLoadValue(TMR_Type *base, qtmr_channel_selection_t channel, uint16_t value)
395{
396 base->CHANNEL[channel].LOAD &= (uint16_t)(~TMR_LOAD_LOAD_MASK);
397 base->CHANNEL[channel].LOAD = value;
398}
399
413static inline uint16_t QTMR_GetCurrentTimerCount(TMR_Type *base, qtmr_channel_selection_t channel)
414{
415 return base->CHANNEL[channel].CNTR;
416}
417
433static inline void QTMR_StartTimer(TMR_Type *base, qtmr_channel_selection_t channel, qtmr_counting_mode_t clockSource)
434{
435 uint16_t reg = base->CHANNEL[channel].CTRL;
436
437 reg &= (uint16_t)(~(TMR_CTRL_CM_MASK));
438 reg |= TMR_CTRL_CM(clockSource);
439 base->CHANNEL[channel].CTRL = reg;
440}
441
448static inline void QTMR_StopTimer(TMR_Type *base, qtmr_channel_selection_t channel)
449{
450 base->CHANNEL[channel].CTRL &= (uint16_t)(~TMR_CTRL_CM_MASK);
451}
452
468void QTMR_EnableDma(TMR_Type *base, qtmr_channel_selection_t channel, uint32_t mask);
469
478void QTMR_DisableDma(TMR_Type *base, qtmr_channel_selection_t channel, uint32_t mask);
479
489void QTMR_SetPwmOutputToIdle(TMR_Type *base, qtmr_channel_selection_t channel, bool idleStatus);
490
499static inline qtmr_pwm_out_state_t QTMR_GetPwmOutputStatus(TMR_Type *base, qtmr_channel_selection_t channel)
500{
501 if (0U != ((base->CHANNEL[channel].CSCTRL) & TMR_CSCTRL_OFLAG_MASK))
502 {
503 return kQTMR_PwmHigh;
504 }
505 else
506 {
507 return kQTMR_PwmLow;
508 }
509}
510
519uint8_t QTMR_GetPwmChannelStatus(TMR_Type *base, qtmr_channel_selection_t channel);
520
528void QTMR_SetPwmClockMode(TMR_Type *base, qtmr_channel_selection_t channel, qtmr_primary_count_source_t prescaler);
529
532#if defined(__cplusplus)
533}
534#endif
535
536 // groupPlatformRT1061-QTMR
537
538#endif /* FSL_QTMR_H_ */
void QTMR_DisableDma(TMR_Type *base, qtmr_channel_selection_t channel, uint32_t mask)
Disable the Quad Timer DMA.
Definition fsl_qtmr.c:642
enum _qtmr_output_mode qtmr_output_mode_t
Quad Timer output mode selection.
void QTMR_SetTimerPeriod(TMR_Type *base, qtmr_channel_selection_t channel, uint16_t ticks)
Sets the timer period in ticks.
Definition fsl_qtmr.c:556
void QTMR_SetPwmClockMode(TMR_Type *base, qtmr_channel_selection_t channel, qtmr_primary_count_source_t prescaler)
This function set the value of the prescaler on QTimer channels.
Definition fsl_qtmr.c:718
enum _qtmr_channel_selection qtmr_channel_selection_t
List of channel selection.
status_t QTMR_SetupPwm(TMR_Type *base, qtmr_channel_selection_t channel, uint32_t pwmFreqHz, uint8_t dutyCyclePercent, bool outputPolarity, uint32_t srcClock_Hz)
Sets up Quad timer module for PWM signal output.
Definition fsl_qtmr.c:169
_qtmr_counting_mode
Quad Timer counting mode selection.
Definition fsl_qtmr.h:74
enum _qtmr_primary_count_source qtmr_primary_count_source_t
Quad Timer primary clock source selection.
void QTMR_EnableInterrupts(TMR_Type *base, qtmr_channel_selection_t channel, uint32_t mask)
Enables the selected Quad Timer interrupts.
Definition fsl_qtmr.c:320
enum _qtmr_status_flags qtmr_status_flags_t
List of Quad Timer flags.
_qtmr_debug_action
List of Quad Timer run options when in Debug mode.
Definition fsl_qtmr.h:124
enum _qtmr_dma_enable qtmr_dma_enable_t
List of Quad Timer DMA enable.
_qtmr_channel_selection
List of channel selection.
Definition fsl_qtmr.h:154
enum _qtmr_input_capture_edge qtmr_input_capture_edge_t
Quad Timer input capture edge mode, rising edge, or falling edge.
_qtmr_preload_control
Quad Timer input capture edge mode, rising edge, or falling edge.
Definition fsl_qtmr.h:116
void QTMR_SetPwmOutputToIdle(TMR_Type *base, qtmr_channel_selection_t channel, bool idleStatus)
Set PWM output in idle status (high or low).
Definition fsl_qtmr.c:674
enum _qtmr_debug_action qtmr_debug_action_t
List of Quad Timer run options when in Debug mode.
void QTMR_GetDefaultConfig(qtmr_config_t *config)
Fill in the Quad Timer config struct with the default settings.
Definition fsl_qtmr.c:129
void QTMR_DisableInterrupts(TMR_Type *base, qtmr_channel_selection_t channel, uint32_t mask)
Disables the selected Quad Timer interrupts.
Definition fsl_qtmr.c:366
void QTMR_EnableDma(TMR_Type *base, qtmr_channel_selection_t channel, uint32_t mask)
Enable the Quad Timer DMA.
Definition fsl_qtmr.c:609
_qtmr_pwm_out_state
Quad Timer PWM output state.
Definition fsl_qtmr.h:87
_qtmr_input_capture_edge
Quad Timer input capture edge mode, rising edge, or falling edge.
Definition fsl_qtmr.h:107
uint32_t QTMR_GetStatus(TMR_Type *base, qtmr_channel_selection_t channel)
Gets the Quad Timer status flags.
Definition fsl_qtmr.c:457
enum _qtmr_counting_mode qtmr_counting_mode_t
Quad Timer counting mode selection.
enum _qtmr_input_source qtmr_input_source_t
Quad Timer input sources selection.
_qtmr_input_source
Quad Timer input sources selection.
Definition fsl_qtmr.h:65
void QTMR_SetCompareValue(TMR_Type *base, qtmr_channel_selection_t channel, uint16_t ticks)
Set compare value.
Definition fsl_qtmr.c:585
struct _qtmr_config qtmr_config_t
Quad Timer config structure.
void QTMR_Deinit(TMR_Type *base, qtmr_channel_selection_t channel)
Stops the counter and gates the Quad Timer clock.
Definition fsl_qtmr.c:103
void QTMR_SetupInputCapture(TMR_Type *base, qtmr_channel_selection_t channel, qtmr_input_source_t capturePin, bool inputPolarity, bool reloadOnCapture, qtmr_input_capture_edge_t captureMode)
Allows the user to count the source clock cycles until a capture event arrives.
Definition fsl_qtmr.c:278
enum _qtmr_preload_control qtmr_preload_control_t
Quad Timer input capture edge mode, rising edge, or falling edge.
_qtmr_primary_count_source
Quad Timer primary clock source selection.
Definition fsl_qtmr.h:44
void QTMR_Init(TMR_Type *base, qtmr_channel_selection_t channel, const qtmr_config_t *config)
Ungates the Quad Timer clock and configures the peripheral for basic operation.
Definition fsl_qtmr.c:72
void QTMR_ClearStatusFlags(TMR_Type *base, qtmr_channel_selection_t channel, uint32_t mask)
Clears the Quad Timer status flags.
Definition fsl_qtmr.c:502
enum _qtmr_pwm_out_state qtmr_pwm_out_state_t
Quad Timer PWM output state.
enum _qtmr_interrupt_enable qtmr_interrupt_enable_t
List of Quad Timer interrupts.
_qtmr_output_mode
Quad Timer output mode selection.
Definition fsl_qtmr.h:94
_qtmr_dma_enable
List of Quad Timer DMA enable.
Definition fsl_qtmr.h:163
_qtmr_interrupt_enable
List of Quad Timer interrupts.
Definition fsl_qtmr.h:134
uint8_t QTMR_GetPwmChannelStatus(TMR_Type *base, qtmr_channel_selection_t channel)
Get the PWM channel dutycycle value.
Definition fsl_qtmr.c:706
_qtmr_status_flags
List of Quad Timer flags.
Definition fsl_qtmr.h:144
uint32_t QTMR_GetEnabledInterrupts(TMR_Type *base, qtmr_channel_selection_t channel)
Gets the enabled Quad Timer interrupts.
Definition fsl_qtmr.c:411
@ kQTMR_PriSrcRiseEdgeSecInpHigh
Definition fsl_qtmr.h:78
@ kQTMR_PriSrcRiseAndFallEdge
Definition fsl_qtmr.h:77
@ kQTMR_PriSrcRiseEdgeSecDir
Definition fsl_qtmr.h:80
@ kQTMR_CascadeCount
Definition fsl_qtmr.h:82
@ kQTMR_SecSrcTrigPriCnt
Definition fsl_qtmr.h:81
@ kQTMR_NoOperation
Definition fsl_qtmr.h:75
@ kQTMR_PriSrcRiseEdge
Definition fsl_qtmr.h:76
@ kQTMR_QuadCountMode
Definition fsl_qtmr.h:79
@ kQTMR_HaltCountForceOutZero
Definition fsl_qtmr.h:128
@ kQTMR_HaltCounter
Definition fsl_qtmr.h:126
@ kQTMR_RunNormalInDebug
Definition fsl_qtmr.h:125
@ kQTMR_ForceOutToZero
Definition fsl_qtmr.h:127
@ kQTMR_Channel_2
Definition fsl_qtmr.h:157
@ kQTMR_Channel_3
Definition fsl_qtmr.h:158
@ kQTMR_Channel_0
Definition fsl_qtmr.h:155
@ kQTMR_Channel_1
Definition fsl_qtmr.h:156
@ kQTMR_NoPreload
Definition fsl_qtmr.h:117
@ kQTMR_LoadOnComp2
Definition fsl_qtmr.h:119
@ kQTMR_LoadOnComp1
Definition fsl_qtmr.h:118
@ kQTMR_PwmHigh
Definition fsl_qtmr.h:89
@ kQTMR_PwmLow
Definition fsl_qtmr.h:88
@ kQTMR_NoCapture
Definition fsl_qtmr.h:108
@ kQTMR_RisingAndFallingEdge
Definition fsl_qtmr.h:111
@ kQTMR_RisingEdge
Definition fsl_qtmr.h:109
@ kQTMR_FallingEdge
Definition fsl_qtmr.h:110
@ kQTMR_Counter3InputPin
Definition fsl_qtmr.h:69
@ kQTMR_Counter1InputPin
Definition fsl_qtmr.h:67
@ kQTMR_Counter0InputPin
Definition fsl_qtmr.h:66
@ kQTMR_Counter2InputPin
Definition fsl_qtmr.h:68
@ kQTMR_ClockCounter1Output
Definition fsl_qtmr.h:50
@ kQTMR_ClockDivide_16
Definition fsl_qtmr.h:57
@ kQTMR_ClockDivide_4
Definition fsl_qtmr.h:55
@ kQTMR_ClockDivide_8
Definition fsl_qtmr.h:56
@ kQTMR_ClockCounter1InputPin
Definition fsl_qtmr.h:46
@ kQTMR_ClockDivide_1
Definition fsl_qtmr.h:53
@ kQTMR_ClockCounter2Output
Definition fsl_qtmr.h:51
@ kQTMR_ClockCounter3Output
Definition fsl_qtmr.h:52
@ kQTMR_ClockCounter0InputPin
Definition fsl_qtmr.h:45
@ kQTMR_ClockDivide_64
Definition fsl_qtmr.h:59
@ kQTMR_ClockCounter0Output
Definition fsl_qtmr.h:49
@ kQTMR_ClockDivide_2
Definition fsl_qtmr.h:54
@ kQTMR_ClockDivide_32
Definition fsl_qtmr.h:58
@ kQTMR_ClockCounter2InputPin
Definition fsl_qtmr.h:47
@ kQTMR_ClockDivide_128
Definition fsl_qtmr.h:60
@ kQTMR_ClockCounter3InputPin
Definition fsl_qtmr.h:48
@ kQTMR_ClearOnCompare
Definition fsl_qtmr.h:96
@ kQTMR_AssertWhenCountActive
Definition fsl_qtmr.h:95
@ kQTMR_SetOnCompareClearOnCountRoll
Definition fsl_qtmr.h:101
@ kQTMR_SetOnCompareClearOnSecSrcInp
Definition fsl_qtmr.h:100
@ kQTMR_SetOnCompare
Definition fsl_qtmr.h:97
@ kQTMR_EnableGateClock
Definition fsl_qtmr.h:102
@ kQTMR_ToggleOnCompare
Definition fsl_qtmr.h:98
@ kQTMR_ToggleOnAltCompareReg
Definition fsl_qtmr.h:99
@ kQTMR_InputEdgeFlagDmaEnable
Definition fsl_qtmr.h:164
@ kQTMR_ComparatorPreload1DmaEnable
Definition fsl_qtmr.h:165
@ kQTMR_ComparatorPreload2DmaEnable
Definition fsl_qtmr.h:166
@ kQTMR_Compare1InterruptEnable
Definition fsl_qtmr.h:136
@ kQTMR_EdgeInterruptEnable
Definition fsl_qtmr.h:139
@ kQTMR_Compare2InterruptEnable
Definition fsl_qtmr.h:137
@ kQTMR_OverflowInterruptEnable
Definition fsl_qtmr.h:138
@ kQTMR_CompareInterruptEnable
Definition fsl_qtmr.h:135
@ kQTMR_CompareFlag
Definition fsl_qtmr.h:145
@ kQTMR_Compare1Flag
Definition fsl_qtmr.h:146
@ kQTMR_Compare2Flag
Definition fsl_qtmr.h:147
@ kQTMR_OverflowFlag
Definition fsl_qtmr.h:148
@ kQTMR_EdgeFlag
Definition fsl_qtmr.h:149
Quad Timer config structure.
Definition fsl_qtmr.h:179
bool enableMasterMode
Definition fsl_qtmr.h:182
uint8_t faultFilterPeriod
Definition fsl_qtmr.h:187
qtmr_primary_count_source_t primarySource
Definition fsl_qtmr.h:180
qtmr_input_source_t secondarySource
Definition fsl_qtmr.h:181
uint8_t faultFilterCount
Definition fsl_qtmr.h:186
qtmr_debug_action_t debugMode
Definition fsl_qtmr.h:188
bool enableExternalForce
Definition fsl_qtmr.h:184