RTEMS 6.1-rc4
Loading...
Searching...
No Matches
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#ifdef __rtems__
12#include <rtems.h>
13#endif /* __rtems__ */
14
20/*******************************************************************************
21 * Definitions
22 ******************************************************************************/
23#ifndef TMR_CSCTRL_OFLAG_MASK
24#define TMR_CSCTRL_OFLAG_MASK (0x100UL)
25#endif
26
27#ifndef TMR_CSCTRL_OFLAG_SHIFT
28#define TMR_CSCTRL_OFLAG_SHIFT (8UL)
29#endif
30
33#define FSL_QTMR_DRIVER_VERSION (MAKE_VERSION(2, 2, 1))
35
38{
56
59{
65
68{
78
81{
85
88{
98
101{
107
110{
115
118{
124
126// typedef enum _qtmr_interrupt_enable
128{
133 kQTMR_EdgeInterruptEnable = (1U << 4)
135
138{
139 kQTMR_CompareFlag = (1U << 0),
140 kQTMR_Compare1Flag = (1U << 1),
141 kQTMR_Compare2Flag = (1U << 2),
142 kQTMR_OverflowFlag = (1U << 3),
143 kQTMR_EdgeFlag = (1U << 4)
145
148{
154
157{
162
172typedef struct _qtmr_config
173{
184
185/*******************************************************************************
186 * API
187 ******************************************************************************/
188
189#if defined(__cplusplus)
190extern "C" {
191#endif
192
197#ifdef __rtems__
207TMR_Type *QTMR_get_regs_from_fdt(const void *fdt, int node);
208
217rtems_vector_number QTMR_get_IRQ_from_fdt(const void *fdt, int node);
218
226uint32_t QTMR_get_src_clk(TMR_Type *base);
227#endif /* __rtems__ */
228
239
247
264
286 uint32_t pwmFreqHz,
287 uint8_t dutyCyclePercent,
288 bool outputPolarity,
289 uint32_t srcClock_Hz);
290
305 qtmr_input_source_t capturePin,
306 bool inputPolarity,
307 bool reloadOnCapture,
308 qtmr_input_capture_edge_t captureMode);
309
323void QTMR_EnableInterrupts(TMR_Type *base, qtmr_channel_selection_t channel, uint32_t mask);
324
333void QTMR_DisableInterrupts(TMR_Type *base, qtmr_channel_selection_t channel, uint32_t mask);
334
345
362uint32_t QTMR_GetStatus(TMR_Type *base, qtmr_channel_selection_t channel);
363
372void QTMR_ClearStatusFlags(TMR_Type *base, qtmr_channel_selection_t channel, uint32_t mask);
373
397void QTMR_SetTimerPeriod(TMR_Type *base, qtmr_channel_selection_t channel, uint16_t ticks);
398
408void QTMR_SetCompareValue(TMR_Type *base, qtmr_channel_selection_t channel, uint16_t ticks);
409
419static inline void QTMR_SetLoadValue(TMR_Type *base, qtmr_channel_selection_t channel, uint16_t value)
420{
421 base->CHANNEL[channel].LOAD &= (uint16_t)(~TMR_LOAD_LOAD_MASK);
422 base->CHANNEL[channel].LOAD = value;
423}
424
438static inline uint16_t QTMR_GetCurrentTimerCount(TMR_Type *base, qtmr_channel_selection_t channel)
439{
440 return base->CHANNEL[channel].CNTR;
441}
442
458static inline void QTMR_StartTimer(TMR_Type *base, qtmr_channel_selection_t channel, qtmr_counting_mode_t clockSource)
459{
460 uint16_t reg = base->CHANNEL[channel].CTRL;
461
462 reg &= (uint16_t)(~(TMR_CTRL_CM_MASK));
463 reg |= TMR_CTRL_CM(clockSource);
464 base->CHANNEL[channel].CTRL = reg;
465}
466
473static inline void QTMR_StopTimer(TMR_Type *base, qtmr_channel_selection_t channel)
474{
475 base->CHANNEL[channel].CTRL &= (uint16_t)(~TMR_CTRL_CM_MASK);
476}
477
493void QTMR_EnableDma(TMR_Type *base, qtmr_channel_selection_t channel, uint32_t mask);
494
503void QTMR_DisableDma(TMR_Type *base, qtmr_channel_selection_t channel, uint32_t mask);
504
514void QTMR_SetPwmOutputToIdle(TMR_Type *base, qtmr_channel_selection_t channel, bool idleStatus);
515
524static inline qtmr_pwm_out_state_t QTMR_GetPwmOutputStatus(TMR_Type *base, qtmr_channel_selection_t channel)
525{
526 if (0U != ((base->CHANNEL[channel].CSCTRL) & TMR_CSCTRL_OFLAG_MASK))
527 {
528 return kQTMR_PwmHigh;
529 }
530 else
531 {
532 return kQTMR_PwmLow;
533 }
534}
535
545
554
557#if defined(__cplusplus)
558}
559#endif
560
563#endif /* _FSL_QTMR_H_ */
ISR_Vector_number rtems_vector_number
This integer type represents interrupt vector numbers.
Definition: intr.h:102
#define TMR_CTRL_CM(x)
Definition: MIMXRT1052.h:43615
int32_t status_t
Type used for all status and error return values.
Definition: fsl_common.h:225
void QTMR_DisableDma(TMR_Type *base, qtmr_channel_selection_t channel, uint32_t mask)
Disable the Quad Timer DMA.
Definition: fsl_qtmr.c:688
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:602
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:764
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:215
_qtmr_counting_mode
Quad Timer counting mode selection.
Definition: fsl_qtmr.h:68
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:366
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:118
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:148
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:110
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:720
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:175
void QTMR_DisableInterrupts(TMR_Type *base, qtmr_channel_selection_t channel, uint32_t mask)
Disables the selected Quad Timer interrupts.
Definition: fsl_qtmr.c:412
void QTMR_EnableDma(TMR_Type *base, qtmr_channel_selection_t channel, uint32_t mask)
Enable the Quad Timer DMA.
Definition: fsl_qtmr.c:655
_qtmr_pwm_out_state
Quad Timer PWM output state.
Definition: fsl_qtmr.h:81
_qtmr_input_capture_edge
Quad Timer input capture edge mode, rising edge, or falling edge.
Definition: fsl_qtmr.h:101
uint32_t QTMR_GetStatus(TMR_Type *base, qtmr_channel_selection_t channel)
Gets the Quad Timer status flags.
Definition: fsl_qtmr.c:503
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:59
void QTMR_SetCompareValue(TMR_Type *base, qtmr_channel_selection_t channel, uint16_t ticks)
Set compare value.
Definition: fsl_qtmr.c:631
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:149
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:324
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:38
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:118
void QTMR_ClearStatusFlags(TMR_Type *base, qtmr_channel_selection_t channel, uint32_t mask)
Clears the Quad Timer status flags.
Definition: fsl_qtmr.c:548
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:88
_qtmr_dma_enable
List of Quad Timer DMA enable.
Definition: fsl_qtmr.h:157
_qtmr_interrupt_enable
List of Quad Timer interrupts.
Definition: fsl_qtmr.h:128
uint8_t QTMR_GetPwmChannelStatus(TMR_Type *base, qtmr_channel_selection_t channel)
Get the PWM channel dutycycle value.
Definition: fsl_qtmr.c:752
_qtmr_status_flags
List of Quad Timer flags.
Definition: fsl_qtmr.h:138
uint32_t QTMR_GetEnabledInterrupts(TMR_Type *base, qtmr_channel_selection_t channel)
Gets the enabled Quad Timer interrupts.
Definition: fsl_qtmr.c:457
@ kQTMR_PriSrcRiseEdgeSecInpHigh
Definition: fsl_qtmr.h:72
@ kQTMR_PriSrcRiseAndFallEdge
Definition: fsl_qtmr.h:71
@ kQTMR_PriSrcRiseEdgeSecDir
Definition: fsl_qtmr.h:74
@ kQTMR_CascadeCount
Definition: fsl_qtmr.h:76
@ kQTMR_SecSrcTrigPriCnt
Definition: fsl_qtmr.h:75
@ kQTMR_NoOperation
Definition: fsl_qtmr.h:69
@ kQTMR_PriSrcRiseEdge
Definition: fsl_qtmr.h:70
@ kQTMR_QuadCountMode
Definition: fsl_qtmr.h:73
@ kQTMR_HaltCountForceOutZero
Definition: fsl_qtmr.h:122
@ kQTMR_HaltCounter
Definition: fsl_qtmr.h:120
@ kQTMR_RunNormalInDebug
Definition: fsl_qtmr.h:119
@ kQTMR_ForceOutToZero
Definition: fsl_qtmr.h:121
@ kQTMR_Channel_2
Definition: fsl_qtmr.h:151
@ kQTMR_Channel_3
Definition: fsl_qtmr.h:152
@ kQTMR_Channel_0
Definition: fsl_qtmr.h:149
@ kQTMR_Channel_1
Definition: fsl_qtmr.h:150
@ kQTMR_NoPreload
Definition: fsl_qtmr.h:111
@ kQTMR_LoadOnComp2
Definition: fsl_qtmr.h:113
@ kQTMR_LoadOnComp1
Definition: fsl_qtmr.h:112
@ kQTMR_PwmHigh
Definition: fsl_qtmr.h:83
@ kQTMR_PwmLow
Definition: fsl_qtmr.h:82
@ kQTMR_NoCapture
Definition: fsl_qtmr.h:102
@ kQTMR_RisingAndFallingEdge
Definition: fsl_qtmr.h:105
@ kQTMR_RisingEdge
Definition: fsl_qtmr.h:103
@ kQTMR_FallingEdge
Definition: fsl_qtmr.h:104
@ kQTMR_Counter3InputPin
Definition: fsl_qtmr.h:63
@ kQTMR_Counter1InputPin
Definition: fsl_qtmr.h:61
@ kQTMR_Counter0InputPin
Definition: fsl_qtmr.h:60
@ kQTMR_Counter2InputPin
Definition: fsl_qtmr.h:62
@ kQTMR_ClockCounter1Output
Definition: fsl_qtmr.h:44
@ kQTMR_ClockDivide_16
Definition: fsl_qtmr.h:51
@ kQTMR_ClockDivide_4
Definition: fsl_qtmr.h:49
@ kQTMR_ClockDivide_8
Definition: fsl_qtmr.h:50
@ kQTMR_ClockCounter1InputPin
Definition: fsl_qtmr.h:40
@ kQTMR_ClockDivide_1
Definition: fsl_qtmr.h:47
@ kQTMR_ClockCounter2Output
Definition: fsl_qtmr.h:45
@ kQTMR_ClockCounter3Output
Definition: fsl_qtmr.h:46
@ kQTMR_ClockCounter0InputPin
Definition: fsl_qtmr.h:39
@ kQTMR_ClockDivide_64
Definition: fsl_qtmr.h:53
@ kQTMR_ClockCounter0Output
Definition: fsl_qtmr.h:43
@ kQTMR_ClockDivide_2
Definition: fsl_qtmr.h:48
@ kQTMR_ClockDivide_32
Definition: fsl_qtmr.h:52
@ kQTMR_ClockCounter2InputPin
Definition: fsl_qtmr.h:41
@ kQTMR_ClockDivide_128
Definition: fsl_qtmr.h:54
@ kQTMR_ClockCounter3InputPin
Definition: fsl_qtmr.h:42
@ kQTMR_ClearOnCompare
Definition: fsl_qtmr.h:90
@ kQTMR_AssertWhenCountActive
Definition: fsl_qtmr.h:89
@ kQTMR_SetOnCompareClearOnCountRoll
Definition: fsl_qtmr.h:95
@ kQTMR_SetOnCompareClearOnSecSrcInp
Definition: fsl_qtmr.h:94
@ kQTMR_SetOnCompare
Definition: fsl_qtmr.h:91
@ kQTMR_EnableGateClock
Definition: fsl_qtmr.h:96
@ kQTMR_ToggleOnCompare
Definition: fsl_qtmr.h:92
@ kQTMR_ToggleOnAltCompareReg
Definition: fsl_qtmr.h:93
@ kQTMR_InputEdgeFlagDmaEnable
Definition: fsl_qtmr.h:158
@ kQTMR_ComparatorPreload1DmaEnable
Definition: fsl_qtmr.h:159
@ kQTMR_ComparatorPreload2DmaEnable
Definition: fsl_qtmr.h:160
@ kQTMR_Compare1InterruptEnable
Definition: fsl_qtmr.h:130
@ kQTMR_EdgeInterruptEnable
Definition: fsl_qtmr.h:133
@ kQTMR_Compare2InterruptEnable
Definition: fsl_qtmr.h:131
@ kQTMR_OverflowInterruptEnable
Definition: fsl_qtmr.h:132
@ kQTMR_CompareInterruptEnable
Definition: fsl_qtmr.h:129
@ kQTMR_CompareFlag
Definition: fsl_qtmr.h:139
@ kQTMR_Compare1Flag
Definition: fsl_qtmr.h:140
@ kQTMR_Compare2Flag
Definition: fsl_qtmr.h:141
@ kQTMR_OverflowFlag
Definition: fsl_qtmr.h:142
@ kQTMR_EdgeFlag
Definition: fsl_qtmr.h:143
This header file defines the RTEMS Classic API.
Definition: MIMXRT1052.h:43409
Quad Timer config structure.
Definition: fsl_qtmr.h:173
bool enableMasterMode
Definition: fsl_qtmr.h:176
uint8_t faultFilterPeriod
Definition: fsl_qtmr.h:181
qtmr_primary_count_source_t primarySource
Definition: fsl_qtmr.h:174
qtmr_input_source_t secondarySource
Definition: fsl_qtmr.h:175
uint8_t faultFilterCount
Definition: fsl_qtmr.h:180
qtmr_debug_action_t debugMode
Definition: fsl_qtmr.h:182
bool enableExternalForce
Definition: fsl_qtmr.h:178
Definition: deflate.c:114