1 /* 2 * Copyright (c) 2016, Freescale Semiconductor, Inc. 3 * Copyright 2016-2019, 2021 NXP 4 * All rights reserved. 5 * 6 * SPDX-License-Identifier: BSD-3-Clause 7 */ 8 #ifndef FSL_UTICK_H_ 9 #define FSL_UTICK_H_ 10 11 #include "fsl_common.h" 12 /*! 13 * @addtogroup utick 14 * @{ 15 */ 16 17 /*! @file*/ 18 19 /******************************************************************************* 20 * Definitions 21 ******************************************************************************/ 22 23 /*! @name Driver version */ 24 /*! @{ */ 25 /*! @brief UTICK driver version 2.0.5. */ 26 #define FSL_UTICK_DRIVER_VERSION (MAKE_VERSION(2, 0, 5)) 27 /*! @} */ 28 29 /*! @brief UTICK timer operational mode. */ 30 typedef enum _utick_mode 31 { 32 kUTICK_Onetime = 0x0U, /*!< Trigger once*/ 33 kUTICK_Repeat = 0x1U, /*!< Trigger repeatedly */ 34 } utick_mode_t; 35 36 /*! @brief UTICK callback function. */ 37 typedef void (*utick_callback_t)(void); 38 39 /******************************************************************************* 40 * API 41 ******************************************************************************/ 42 43 #if defined(__cplusplus) 44 extern "C" { 45 #endif /* _cplusplus */ 46 47 /*! 48 * @name Initialization and deinitialization 49 * @{ 50 */ 51 52 /*! 53 * @brief Initializes an UTICK by turning its bus clock on 54 * 55 */ 56 void UTICK_Init(UTICK_Type *base); 57 58 /*! 59 * @brief Deinitializes a UTICK instance. 60 * 61 * This function shuts down Utick bus clock 62 * 63 * @param base UTICK peripheral base address. 64 */ 65 void UTICK_Deinit(UTICK_Type *base); 66 /*! 67 * @brief Get Status Flags. 68 * 69 * This returns the status flag 70 * 71 * @param base UTICK peripheral base address. 72 * @return status register value 73 */ 74 uint32_t UTICK_GetStatusFlags(UTICK_Type *base); 75 /*! 76 * @brief Clear Status Interrupt Flags. 77 * 78 * This clears intr status flag 79 * 80 * @param base UTICK peripheral base address. 81 * @return none 82 */ 83 void UTICK_ClearStatusFlags(UTICK_Type *base); 84 85 /*! 86 * @brief Starts UTICK. 87 * 88 * This function starts a repeat/onetime countdown with an optional callback 89 * 90 * @param base UTICK peripheral base address. 91 * @param mode UTICK timer mode (ie kUTICK_onetime or kUTICK_repeat) 92 * @param count UTICK timer mode (ie kUTICK_onetime or kUTICK_repeat) 93 * @param cb UTICK callback (can be left as NULL if none, otherwise should be a void func(void)) 94 * @return none 95 */ 96 void UTICK_SetTick(UTICK_Type *base, utick_mode_t mode, uint32_t count, utick_callback_t cb); 97 /*! 98 * @brief UTICK Interrupt Service Handler. 99 * 100 * This function handles the interrupt and refers to the callback array in the driver to callback user (as per request 101 * in UTICK_SetTick()). 102 * if no user callback is scheduled, the interrupt will simply be cleared. 103 * 104 * @param base UTICK peripheral base address. 105 * @param cb callback scheduled for this instance of UTICK 106 * @return none 107 */ 108 void UTICK_HandleIRQ(UTICK_Type *base, utick_callback_t cb); 109 110 /*! @} */ 111 112 #if defined(__cplusplus) 113 } 114 #endif 115 116 /*! @}*/ 117 118 #endif /* FSL_UTICK_H_ */ 119