RTEMS 6.1-rc4
Loading...
Searching...
No Matches
fsl_pit.h
1/*
2 * Copyright (c) 2015, Freescale Semiconductor, Inc.
3 * Copyright 2016-2020 NXP
4 * All rights reserved.
5 *
6 * SPDX-License-Identifier: BSD-3-Clause
7 */
8#ifndef _FSL_PIT_H_
9#define _FSL_PIT_H_
10
11#include "fsl_common.h"
12
18/*******************************************************************************
19 * Definitions
20 ******************************************************************************/
21
25#define FSL_PIT_DRIVER_VERSION (MAKE_VERSION(2, 0, 4))
32typedef enum _pit_chnl
33{
39
42{
43 kPIT_TimerInterruptEnable = PIT_TCTRL_TIE_MASK,
45
48{
49 kPIT_TimerFlag = PIT_TFLG_TIF_MASK,
51
61typedef struct _pit_config
62{
65
66/*******************************************************************************
67 * API
68 ******************************************************************************/
69
70#if defined(__cplusplus)
71extern "C" {
72#endif
73
87void PIT_Init(PIT_Type *base, const pit_config_t *config);
88
94void PIT_Deinit(PIT_Type *base);
95
105static inline void PIT_GetDefaultConfig(pit_config_t *config)
106{
107 assert(NULL != config);
108
109 /* Timers are stopped in Debug mode */
110 config->enableRunInDebug = false;
111}
112
113#if defined(FSL_FEATURE_PIT_HAS_CHAIN_MODE) && FSL_FEATURE_PIT_HAS_CHAIN_MODE
114
130static inline void PIT_SetTimerChainMode(PIT_Type *base, pit_chnl_t channel, bool enable)
131{
132 if (enable)
133 {
134 base->CHANNEL[channel].TCTRL |= PIT_TCTRL_CHN_MASK;
135 }
136 else
137 {
138 base->CHANNEL[channel].TCTRL &= ~PIT_TCTRL_CHN_MASK;
139 }
140}
141
142#endif /* FSL_FEATURE_PIT_HAS_CHAIN_MODE */
143
159static inline void PIT_EnableInterrupts(PIT_Type *base, pit_chnl_t channel, uint32_t mask)
160{
161 base->CHANNEL[channel].TCTRL |= mask;
162}
163
172static inline void PIT_DisableInterrupts(PIT_Type *base, pit_chnl_t channel, uint32_t mask)
173{
174 base->CHANNEL[channel].TCTRL &= ~mask;
175}
176
186static inline uint32_t PIT_GetEnabledInterrupts(PIT_Type *base, pit_chnl_t channel)
187{
188 return (base->CHANNEL[channel].TCTRL & PIT_TCTRL_TIE_MASK);
189}
190
207static inline uint32_t PIT_GetStatusFlags(PIT_Type *base, pit_chnl_t channel)
208{
209 return (base->CHANNEL[channel].TFLG & PIT_TFLG_TIF_MASK);
210}
211
220static inline void PIT_ClearStatusFlags(PIT_Type *base, pit_chnl_t channel, uint32_t mask)
221{
222 base->CHANNEL[channel].TFLG = mask;
223}
224
246static inline void PIT_SetTimerPeriod(PIT_Type *base, pit_chnl_t channel, uint32_t count)
247{
248 assert(count != 0U);
249 /* According to RM, the LDVAL trigger = clock ticks -1 */
250 base->CHANNEL[channel].LDVAL = count - 1U;
251}
252
266static inline uint32_t PIT_GetCurrentTimerCount(PIT_Type *base, pit_chnl_t channel)
267{
268 return base->CHANNEL[channel].CVAL;
269}
270
288static inline void PIT_StartTimer(PIT_Type *base, pit_chnl_t channel)
289{
290 base->CHANNEL[channel].TCTRL |= PIT_TCTRL_TEN_MASK;
291}
292
302static inline void PIT_StopTimer(PIT_Type *base, pit_chnl_t channel)
303{
304 base->CHANNEL[channel].TCTRL &= ~PIT_TCTRL_TEN_MASK;
305}
306
309#if defined(FSL_FEATURE_PIT_HAS_LIFETIME_TIMER) && FSL_FEATURE_PIT_HAS_LIFETIME_TIMER
310
324uint64_t PIT_GetLifetimeTimerCount(PIT_Type *base);
325
326#endif /* FSL_FEATURE_PIT_HAS_LIFETIME_TIMER */
327
328#if defined(__cplusplus)
329}
330#endif
331
334#endif /* _FSL_PIT_H_ */
_pit_chnl
List of PIT channels.
Definition: fsl_pit.h:33
enum _pit_chnl pit_chnl_t
List of PIT channels.
void PIT_Deinit(PIT_Type *base)
Gates the PIT clock and disables the PIT module.
Definition: fsl_pit.c:106
struct _pit_config pit_config_t
PIT configuration structure.
_pit_interrupt_enable
List of PIT interrupts.
Definition: fsl_pit.h:42
void PIT_Init(PIT_Type *base, const pit_config_t *config)
Ungates the PIT clock, enables the PIT module, and configures the peripheral for basic operations.
Definition: fsl_pit.c:68
enum _pit_status_flags pit_status_flags_t
List of PIT status flags.
_pit_status_flags
List of PIT status flags.
Definition: fsl_pit.h:48
enum _pit_interrupt_enable pit_interrupt_enable_t
List of PIT interrupts.
@ kPIT_Chnl_3
Definition: fsl_pit.h:37
@ kPIT_Chnl_0
Definition: fsl_pit.h:34
@ kPIT_Chnl_1
Definition: fsl_pit.h:35
@ kPIT_Chnl_2
Definition: fsl_pit.h:36
@ kPIT_TimerInterruptEnable
Definition: fsl_pit.h:43
@ kPIT_TimerFlag
Definition: fsl_pit.h:49
Definition: MIMXRT1052.h:33298
PIT configuration structure.
Definition: fsl_pit.h:62
bool enableRunInDebug
Definition: fsl_pit.h:63
Definition: deflate.c:114