The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

mbed 2

This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.

Committer:
AnnaBridge
Date:
Thu Nov 08 11:45:42 2018 +0000
Revision:
171:3a7713b1edbc
Parent:
TARGET_RO359B/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K24F/drivers/fsl_pit.h@143:86740a56073b
mbed library. Release version 164

Who changed what in which revision?

UserRevisionLine numberNew contents of line
AnnaBridge 143:86740a56073b 1 /*
AnnaBridge 143:86740a56073b 2 * Copyright (c) 2015, Freescale Semiconductor, Inc.
AnnaBridge 143:86740a56073b 3 * Copyright 2016-2017 NXP
AnnaBridge 143:86740a56073b 4 *
AnnaBridge 143:86740a56073b 5 * Redistribution and use in source and binary forms, with or without modification,
AnnaBridge 143:86740a56073b 6 * are permitted provided that the following conditions are met:
AnnaBridge 143:86740a56073b 7 *
AnnaBridge 143:86740a56073b 8 * o Redistributions of source code must retain the above copyright notice, this list
AnnaBridge 143:86740a56073b 9 * of conditions and the following disclaimer.
AnnaBridge 143:86740a56073b 10 *
AnnaBridge 143:86740a56073b 11 * o Redistributions in binary form must reproduce the above copyright notice, this
AnnaBridge 143:86740a56073b 12 * list of conditions and the following disclaimer in the documentation and/or
AnnaBridge 143:86740a56073b 13 * other materials provided with the distribution.
AnnaBridge 143:86740a56073b 14 *
AnnaBridge 143:86740a56073b 15 * o Neither the name of the copyright holder nor the names of its
AnnaBridge 143:86740a56073b 16 * contributors may be used to endorse or promote products derived from this
AnnaBridge 143:86740a56073b 17 * software without specific prior written permission.
AnnaBridge 143:86740a56073b 18 *
AnnaBridge 143:86740a56073b 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
AnnaBridge 143:86740a56073b 20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
AnnaBridge 143:86740a56073b 21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
AnnaBridge 143:86740a56073b 22 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
AnnaBridge 143:86740a56073b 23 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
AnnaBridge 143:86740a56073b 24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
AnnaBridge 143:86740a56073b 25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
AnnaBridge 143:86740a56073b 26 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
AnnaBridge 143:86740a56073b 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
AnnaBridge 143:86740a56073b 28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
AnnaBridge 143:86740a56073b 29 */
AnnaBridge 143:86740a56073b 30 #ifndef _FSL_PIT_H_
AnnaBridge 143:86740a56073b 31 #define _FSL_PIT_H_
AnnaBridge 143:86740a56073b 32
AnnaBridge 143:86740a56073b 33 #include "fsl_common.h"
AnnaBridge 143:86740a56073b 34
AnnaBridge 143:86740a56073b 35 /*!
AnnaBridge 143:86740a56073b 36 * @addtogroup pit
AnnaBridge 143:86740a56073b 37 * @{
AnnaBridge 143:86740a56073b 38 */
AnnaBridge 143:86740a56073b 39
AnnaBridge 143:86740a56073b 40
AnnaBridge 143:86740a56073b 41 /*******************************************************************************
AnnaBridge 143:86740a56073b 42 * Definitions
AnnaBridge 143:86740a56073b 43 ******************************************************************************/
AnnaBridge 143:86740a56073b 44
AnnaBridge 143:86740a56073b 45 /*! @name Driver version */
AnnaBridge 143:86740a56073b 46 /*@{*/
AnnaBridge 143:86740a56073b 47 #define FSL_PIT_DRIVER_VERSION (MAKE_VERSION(2, 0, 0)) /*!< Version 2.0.0 */
AnnaBridge 143:86740a56073b 48 /*@}*/
AnnaBridge 143:86740a56073b 49
AnnaBridge 143:86740a56073b 50 /*!
AnnaBridge 143:86740a56073b 51 * @brief List of PIT channels
AnnaBridge 143:86740a56073b 52 * @note Actual number of available channels is SoC dependent
AnnaBridge 143:86740a56073b 53 */
AnnaBridge 143:86740a56073b 54 typedef enum _pit_chnl
AnnaBridge 143:86740a56073b 55 {
AnnaBridge 143:86740a56073b 56 kPIT_Chnl_0 = 0U, /*!< PIT channel number 0*/
AnnaBridge 143:86740a56073b 57 kPIT_Chnl_1, /*!< PIT channel number 1 */
AnnaBridge 143:86740a56073b 58 kPIT_Chnl_2, /*!< PIT channel number 2 */
AnnaBridge 143:86740a56073b 59 kPIT_Chnl_3, /*!< PIT channel number 3 */
AnnaBridge 143:86740a56073b 60 } pit_chnl_t;
AnnaBridge 143:86740a56073b 61
AnnaBridge 143:86740a56073b 62 /*! @brief List of PIT interrupts */
AnnaBridge 143:86740a56073b 63 typedef enum _pit_interrupt_enable
AnnaBridge 143:86740a56073b 64 {
AnnaBridge 143:86740a56073b 65 kPIT_TimerInterruptEnable = PIT_TCTRL_TIE_MASK, /*!< Timer interrupt enable*/
AnnaBridge 143:86740a56073b 66 } pit_interrupt_enable_t;
AnnaBridge 143:86740a56073b 67
AnnaBridge 143:86740a56073b 68 /*! @brief List of PIT status flags */
AnnaBridge 143:86740a56073b 69 typedef enum _pit_status_flags
AnnaBridge 143:86740a56073b 70 {
AnnaBridge 143:86740a56073b 71 kPIT_TimerFlag = PIT_TFLG_TIF_MASK, /*!< Timer flag */
AnnaBridge 143:86740a56073b 72 } pit_status_flags_t;
AnnaBridge 143:86740a56073b 73
AnnaBridge 143:86740a56073b 74 /*!
AnnaBridge 143:86740a56073b 75 * @brief PIT configuration structure
AnnaBridge 143:86740a56073b 76 *
AnnaBridge 143:86740a56073b 77 * This structure holds the configuration settings for the PIT peripheral. To initialize this
AnnaBridge 143:86740a56073b 78 * structure to reasonable defaults, call the PIT_GetDefaultConfig() function and pass a
AnnaBridge 143:86740a56073b 79 * pointer to your config structure instance.
AnnaBridge 143:86740a56073b 80 *
AnnaBridge 143:86740a56073b 81 * The configuration structure can be made constant so it resides in flash.
AnnaBridge 143:86740a56073b 82 */
AnnaBridge 143:86740a56073b 83 typedef struct _pit_config
AnnaBridge 143:86740a56073b 84 {
AnnaBridge 143:86740a56073b 85 bool enableRunInDebug; /*!< true: Timers run in debug mode; false: Timers stop in debug mode */
AnnaBridge 143:86740a56073b 86 } pit_config_t;
AnnaBridge 143:86740a56073b 87
AnnaBridge 143:86740a56073b 88 /*******************************************************************************
AnnaBridge 143:86740a56073b 89 * API
AnnaBridge 143:86740a56073b 90 ******************************************************************************/
AnnaBridge 143:86740a56073b 91
AnnaBridge 143:86740a56073b 92 #if defined(__cplusplus)
AnnaBridge 143:86740a56073b 93 extern "C" {
AnnaBridge 143:86740a56073b 94 #endif
AnnaBridge 143:86740a56073b 95
AnnaBridge 143:86740a56073b 96 /*!
AnnaBridge 143:86740a56073b 97 * @name Initialization and deinitialization
AnnaBridge 143:86740a56073b 98 * @{
AnnaBridge 143:86740a56073b 99 */
AnnaBridge 143:86740a56073b 100
AnnaBridge 143:86740a56073b 101 /*!
AnnaBridge 143:86740a56073b 102 * @brief Ungates the PIT clock, enables the PIT module, and configures the peripheral for basic operations.
AnnaBridge 143:86740a56073b 103 *
AnnaBridge 143:86740a56073b 104 * @note This API should be called at the beginning of the application using the PIT driver.
AnnaBridge 143:86740a56073b 105 *
AnnaBridge 143:86740a56073b 106 * @param base PIT peripheral base address
AnnaBridge 143:86740a56073b 107 * @param config Pointer to the user's PIT config structure
AnnaBridge 143:86740a56073b 108 */
AnnaBridge 143:86740a56073b 109 void PIT_Init(PIT_Type *base, const pit_config_t *config);
AnnaBridge 143:86740a56073b 110
AnnaBridge 143:86740a56073b 111 /*!
AnnaBridge 143:86740a56073b 112 * @brief Gates the PIT clock and disables the PIT module.
AnnaBridge 143:86740a56073b 113 *
AnnaBridge 143:86740a56073b 114 * @param base PIT peripheral base address
AnnaBridge 143:86740a56073b 115 */
AnnaBridge 143:86740a56073b 116 void PIT_Deinit(PIT_Type *base);
AnnaBridge 143:86740a56073b 117
AnnaBridge 143:86740a56073b 118 /*!
AnnaBridge 143:86740a56073b 119 * @brief Fills in the PIT configuration structure with the default settings.
AnnaBridge 143:86740a56073b 120 *
AnnaBridge 143:86740a56073b 121 * The default values are as follows.
AnnaBridge 143:86740a56073b 122 * @code
AnnaBridge 143:86740a56073b 123 * config->enableRunInDebug = false;
AnnaBridge 143:86740a56073b 124 * @endcode
AnnaBridge 143:86740a56073b 125 * @param config Pointer to the onfiguration structure.
AnnaBridge 143:86740a56073b 126 */
AnnaBridge 143:86740a56073b 127 static inline void PIT_GetDefaultConfig(pit_config_t *config)
AnnaBridge 143:86740a56073b 128 {
AnnaBridge 143:86740a56073b 129 assert(config);
AnnaBridge 143:86740a56073b 130
AnnaBridge 143:86740a56073b 131 /* Timers are stopped in Debug mode */
AnnaBridge 143:86740a56073b 132 config->enableRunInDebug = false;
AnnaBridge 143:86740a56073b 133 }
AnnaBridge 143:86740a56073b 134
AnnaBridge 143:86740a56073b 135 #if defined(FSL_FEATURE_PIT_HAS_CHAIN_MODE) && FSL_FEATURE_PIT_HAS_CHAIN_MODE
AnnaBridge 143:86740a56073b 136
AnnaBridge 143:86740a56073b 137 /*!
AnnaBridge 143:86740a56073b 138 * @brief Enables or disables chaining a timer with the previous timer.
AnnaBridge 143:86740a56073b 139 *
AnnaBridge 143:86740a56073b 140 * When a timer has a chain mode enabled, it only counts after the previous
AnnaBridge 143:86740a56073b 141 * timer has expired. If the timer n-1 has counted down to 0, counter n
AnnaBridge 143:86740a56073b 142 * decrements the value by one. Each timer is 32-bits, which allows the developers
AnnaBridge 143:86740a56073b 143 * to chain timers together and form a longer timer (64-bits and larger). The first timer
AnnaBridge 143:86740a56073b 144 * (timer 0) can't be chained to any other timer.
AnnaBridge 143:86740a56073b 145 *
AnnaBridge 143:86740a56073b 146 * @param base PIT peripheral base address
AnnaBridge 143:86740a56073b 147 * @param channel Timer channel number which is chained with the previous timer
AnnaBridge 143:86740a56073b 148 * @param enable Enable or disable chain.
AnnaBridge 143:86740a56073b 149 * true: Current timer is chained with the previous timer.
AnnaBridge 143:86740a56073b 150 * false: Timer doesn't chain with other timers.
AnnaBridge 143:86740a56073b 151 */
AnnaBridge 143:86740a56073b 152 static inline void PIT_SetTimerChainMode(PIT_Type *base, pit_chnl_t channel, bool enable)
AnnaBridge 143:86740a56073b 153 {
AnnaBridge 143:86740a56073b 154 if (enable)
AnnaBridge 143:86740a56073b 155 {
AnnaBridge 143:86740a56073b 156 base->CHANNEL[channel].TCTRL |= PIT_TCTRL_CHN_MASK;
AnnaBridge 143:86740a56073b 157 }
AnnaBridge 143:86740a56073b 158 else
AnnaBridge 143:86740a56073b 159 {
AnnaBridge 143:86740a56073b 160 base->CHANNEL[channel].TCTRL &= ~PIT_TCTRL_CHN_MASK;
AnnaBridge 143:86740a56073b 161 }
AnnaBridge 143:86740a56073b 162 }
AnnaBridge 143:86740a56073b 163
AnnaBridge 143:86740a56073b 164 #endif /* FSL_FEATURE_PIT_HAS_CHAIN_MODE */
AnnaBridge 143:86740a56073b 165
AnnaBridge 143:86740a56073b 166 /*! @}*/
AnnaBridge 143:86740a56073b 167
AnnaBridge 143:86740a56073b 168 /*!
AnnaBridge 143:86740a56073b 169 * @name Interrupt Interface
AnnaBridge 143:86740a56073b 170 * @{
AnnaBridge 143:86740a56073b 171 */
AnnaBridge 143:86740a56073b 172
AnnaBridge 143:86740a56073b 173 /*!
AnnaBridge 143:86740a56073b 174 * @brief Enables the selected PIT interrupts.
AnnaBridge 143:86740a56073b 175 *
AnnaBridge 143:86740a56073b 176 * @param base PIT peripheral base address
AnnaBridge 143:86740a56073b 177 * @param channel Timer channel number
AnnaBridge 143:86740a56073b 178 * @param mask The interrupts to enable. This is a logical OR of members of the
AnnaBridge 143:86740a56073b 179 * enumeration ::pit_interrupt_enable_t
AnnaBridge 143:86740a56073b 180 */
AnnaBridge 143:86740a56073b 181 static inline void PIT_EnableInterrupts(PIT_Type *base, pit_chnl_t channel, uint32_t mask)
AnnaBridge 143:86740a56073b 182 {
AnnaBridge 143:86740a56073b 183 base->CHANNEL[channel].TCTRL |= mask;
AnnaBridge 143:86740a56073b 184 }
AnnaBridge 143:86740a56073b 185
AnnaBridge 143:86740a56073b 186 /*!
AnnaBridge 143:86740a56073b 187 * @brief Disables the selected PIT interrupts.
AnnaBridge 143:86740a56073b 188 *
AnnaBridge 143:86740a56073b 189 * @param base PIT peripheral base address
AnnaBridge 143:86740a56073b 190 * @param channel Timer channel number
AnnaBridge 143:86740a56073b 191 * @param mask The interrupts to disable. This is a logical OR of members of the
AnnaBridge 143:86740a56073b 192 * enumeration ::pit_interrupt_enable_t
AnnaBridge 143:86740a56073b 193 */
AnnaBridge 143:86740a56073b 194 static inline void PIT_DisableInterrupts(PIT_Type *base, pit_chnl_t channel, uint32_t mask)
AnnaBridge 143:86740a56073b 195 {
AnnaBridge 143:86740a56073b 196 base->CHANNEL[channel].TCTRL &= ~mask;
AnnaBridge 143:86740a56073b 197 }
AnnaBridge 143:86740a56073b 198
AnnaBridge 143:86740a56073b 199 /*!
AnnaBridge 143:86740a56073b 200 * @brief Gets the enabled PIT interrupts.
AnnaBridge 143:86740a56073b 201 *
AnnaBridge 143:86740a56073b 202 * @param base PIT peripheral base address
AnnaBridge 143:86740a56073b 203 * @param channel Timer channel number
AnnaBridge 143:86740a56073b 204 *
AnnaBridge 143:86740a56073b 205 * @return The enabled interrupts. This is the logical OR of members of the
AnnaBridge 143:86740a56073b 206 * enumeration ::pit_interrupt_enable_t
AnnaBridge 143:86740a56073b 207 */
AnnaBridge 143:86740a56073b 208 static inline uint32_t PIT_GetEnabledInterrupts(PIT_Type *base, pit_chnl_t channel)
AnnaBridge 143:86740a56073b 209 {
AnnaBridge 143:86740a56073b 210 return (base->CHANNEL[channel].TCTRL & PIT_TCTRL_TIE_MASK);
AnnaBridge 143:86740a56073b 211 }
AnnaBridge 143:86740a56073b 212
AnnaBridge 143:86740a56073b 213 /*! @}*/
AnnaBridge 143:86740a56073b 214
AnnaBridge 143:86740a56073b 215 /*!
AnnaBridge 143:86740a56073b 216 * @name Status Interface
AnnaBridge 143:86740a56073b 217 * @{
AnnaBridge 143:86740a56073b 218 */
AnnaBridge 143:86740a56073b 219
AnnaBridge 143:86740a56073b 220 /*!
AnnaBridge 143:86740a56073b 221 * @brief Gets the PIT status flags.
AnnaBridge 143:86740a56073b 222 *
AnnaBridge 143:86740a56073b 223 * @param base PIT peripheral base address
AnnaBridge 143:86740a56073b 224 * @param channel Timer channel number
AnnaBridge 143:86740a56073b 225 *
AnnaBridge 143:86740a56073b 226 * @return The status flags. This is the logical OR of members of the
AnnaBridge 143:86740a56073b 227 * enumeration ::pit_status_flags_t
AnnaBridge 143:86740a56073b 228 */
AnnaBridge 143:86740a56073b 229 static inline uint32_t PIT_GetStatusFlags(PIT_Type *base, pit_chnl_t channel)
AnnaBridge 143:86740a56073b 230 {
AnnaBridge 143:86740a56073b 231 return (base->CHANNEL[channel].TFLG & PIT_TFLG_TIF_MASK);
AnnaBridge 143:86740a56073b 232 }
AnnaBridge 143:86740a56073b 233
AnnaBridge 143:86740a56073b 234 /*!
AnnaBridge 143:86740a56073b 235 * @brief Clears the PIT status flags.
AnnaBridge 143:86740a56073b 236 *
AnnaBridge 143:86740a56073b 237 * @param base PIT peripheral base address
AnnaBridge 143:86740a56073b 238 * @param channel Timer channel number
AnnaBridge 143:86740a56073b 239 * @param mask The status flags to clear. This is a logical OR of members of the
AnnaBridge 143:86740a56073b 240 * enumeration ::pit_status_flags_t
AnnaBridge 143:86740a56073b 241 */
AnnaBridge 143:86740a56073b 242 static inline void PIT_ClearStatusFlags(PIT_Type *base, pit_chnl_t channel, uint32_t mask)
AnnaBridge 143:86740a56073b 243 {
AnnaBridge 143:86740a56073b 244 base->CHANNEL[channel].TFLG = mask;
AnnaBridge 143:86740a56073b 245 }
AnnaBridge 143:86740a56073b 246
AnnaBridge 143:86740a56073b 247 /*! @}*/
AnnaBridge 143:86740a56073b 248
AnnaBridge 143:86740a56073b 249 /*!
AnnaBridge 143:86740a56073b 250 * @name Read and Write the timer period
AnnaBridge 143:86740a56073b 251 * @{
AnnaBridge 143:86740a56073b 252 */
AnnaBridge 143:86740a56073b 253
AnnaBridge 143:86740a56073b 254 /*!
AnnaBridge 143:86740a56073b 255 * @brief Sets the timer period in units of count.
AnnaBridge 143:86740a56073b 256 *
AnnaBridge 143:86740a56073b 257 * Timers begin counting from the value set by this function until it reaches 0,
AnnaBridge 143:86740a56073b 258 * then it generates an interrupt and load this register value again.
AnnaBridge 143:86740a56073b 259 * Writing a new value to this register does not restart the timer. Instead, the value
AnnaBridge 143:86740a56073b 260 * is loaded after the timer expires.
AnnaBridge 143:86740a56073b 261 *
AnnaBridge 143:86740a56073b 262 * @note Users can call the utility macros provided in fsl_common.h to convert to ticks.
AnnaBridge 143:86740a56073b 263 *
AnnaBridge 143:86740a56073b 264 * @param base PIT peripheral base address
AnnaBridge 143:86740a56073b 265 * @param channel Timer channel number
AnnaBridge 143:86740a56073b 266 * @param count Timer period in units of ticks
AnnaBridge 143:86740a56073b 267 */
AnnaBridge 143:86740a56073b 268 static inline void PIT_SetTimerPeriod(PIT_Type *base, pit_chnl_t channel, uint32_t count)
AnnaBridge 143:86740a56073b 269 {
AnnaBridge 143:86740a56073b 270 base->CHANNEL[channel].LDVAL = count;
AnnaBridge 143:86740a56073b 271 }
AnnaBridge 143:86740a56073b 272
AnnaBridge 143:86740a56073b 273 /*!
AnnaBridge 143:86740a56073b 274 * @brief Reads the current timer counting value.
AnnaBridge 143:86740a56073b 275 *
AnnaBridge 143:86740a56073b 276 * This function returns the real-time timer counting value, in a range from 0 to a
AnnaBridge 143:86740a56073b 277 * timer period.
AnnaBridge 143:86740a56073b 278 *
AnnaBridge 143:86740a56073b 279 * @note Users can call the utility macros provided in fsl_common.h to convert ticks to usec or msec.
AnnaBridge 143:86740a56073b 280 *
AnnaBridge 143:86740a56073b 281 * @param base PIT peripheral base address
AnnaBridge 143:86740a56073b 282 * @param channel Timer channel number
AnnaBridge 143:86740a56073b 283 *
AnnaBridge 143:86740a56073b 284 * @return Current timer counting value in ticks
AnnaBridge 143:86740a56073b 285 */
AnnaBridge 143:86740a56073b 286 static inline uint32_t PIT_GetCurrentTimerCount(PIT_Type *base, pit_chnl_t channel)
AnnaBridge 143:86740a56073b 287 {
AnnaBridge 143:86740a56073b 288 return base->CHANNEL[channel].CVAL;
AnnaBridge 143:86740a56073b 289 }
AnnaBridge 143:86740a56073b 290
AnnaBridge 143:86740a56073b 291 /*! @}*/
AnnaBridge 143:86740a56073b 292
AnnaBridge 143:86740a56073b 293 /*!
AnnaBridge 143:86740a56073b 294 * @name Timer Start and Stop
AnnaBridge 143:86740a56073b 295 * @{
AnnaBridge 143:86740a56073b 296 */
AnnaBridge 143:86740a56073b 297
AnnaBridge 143:86740a56073b 298 /*!
AnnaBridge 143:86740a56073b 299 * @brief Starts the timer counting.
AnnaBridge 143:86740a56073b 300 *
AnnaBridge 143:86740a56073b 301 * After calling this function, timers load period value, count down to 0 and
AnnaBridge 143:86740a56073b 302 * then load the respective start value again. Each time a timer reaches 0,
AnnaBridge 143:86740a56073b 303 * it generates a trigger pulse and sets the timeout interrupt flag.
AnnaBridge 143:86740a56073b 304 *
AnnaBridge 143:86740a56073b 305 * @param base PIT peripheral base address
AnnaBridge 143:86740a56073b 306 * @param channel Timer channel number.
AnnaBridge 143:86740a56073b 307 */
AnnaBridge 143:86740a56073b 308 static inline void PIT_StartTimer(PIT_Type *base, pit_chnl_t channel)
AnnaBridge 143:86740a56073b 309 {
AnnaBridge 143:86740a56073b 310 base->CHANNEL[channel].TCTRL |= PIT_TCTRL_TEN_MASK;
AnnaBridge 143:86740a56073b 311 }
AnnaBridge 143:86740a56073b 312
AnnaBridge 143:86740a56073b 313 /*!
AnnaBridge 143:86740a56073b 314 * @brief Stops the timer counting.
AnnaBridge 143:86740a56073b 315 *
AnnaBridge 143:86740a56073b 316 * This function stops every timer counting. Timers reload their periods
AnnaBridge 143:86740a56073b 317 * respectively after the next time they call the PIT_DRV_StartTimer.
AnnaBridge 143:86740a56073b 318 *
AnnaBridge 143:86740a56073b 319 * @param base PIT peripheral base address
AnnaBridge 143:86740a56073b 320 * @param channel Timer channel number.
AnnaBridge 143:86740a56073b 321 */
AnnaBridge 143:86740a56073b 322 static inline void PIT_StopTimer(PIT_Type *base, pit_chnl_t channel)
AnnaBridge 143:86740a56073b 323 {
AnnaBridge 143:86740a56073b 324 base->CHANNEL[channel].TCTRL &= ~PIT_TCTRL_TEN_MASK;
AnnaBridge 143:86740a56073b 325 }
AnnaBridge 143:86740a56073b 326
AnnaBridge 143:86740a56073b 327 /*! @}*/
AnnaBridge 143:86740a56073b 328
AnnaBridge 143:86740a56073b 329 #if defined(FSL_FEATURE_PIT_HAS_LIFETIME_TIMER) && FSL_FEATURE_PIT_HAS_LIFETIME_TIMER
AnnaBridge 143:86740a56073b 330
AnnaBridge 143:86740a56073b 331 /*!
AnnaBridge 143:86740a56073b 332 * @brief Reads the current lifetime counter value.
AnnaBridge 143:86740a56073b 333 *
AnnaBridge 143:86740a56073b 334 * The lifetime timer is a 64-bit timer which chains timer 0 and timer 1 together.
AnnaBridge 143:86740a56073b 335 * Timer 0 and 1 are chained by calling the PIT_SetTimerChainMode before using this timer.
AnnaBridge 143:86740a56073b 336 * The period of lifetime timer is equal to the "period of timer 0 * period of timer 1".
AnnaBridge 143:86740a56073b 337 * For the 64-bit value, the higher 32-bit has the value of timer 1, and the lower 32-bit
AnnaBridge 143:86740a56073b 338 * has the value of timer 0.
AnnaBridge 143:86740a56073b 339 *
AnnaBridge 143:86740a56073b 340 * @param base PIT peripheral base address
AnnaBridge 143:86740a56073b 341 *
AnnaBridge 143:86740a56073b 342 * @return Current lifetime timer value
AnnaBridge 143:86740a56073b 343 */
AnnaBridge 143:86740a56073b 344 uint64_t PIT_GetLifetimeTimerCount(PIT_Type *base);
AnnaBridge 143:86740a56073b 345
AnnaBridge 143:86740a56073b 346 #endif /* FSL_FEATURE_PIT_HAS_LIFETIME_TIMER */
AnnaBridge 143:86740a56073b 347
AnnaBridge 143:86740a56073b 348 #if defined(__cplusplus)
AnnaBridge 143:86740a56073b 349 }
AnnaBridge 143:86740a56073b 350 #endif
AnnaBridge 143:86740a56073b 351
AnnaBridge 143:86740a56073b 352 /*! @}*/
AnnaBridge 143:86740a56073b 353
AnnaBridge 143:86740a56073b 354 #endif /* _FSL_PIT_H_ */