Mouse code for the MacroRat

Dependencies:   ITG3200 QEI

Committer:
sahilmgandhi
Date:
Sat Jun 03 00:22:44 2017 +0000
Revision:
46:b156ef445742
Parent:
18:6a4db94011d3
Final code for internal battlebot competition.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sahilmgandhi 18:6a4db94011d3 1 /**************************************************************************//**
sahilmgandhi 18:6a4db94011d3 2 * @file timer.h
sahilmgandhi 18:6a4db94011d3 3 * @version V1.00
sahilmgandhi 18:6a4db94011d3 4 * $Revision: 6 $
sahilmgandhi 18:6a4db94011d3 5 * $Date: 14/05/29 1:13p $
sahilmgandhi 18:6a4db94011d3 6 * @brief NUC472/NUC442 TIMER driver header file
sahilmgandhi 18:6a4db94011d3 7 *
sahilmgandhi 18:6a4db94011d3 8 * @note
sahilmgandhi 18:6a4db94011d3 9 * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved.
sahilmgandhi 18:6a4db94011d3 10 *****************************************************************************/
sahilmgandhi 18:6a4db94011d3 11 #ifndef __TIMER_H__
sahilmgandhi 18:6a4db94011d3 12 #define __TIMER_H__
sahilmgandhi 18:6a4db94011d3 13
sahilmgandhi 18:6a4db94011d3 14 #ifdef __cplusplus
sahilmgandhi 18:6a4db94011d3 15 extern "C"
sahilmgandhi 18:6a4db94011d3 16 {
sahilmgandhi 18:6a4db94011d3 17 #endif
sahilmgandhi 18:6a4db94011d3 18
sahilmgandhi 18:6a4db94011d3 19
sahilmgandhi 18:6a4db94011d3 20 /** @addtogroup NUC472_442_Device_Driver NUC472/NUC442 Device Driver
sahilmgandhi 18:6a4db94011d3 21 @{
sahilmgandhi 18:6a4db94011d3 22 */
sahilmgandhi 18:6a4db94011d3 23
sahilmgandhi 18:6a4db94011d3 24 /** @addtogroup NUC472_442_TIMER_Driver TIMER Driver
sahilmgandhi 18:6a4db94011d3 25 @{
sahilmgandhi 18:6a4db94011d3 26 */
sahilmgandhi 18:6a4db94011d3 27
sahilmgandhi 18:6a4db94011d3 28 /** @addtogroup NUC472_442_TIMER_EXPORTED_CONSTANTS TIMER Exported Constants
sahilmgandhi 18:6a4db94011d3 29 @{
sahilmgandhi 18:6a4db94011d3 30 */
sahilmgandhi 18:6a4db94011d3 31
sahilmgandhi 18:6a4db94011d3 32 #define TIMER_ONESHOT_MODE (0UL) /*!< Timer working in one shot mode \hideinitializer */
sahilmgandhi 18:6a4db94011d3 33 #define TIMER_PERIODIC_MODE (1UL << TIMER_CTL_OPMODE_Pos) /*!< Timer working in periodic mode \hideinitializer */
sahilmgandhi 18:6a4db94011d3 34 #define TIMER_TOGGLE_MODE (2UL << TIMER_CTL_OPMODE_Pos) /*!< Timer working in toggle mode \hideinitializer */
sahilmgandhi 18:6a4db94011d3 35 #define TIMER_CONTINUOUS_MODE (3UL << TIMER_CTL_OPMODE_Pos) /*!< Timer working in continuous mode \hideinitializer */
sahilmgandhi 18:6a4db94011d3 36 #define TIMER_CAPTURE_FREE_COUNTING_MODE (0UL) /*!< Free counting mode \hideinitializer */
sahilmgandhi 18:6a4db94011d3 37 #define TIMER_CAPTURE_COUNTER_RESET_MODE (TIMER_EXTCTL_CAPFUNCS_Msk) /*!< Counter reset mode \hideinitializer */
sahilmgandhi 18:6a4db94011d3 38 #define TIMER_CAPTURE_FALLING_EDGE (0UL) /*!< Falling edge trigger timer capture \hideinitializer */
sahilmgandhi 18:6a4db94011d3 39 #define TIMER_CAPTURE_RISING_EDGE (1UL << TIMER_EXTCTL_CAPEDGE_Pos) /*!< Rising edge trigger timer capture \hideinitializer */
sahilmgandhi 18:6a4db94011d3 40 #define TIMER_CAPTURE_FALLING_THEN_RISING_EDGE (2UL << TIMER_EXTCTL_CAPEDGE_Pos) /*!< Falling edge then rising edge trigger timer capture \hideinitializer */
sahilmgandhi 18:6a4db94011d3 41 #define TIMER_CAPTURE_RISING_THEN_FALLING_EDGE (3UL << TIMER_EXTCTL_CAPEDGE_Pos) /*!< Rising edge then falling edge trigger timer capture \hideinitializer */
sahilmgandhi 18:6a4db94011d3 42 #define TIMER_COUNTER_RISING_EDGE (TIMER_EXTCTL_CNTPHASE_Msk) /*!< Counter increase on rising edge \hideinitializer */
sahilmgandhi 18:6a4db94011d3 43 #define TIMER_COUNTER_FALLING_EDGE (0UL) /*!< Counter increase on falling edge \hideinitializer */
sahilmgandhi 18:6a4db94011d3 44 #define TIMER_TOGGLE_OUT1 (TIMER_CTL_TOGDIS2_Msk) /*!< Select PB.4, PB.1, PC.6, PC.1 as timer toggle output pin \hideinitializer */
sahilmgandhi 18:6a4db94011d3 45 #define TIMER_TOGGLE_OUT2 (TIMER_CTL_TOGDIS1_Msk) /*!< Select PD.1, PE.8, PE.1, PD.11 as timer toggle output pin \hideinitializer */
sahilmgandhi 18:6a4db94011d3 46
sahilmgandhi 18:6a4db94011d3 47 /*@}*/ /* end of group NUC472_442_TIMER_EXPORTED_CONSTANTS */
sahilmgandhi 18:6a4db94011d3 48
sahilmgandhi 18:6a4db94011d3 49
sahilmgandhi 18:6a4db94011d3 50 /** @addtogroup NUC472_442_TIMER_EXPORTED_FUNCTIONS TIMER Exported Functions
sahilmgandhi 18:6a4db94011d3 51 @{
sahilmgandhi 18:6a4db94011d3 52 */
sahilmgandhi 18:6a4db94011d3 53
sahilmgandhi 18:6a4db94011d3 54 /**
sahilmgandhi 18:6a4db94011d3 55 * @brief This macro is used to set new Timer compared value
sahilmgandhi 18:6a4db94011d3 56 * @param[in] timer The base address of Timer module
sahilmgandhi 18:6a4db94011d3 57 * @param[in] u32Value Timer compare value. Valid values are between 2 to 0xFFFFFF
sahilmgandhi 18:6a4db94011d3 58 * @return None
sahilmgandhi 18:6a4db94011d3 59 * \hideinitializer
sahilmgandhi 18:6a4db94011d3 60 */
sahilmgandhi 18:6a4db94011d3 61 #define TIMER_SET_CMP_VALUE(timer, u32Value) ((timer)->CMP = (u32Value))
sahilmgandhi 18:6a4db94011d3 62
sahilmgandhi 18:6a4db94011d3 63 /**
sahilmgandhi 18:6a4db94011d3 64 * @brief This macro is used to set new Timer prescale value
sahilmgandhi 18:6a4db94011d3 65 * @param[in] timer The base address of Timer module
sahilmgandhi 18:6a4db94011d3 66 * @param[in] u32Value Timer prescale value. Valid values are between 0 to 0xFF
sahilmgandhi 18:6a4db94011d3 67 * @return None
sahilmgandhi 18:6a4db94011d3 68 * @note Clock input is divided by (prescale + 1) before it is fed into timer
sahilmgandhi 18:6a4db94011d3 69 * \hideinitializer
sahilmgandhi 18:6a4db94011d3 70 */
sahilmgandhi 18:6a4db94011d3 71 #define TIMER_SET_PRESCALE_VALUE(timer, u32Value) ((timer)->CTL = ((timer)->CTL & ~TIMER_CTL_PSC_Msk) | (u32Value))
sahilmgandhi 18:6a4db94011d3 72
sahilmgandhi 18:6a4db94011d3 73 /**
sahilmgandhi 18:6a4db94011d3 74 * @brief This macro is used to check if specify Timer is inactive or active
sahilmgandhi 18:6a4db94011d3 75 * @return timer is activate or inactivate
sahilmgandhi 18:6a4db94011d3 76 * @retval 0 Timer 24-bit up counter is inactive
sahilmgandhi 18:6a4db94011d3 77 * @retval 1 Timer 24-bit up counter is active
sahilmgandhi 18:6a4db94011d3 78 * \hideinitializer
sahilmgandhi 18:6a4db94011d3 79 */
sahilmgandhi 18:6a4db94011d3 80 #define TIMER_IS_ACTIVE(timer) ((timer)->CTL & TIMER_CTL_ACTSTS_Msk ? 1 : 0)
sahilmgandhi 18:6a4db94011d3 81
sahilmgandhi 18:6a4db94011d3 82 /**
sahilmgandhi 18:6a4db94011d3 83 * @brief This macro is used to select Timer toggle output pin
sahilmgandhi 18:6a4db94011d3 84 * @param[in] timer The base address of Timer module
sahilmgandhi 18:6a4db94011d3 85 * @param[in] u32ToutSel Toggle output pin selection, valid values are
sahilmgandhi 18:6a4db94011d3 86 * - \ref TIMER_TOGGLE_OUT1
sahilmgandhi 18:6a4db94011d3 87 * - \ref TIMER_TOGGLE_OUT2
sahilmgandhi 18:6a4db94011d3 88 * @return None
sahilmgandhi 18:6a4db94011d3 89 * \hideinitializer
sahilmgandhi 18:6a4db94011d3 90 */
sahilmgandhi 18:6a4db94011d3 91 #define TIMER_SELECT_TOUT_PIN(timer, u32ToutSel) ((timer)->CTL = ((timer)->CTL & ~(TIMER_CTL_TOGDIS2_Msk | TIMER_CTL_TOGDIS1_Msk)) | (u32ToutSel))
sahilmgandhi 18:6a4db94011d3 92
sahilmgandhi 18:6a4db94011d3 93
sahilmgandhi 18:6a4db94011d3 94 /**
sahilmgandhi 18:6a4db94011d3 95 * @brief This function is used to start Timer counting
sahilmgandhi 18:6a4db94011d3 96 * @param[in] timer The base address of Timer module
sahilmgandhi 18:6a4db94011d3 97 * @return None
sahilmgandhi 18:6a4db94011d3 98 */
sahilmgandhi 18:6a4db94011d3 99 __STATIC_INLINE void TIMER_Start(TIMER_T *timer)
sahilmgandhi 18:6a4db94011d3 100 {
sahilmgandhi 18:6a4db94011d3 101 timer->CTL |= TIMER_CTL_CNTEN_Msk;
sahilmgandhi 18:6a4db94011d3 102 }
sahilmgandhi 18:6a4db94011d3 103
sahilmgandhi 18:6a4db94011d3 104 /**
sahilmgandhi 18:6a4db94011d3 105 * @brief This function is used to stop Timer counting
sahilmgandhi 18:6a4db94011d3 106 * @param[in] timer The base address of Timer module
sahilmgandhi 18:6a4db94011d3 107 * @return None
sahilmgandhi 18:6a4db94011d3 108 */
sahilmgandhi 18:6a4db94011d3 109 __STATIC_INLINE void TIMER_Stop(TIMER_T *timer)
sahilmgandhi 18:6a4db94011d3 110 {
sahilmgandhi 18:6a4db94011d3 111 timer->CTL &= ~TIMER_CTL_CNTEN_Msk;
sahilmgandhi 18:6a4db94011d3 112 }
sahilmgandhi 18:6a4db94011d3 113
sahilmgandhi 18:6a4db94011d3 114 /**
sahilmgandhi 18:6a4db94011d3 115 * @brief This function is used to enable the Timer wake-up function
sahilmgandhi 18:6a4db94011d3 116 * @param[in] timer The base address of Timer module
sahilmgandhi 18:6a4db94011d3 117 * @return None
sahilmgandhi 18:6a4db94011d3 118 * @note To wake the system from power down mode, timer clock source must be ether LXT or LIRC
sahilmgandhi 18:6a4db94011d3 119 */
sahilmgandhi 18:6a4db94011d3 120 __STATIC_INLINE void TIMER_EnableWakeup(TIMER_T *timer)
sahilmgandhi 18:6a4db94011d3 121 {
sahilmgandhi 18:6a4db94011d3 122 timer->CTL |= TIMER_CTL_WKEN_Msk;
sahilmgandhi 18:6a4db94011d3 123 }
sahilmgandhi 18:6a4db94011d3 124
sahilmgandhi 18:6a4db94011d3 125 /**
sahilmgandhi 18:6a4db94011d3 126 * @brief This function is used to disable the Timer wake-up function
sahilmgandhi 18:6a4db94011d3 127 * @param[in] timer The base address of Timer module
sahilmgandhi 18:6a4db94011d3 128 * @return None
sahilmgandhi 18:6a4db94011d3 129 */
sahilmgandhi 18:6a4db94011d3 130 __STATIC_INLINE void TIMER_DisableWakeup(TIMER_T *timer)
sahilmgandhi 18:6a4db94011d3 131 {
sahilmgandhi 18:6a4db94011d3 132 timer->CTL &= ~TIMER_CTL_WKEN_Msk;
sahilmgandhi 18:6a4db94011d3 133 }
sahilmgandhi 18:6a4db94011d3 134
sahilmgandhi 18:6a4db94011d3 135
sahilmgandhi 18:6a4db94011d3 136 /**
sahilmgandhi 18:6a4db94011d3 137 * @brief This function is used to enable the capture pin detection de-bounce function.
sahilmgandhi 18:6a4db94011d3 138 * @param[in] timer The base address of Timer module
sahilmgandhi 18:6a4db94011d3 139 * @return None
sahilmgandhi 18:6a4db94011d3 140 */
sahilmgandhi 18:6a4db94011d3 141 __STATIC_INLINE void TIMER_EnableCaptureDebounce(TIMER_T *timer)
sahilmgandhi 18:6a4db94011d3 142 {
sahilmgandhi 18:6a4db94011d3 143 timer->EXTCTL |= TIMER_EXTCTL_CAPDBEN_Msk;
sahilmgandhi 18:6a4db94011d3 144 }
sahilmgandhi 18:6a4db94011d3 145
sahilmgandhi 18:6a4db94011d3 146 /**
sahilmgandhi 18:6a4db94011d3 147 * @brief This function is used to disable the capture pin detection de-bounce function.
sahilmgandhi 18:6a4db94011d3 148 * @param[in] timer The base address of Timer module
sahilmgandhi 18:6a4db94011d3 149 * @return None
sahilmgandhi 18:6a4db94011d3 150 */
sahilmgandhi 18:6a4db94011d3 151 __STATIC_INLINE void TIMER_DisableCaptureDebounce(TIMER_T *timer)
sahilmgandhi 18:6a4db94011d3 152 {
sahilmgandhi 18:6a4db94011d3 153 timer->EXTCTL &= ~TIMER_EXTCTL_CAPDBEN_Msk;
sahilmgandhi 18:6a4db94011d3 154 }
sahilmgandhi 18:6a4db94011d3 155
sahilmgandhi 18:6a4db94011d3 156
sahilmgandhi 18:6a4db94011d3 157 /**
sahilmgandhi 18:6a4db94011d3 158 * @brief This function is used to enable the counter pin detection de-bounce function.
sahilmgandhi 18:6a4db94011d3 159 * @param[in] timer The base address of Timer module
sahilmgandhi 18:6a4db94011d3 160 * @return None
sahilmgandhi 18:6a4db94011d3 161 */
sahilmgandhi 18:6a4db94011d3 162 __STATIC_INLINE void TIMER_EnableEventCounterDebounce(TIMER_T *timer)
sahilmgandhi 18:6a4db94011d3 163 {
sahilmgandhi 18:6a4db94011d3 164 timer->EXTCTL |= TIMER_EXTCTL_ECNTDBEN_Msk;
sahilmgandhi 18:6a4db94011d3 165 }
sahilmgandhi 18:6a4db94011d3 166
sahilmgandhi 18:6a4db94011d3 167 /**
sahilmgandhi 18:6a4db94011d3 168 * @brief This function is used to disable the counter pin detection de-bounce function.
sahilmgandhi 18:6a4db94011d3 169 * @param[in] timer The base address of Timer module
sahilmgandhi 18:6a4db94011d3 170 * @return None
sahilmgandhi 18:6a4db94011d3 171 */
sahilmgandhi 18:6a4db94011d3 172 __STATIC_INLINE void TIMER_DisableEventCounterDebounce(TIMER_T *timer)
sahilmgandhi 18:6a4db94011d3 173 {
sahilmgandhi 18:6a4db94011d3 174 timer->EXTCTL &= ~TIMER_EXTCTL_ECNTDBEN_Msk;
sahilmgandhi 18:6a4db94011d3 175 }
sahilmgandhi 18:6a4db94011d3 176
sahilmgandhi 18:6a4db94011d3 177 /**
sahilmgandhi 18:6a4db94011d3 178 * @brief This function is used to enable the Timer time-out interrupt function.
sahilmgandhi 18:6a4db94011d3 179 * @param[in] timer The base address of Timer module
sahilmgandhi 18:6a4db94011d3 180 * @return None
sahilmgandhi 18:6a4db94011d3 181 */
sahilmgandhi 18:6a4db94011d3 182 __STATIC_INLINE void TIMER_EnableInt(TIMER_T *timer)
sahilmgandhi 18:6a4db94011d3 183 {
sahilmgandhi 18:6a4db94011d3 184 timer->CTL |= TIMER_CTL_INTEN_Msk;
sahilmgandhi 18:6a4db94011d3 185 }
sahilmgandhi 18:6a4db94011d3 186
sahilmgandhi 18:6a4db94011d3 187 /**
sahilmgandhi 18:6a4db94011d3 188 * @brief This function is used to disable the Timer time-out interrupt function.
sahilmgandhi 18:6a4db94011d3 189 * @param[in] timer The base address of Timer module
sahilmgandhi 18:6a4db94011d3 190 * @return None
sahilmgandhi 18:6a4db94011d3 191 */
sahilmgandhi 18:6a4db94011d3 192 __STATIC_INLINE void TIMER_DisableInt(TIMER_T *timer)
sahilmgandhi 18:6a4db94011d3 193 {
sahilmgandhi 18:6a4db94011d3 194 timer->CTL &= ~TIMER_CTL_INTEN_Msk;
sahilmgandhi 18:6a4db94011d3 195 }
sahilmgandhi 18:6a4db94011d3 196
sahilmgandhi 18:6a4db94011d3 197 /**
sahilmgandhi 18:6a4db94011d3 198 * @brief This function is used to enable the Timer capture trigger interrupt function.
sahilmgandhi 18:6a4db94011d3 199 * @param[in] timer The base address of Timer module
sahilmgandhi 18:6a4db94011d3 200 * @return None
sahilmgandhi 18:6a4db94011d3 201 */
sahilmgandhi 18:6a4db94011d3 202 __STATIC_INLINE void TIMER_EnableCaptureInt(TIMER_T *timer)
sahilmgandhi 18:6a4db94011d3 203 {
sahilmgandhi 18:6a4db94011d3 204 timer->EXTCTL |= TIMER_EXTCTL_CAPIEN_Msk;
sahilmgandhi 18:6a4db94011d3 205 }
sahilmgandhi 18:6a4db94011d3 206
sahilmgandhi 18:6a4db94011d3 207 /**
sahilmgandhi 18:6a4db94011d3 208 * @brief This function is used to disable the Timer capture trigger interrupt function.
sahilmgandhi 18:6a4db94011d3 209 * @param[in] timer The base address of Timer module
sahilmgandhi 18:6a4db94011d3 210 * @return None
sahilmgandhi 18:6a4db94011d3 211 */
sahilmgandhi 18:6a4db94011d3 212 __STATIC_INLINE void TIMER_DisableCaptureInt(TIMER_T *timer)
sahilmgandhi 18:6a4db94011d3 213 {
sahilmgandhi 18:6a4db94011d3 214 timer->EXTCTL &= ~TIMER_EXTCTL_CAPIEN_Msk;
sahilmgandhi 18:6a4db94011d3 215 }
sahilmgandhi 18:6a4db94011d3 216
sahilmgandhi 18:6a4db94011d3 217 /**
sahilmgandhi 18:6a4db94011d3 218 * @brief This function indicates Timer time-out interrupt occurred or not.
sahilmgandhi 18:6a4db94011d3 219 * @param[in] timer The base address of Timer module
sahilmgandhi 18:6a4db94011d3 220 * @return Timer time-out interrupt occurred or not
sahilmgandhi 18:6a4db94011d3 221 * @retval 0 Timer time-out interrupt did not occur
sahilmgandhi 18:6a4db94011d3 222 * @retval 1 Timer time-out interrupt occurred
sahilmgandhi 18:6a4db94011d3 223 */
sahilmgandhi 18:6a4db94011d3 224 __STATIC_INLINE uint32_t TIMER_GetIntFlag(TIMER_T *timer)
sahilmgandhi 18:6a4db94011d3 225 {
sahilmgandhi 18:6a4db94011d3 226 return(timer->INTSTS & TIMER_INTSTS_TIF_Msk ? 1 : 0);
sahilmgandhi 18:6a4db94011d3 227 }
sahilmgandhi 18:6a4db94011d3 228
sahilmgandhi 18:6a4db94011d3 229 /**
sahilmgandhi 18:6a4db94011d3 230 * @brief This function clears the Timer time-out interrupt flag.
sahilmgandhi 18:6a4db94011d3 231 * @param[in] timer The base address of Timer module
sahilmgandhi 18:6a4db94011d3 232 * @return None
sahilmgandhi 18:6a4db94011d3 233 */
sahilmgandhi 18:6a4db94011d3 234 __STATIC_INLINE void TIMER_ClearIntFlag(TIMER_T *timer)
sahilmgandhi 18:6a4db94011d3 235 {
sahilmgandhi 18:6a4db94011d3 236 timer->INTSTS = TIMER_INTSTS_TIF_Msk;
sahilmgandhi 18:6a4db94011d3 237 }
sahilmgandhi 18:6a4db94011d3 238
sahilmgandhi 18:6a4db94011d3 239 /**
sahilmgandhi 18:6a4db94011d3 240 * @brief This function indicates Timer capture interrupt occurred or not.
sahilmgandhi 18:6a4db94011d3 241 * @param[in] timer The base address of Timer module
sahilmgandhi 18:6a4db94011d3 242 * @return Timer capture interrupt occurred or not
sahilmgandhi 18:6a4db94011d3 243 * @retval 0 Timer capture interrupt did not occur
sahilmgandhi 18:6a4db94011d3 244 * @retval 1 Timer capture interrupt occurred
sahilmgandhi 18:6a4db94011d3 245 */
sahilmgandhi 18:6a4db94011d3 246 __STATIC_INLINE uint32_t TIMER_GetCaptureIntFlag(TIMER_T *timer)
sahilmgandhi 18:6a4db94011d3 247 {
sahilmgandhi 18:6a4db94011d3 248 return timer->EINTSTS;
sahilmgandhi 18:6a4db94011d3 249 }
sahilmgandhi 18:6a4db94011d3 250
sahilmgandhi 18:6a4db94011d3 251 /**
sahilmgandhi 18:6a4db94011d3 252 * @brief This function clears the Timer capture interrupt flag.
sahilmgandhi 18:6a4db94011d3 253 * @param[in] timer The base address of Timer module
sahilmgandhi 18:6a4db94011d3 254 * @return None
sahilmgandhi 18:6a4db94011d3 255 */
sahilmgandhi 18:6a4db94011d3 256 __STATIC_INLINE void TIMER_ClearCaptureIntFlag(TIMER_T *timer)
sahilmgandhi 18:6a4db94011d3 257 {
sahilmgandhi 18:6a4db94011d3 258 timer->EINTSTS = TIMER_EINTSTS_CAPIF_Msk;
sahilmgandhi 18:6a4db94011d3 259 }
sahilmgandhi 18:6a4db94011d3 260
sahilmgandhi 18:6a4db94011d3 261 /**
sahilmgandhi 18:6a4db94011d3 262 * @brief This function indicates Timer has waked up system or not.
sahilmgandhi 18:6a4db94011d3 263 * @param[in] timer The base address of Timer module
sahilmgandhi 18:6a4db94011d3 264 * @return Timer has waked up system or not
sahilmgandhi 18:6a4db94011d3 265 * @retval 0 Timer did not wake up system
sahilmgandhi 18:6a4db94011d3 266 * @retval 1 Timer wake up system
sahilmgandhi 18:6a4db94011d3 267 */
sahilmgandhi 18:6a4db94011d3 268 __STATIC_INLINE uint32_t TIMER_GetWakeupFlag(TIMER_T *timer)
sahilmgandhi 18:6a4db94011d3 269 {
sahilmgandhi 18:6a4db94011d3 270 return (timer->INTSTS & TIMER_INTSTS_TWKF_Msk ? 1 : 0);
sahilmgandhi 18:6a4db94011d3 271 }
sahilmgandhi 18:6a4db94011d3 272
sahilmgandhi 18:6a4db94011d3 273 /**
sahilmgandhi 18:6a4db94011d3 274 * @brief This function clears the Timer wakeup interrupt flag.
sahilmgandhi 18:6a4db94011d3 275 * @param[in] timer The base address of Timer module
sahilmgandhi 18:6a4db94011d3 276 * @return None
sahilmgandhi 18:6a4db94011d3 277 */
sahilmgandhi 18:6a4db94011d3 278 __STATIC_INLINE void TIMER_ClearWakeupFlag(TIMER_T *timer)
sahilmgandhi 18:6a4db94011d3 279 {
sahilmgandhi 18:6a4db94011d3 280 timer->INTSTS = TIMER_INTSTS_TWKF_Msk;
sahilmgandhi 18:6a4db94011d3 281 }
sahilmgandhi 18:6a4db94011d3 282
sahilmgandhi 18:6a4db94011d3 283 /**
sahilmgandhi 18:6a4db94011d3 284 * @brief This function gets the Timer capture data.
sahilmgandhi 18:6a4db94011d3 285 * @param[in] timer The base address of Timer module
sahilmgandhi 18:6a4db94011d3 286 * @return Timer capture data value
sahilmgandhi 18:6a4db94011d3 287 */
sahilmgandhi 18:6a4db94011d3 288 __STATIC_INLINE uint32_t TIMER_GetCaptureData(TIMER_T *timer)
sahilmgandhi 18:6a4db94011d3 289 {
sahilmgandhi 18:6a4db94011d3 290 return timer->CAP;
sahilmgandhi 18:6a4db94011d3 291 }
sahilmgandhi 18:6a4db94011d3 292
sahilmgandhi 18:6a4db94011d3 293 /**
sahilmgandhi 18:6a4db94011d3 294 * @brief This function reports the current timer counter value.
sahilmgandhi 18:6a4db94011d3 295 * @param[in] timer The base address of Timer module
sahilmgandhi 18:6a4db94011d3 296 * @return Timer counter value
sahilmgandhi 18:6a4db94011d3 297 */
sahilmgandhi 18:6a4db94011d3 298 __STATIC_INLINE uint32_t TIMER_GetCounter(TIMER_T *timer)
sahilmgandhi 18:6a4db94011d3 299 {
sahilmgandhi 18:6a4db94011d3 300 return timer->CNT;
sahilmgandhi 18:6a4db94011d3 301 }
sahilmgandhi 18:6a4db94011d3 302
sahilmgandhi 18:6a4db94011d3 303 uint32_t TIMER_Open(TIMER_T *timer, uint32_t u32Mode, uint32_t u32Freq);
sahilmgandhi 18:6a4db94011d3 304 void TIMER_Close(TIMER_T *timer);
sahilmgandhi 18:6a4db94011d3 305 void TIMER_Delay(TIMER_T *timer, uint32_t u32Usec);
sahilmgandhi 18:6a4db94011d3 306 void TIMER_EnableCapture(TIMER_T *timer, uint32_t u32CapMode, uint32_t u32Edge);
sahilmgandhi 18:6a4db94011d3 307 void TIMER_DisableCapture(TIMER_T *timer);
sahilmgandhi 18:6a4db94011d3 308 void TIMER_EnableEventCounter(TIMER_T *timer, uint32_t u32Edge);
sahilmgandhi 18:6a4db94011d3 309 void TIMER_DisableEventCounter(TIMER_T *timer);
sahilmgandhi 18:6a4db94011d3 310 uint32_t TIMER_GetModuleClock(TIMER_T *timer);
sahilmgandhi 18:6a4db94011d3 311
sahilmgandhi 18:6a4db94011d3 312
sahilmgandhi 18:6a4db94011d3 313 /*@}*/ /* end of group NUC472_442_TIMER_EXPORTED_FUNCTIONS */
sahilmgandhi 18:6a4db94011d3 314
sahilmgandhi 18:6a4db94011d3 315 /*@}*/ /* end of group NUC472_442_TIMER_Driver */
sahilmgandhi 18:6a4db94011d3 316
sahilmgandhi 18:6a4db94011d3 317 /*@}*/ /* end of group NUC472_442_Device_Driver */
sahilmgandhi 18:6a4db94011d3 318
sahilmgandhi 18:6a4db94011d3 319 #ifdef __cplusplus
sahilmgandhi 18:6a4db94011d3 320 }
sahilmgandhi 18:6a4db94011d3 321 #endif
sahilmgandhi 18:6a4db94011d3 322
sahilmgandhi 18:6a4db94011d3 323 #endif //__TIMER_H__
sahilmgandhi 18:6a4db94011d3 324
sahilmgandhi 18:6a4db94011d3 325 /*** (C) COPYRIGHT 2013 Nuvoton Technology Corp. ***/