1 //***************************************************************************** 2 // 3 // timer.h - Prototypes for the timer module 4 // 5 // Copyright (c) 2005-2020 Texas Instruments Incorporated. All rights reserved. 6 // Software License Agreement 7 // 8 // Redistribution and use in source and binary forms, with or without 9 // modification, are permitted provided that the following conditions 10 // are met: 11 // 12 // Redistributions of source code must retain the above copyright 13 // notice, this list of conditions and the following disclaimer. 14 // 15 // Redistributions in binary form must reproduce the above copyright 16 // notice, this list of conditions and the following disclaimer in the 17 // documentation and/or other materials provided with the 18 // distribution. 19 // 20 // Neither the name of Texas Instruments Incorporated nor the names of 21 // its contributors may be used to endorse or promote products derived 22 // from this software without specific prior written permission. 23 // 24 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 25 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 26 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 27 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 28 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 29 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 30 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 31 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 32 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 33 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 34 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 // 36 // This is part of revision 2.2.0.295 of the Tiva Peripheral Driver Library. 37 // 38 //***************************************************************************** 39 40 #ifndef __DRIVERLIB_TIMER_H__ 41 #define __DRIVERLIB_TIMER_H__ 42 43 //***************************************************************************** 44 // 45 // If building with a C++ compiler, make all of the definitions in this header 46 // have a C binding. 47 // 48 //***************************************************************************** 49 #ifdef __cplusplus 50 extern "C" 51 { 52 #endif 53 54 //***************************************************************************** 55 // 56 // Values that can be passed to TimerConfigure as the ui32Config parameter. 57 // 58 //***************************************************************************** 59 #define TIMER_CFG_ONE_SHOT 0x00000021 // Full-width one-shot timer 60 #define TIMER_CFG_ONE_SHOT_UP 0x00000031 // Full-width one-shot up-count 61 // timer 62 #define TIMER_CFG_PERIODIC 0x00000022 // Full-width periodic timer 63 #define TIMER_CFG_PERIODIC_UP 0x00000032 // Full-width periodic up-count 64 // timer 65 #define TIMER_CFG_RTC 0x01000000 // Full-width RTC timer 66 #define TIMER_CFG_SPLIT_PAIR 0x04000000 // Two half-width timers 67 #define TIMER_CFG_A_ONE_SHOT 0x00000021 // Timer A one-shot timer 68 #define TIMER_CFG_A_ONE_SHOT_UP 0x00000031 // Timer A one-shot up-count timer 69 #define TIMER_CFG_A_PERIODIC 0x00000022 // Timer A periodic timer 70 #define TIMER_CFG_A_PERIODIC_UP 0x00000032 // Timer A periodic up-count timer 71 #define TIMER_CFG_A_CAP_COUNT 0x00000003 // Timer A event counter 72 #define TIMER_CFG_A_CAP_COUNT_UP 0x00000013 // Timer A event up-counter 73 #define TIMER_CFG_A_CAP_TIME 0x00000007 // Timer A event timer 74 #define TIMER_CFG_A_CAP_TIME_UP 0x00000017 // Timer A event up-count timer 75 #define TIMER_CFG_A_ONE_SHOT_PWM 0x00000009 // Timer A one-shot PWM output 76 #define TIMER_CFG_A_PWM 0x0000000A // Timer A PWM output 77 #define TIMER_CFG_B_ONE_SHOT 0x00002100 // Timer B one-shot timer 78 #define TIMER_CFG_B_ONE_SHOT_UP 0x00003100 // Timer B one-shot up-count timer 79 #define TIMER_CFG_B_PERIODIC 0x00002200 // Timer B periodic timer 80 #define TIMER_CFG_B_PERIODIC_UP 0x00003200 // Timer B periodic up-count timer 81 #define TIMER_CFG_B_CAP_COUNT 0x00000300 // Timer B event counter 82 #define TIMER_CFG_B_CAP_COUNT_UP 0x00001300 // Timer B event up-counter 83 #define TIMER_CFG_B_CAP_TIME 0x00000700 // Timer B event timer 84 #define TIMER_CFG_B_CAP_TIME_UP 0x00001700 // Timer B event up-count timer 85 #define TIMER_CFG_B_ONE_SHOT_PWM 0x00000900 // Timer B one-shot PWM output 86 #define TIMER_CFG_B_PWM 0x00000A00 // Timer B PWM output 87 #define TIMER_CFG_A_ACT_TOINTD 0x00010000 // Timer A compare action disable 88 // time-out interrupt. 89 #define TIMER_CFG_A_ACT_NONE 0x00000000 // Timer A compare action none. 90 #define TIMER_CFG_A_ACT_TOGGLE 0x00020000 // Timer A compare action toggle. 91 #define TIMER_CFG_A_ACT_CLRTO 0x00040000 // Timer A compare action CCP 92 // clear on time-out. 93 #define TIMER_CFG_A_ACT_SETTO 0x00060000 // Timer A compare action CCP set 94 // on time-out. 95 #define TIMER_CFG_A_ACT_SETTOGTO 0x00080000 // Timer A compare action set CCP 96 // toggle on time-out. 97 #define TIMER_CFG_A_ACT_CLRTOGTO 0x000A0000 // Timer A compare action clear 98 // CCP toggle on time-out. 99 #define TIMER_CFG_A_ACT_SETCLRTO 0x000C0000 // Timer A compare action set CCP 100 // clear on time-out. 101 #define TIMER_CFG_A_ACT_CLRSETTO 0x000E0000 // Timer A compare action clear 102 // CCP set on time-out. 103 #define TIMER_CFG_B_ACT_TOINTD 0x00100000 // Timer B compare action disable 104 // time-out interrupt. 105 #define TIMER_CFG_B_ACT_NONE 0x00000000 // Timer A compare action none. 106 #define TIMER_CFG_B_ACT_TOGGLE 0x00200000 // Timer A compare action toggle. 107 #define TIMER_CFG_B_ACT_CLRTO 0x00400000 // Timer A compare action CCP 108 // clear on time-out. 109 #define TIMER_CFG_B_ACT_SETTO 0x00600000 // Timer A compare action CCP set 110 // on time-out. 111 #define TIMER_CFG_B_ACT_SETTOGTO 0x00800000 // Timer A compare action set CCP 112 // toggle on time-out. 113 #define TIMER_CFG_B_ACT_CLRTOGTO 0x00A00000 // Timer A compare action clear 114 // CCP toggle on time-out. 115 #define TIMER_CFG_B_ACT_SETCLRTO 0x00C00000 // Timer A compare action set CCP 116 // clear on time-out. 117 #define TIMER_CFG_B_ACT_CLRSETTO 0x0000E000 // Timer A compare action clear 118 // CCP set on time-out. 119 120 //***************************************************************************** 121 // 122 // Values that can be passed to TimerIntEnable, TimerIntDisable, and 123 // TimerIntClear as the ui32IntFlags parameter, and returned from 124 // TimerIntStatus. 125 // 126 //***************************************************************************** 127 #define TIMER_TIMB_DMA 0x00002000 // TimerB DMA Complete Interrupt. 128 #define TIMER_TIMB_MATCH 0x00000800 // TimerB match interrupt 129 #define TIMER_CAPB_EVENT 0x00000400 // CaptureB event interrupt 130 #define TIMER_CAPB_MATCH 0x00000200 // CaptureB match interrupt 131 #define TIMER_TIMB_TIMEOUT 0x00000100 // TimerB time out interrupt 132 #define TIMER_TIMA_DMA 0x00000020 // TimerA DMA Complete Interrupt. 133 #define TIMER_TIMA_MATCH 0x00000010 // TimerA match interrupt 134 #define TIMER_RTC_MATCH 0x00000008 // RTC interrupt mask 135 #define TIMER_CAPA_EVENT 0x00000004 // CaptureA event interrupt 136 #define TIMER_CAPA_MATCH 0x00000002 // CaptureA match interrupt 137 #define TIMER_TIMA_TIMEOUT 0x00000001 // TimerA time out interrupt 138 139 //***************************************************************************** 140 // 141 // Values that can be passed to TimerControlEvent as the ui32Event parameter. 142 // 143 //***************************************************************************** 144 #define TIMER_EVENT_POS_EDGE 0x00000000 // Count positive edges 145 #define TIMER_EVENT_NEG_EDGE 0x00000404 // Count negative edges 146 #define TIMER_EVENT_BOTH_EDGES 0x00000C0C // Count both edges 147 148 //***************************************************************************** 149 // 150 // Values that can be passed to most of the timer APIs as the ui32Timer 151 // parameter. 152 // 153 //***************************************************************************** 154 #define TIMER_A 0x000000ff // Timer A 155 #define TIMER_B 0x0000ff00 // Timer B 156 #define TIMER_BOTH 0x0000ffff // Timer Both 157 158 //***************************************************************************** 159 // 160 // Values that can be passed to TimerSynchronize as the ui32Timers parameter. 161 // 162 //***************************************************************************** 163 #define TIMER_0A_SYNC 0x00000001 // Synchronize Timer 0A 164 #define TIMER_0B_SYNC 0x00000002 // Synchronize Timer 0B 165 #define TIMER_1A_SYNC 0x00000004 // Synchronize Timer 1A 166 #define TIMER_1B_SYNC 0x00000008 // Synchronize Timer 1B 167 #define TIMER_2A_SYNC 0x00000010 // Synchronize Timer 2A 168 #define TIMER_2B_SYNC 0x00000020 // Synchronize Timer 2B 169 #define TIMER_3A_SYNC 0x00000040 // Synchronize Timer 3A 170 #define TIMER_3B_SYNC 0x00000080 // Synchronize Timer 3B 171 #define TIMER_4A_SYNC 0x00000100 // Synchronize Timer 4A 172 #define TIMER_4B_SYNC 0x00000200 // Synchronize Timer 4B 173 #define TIMER_5A_SYNC 0x00000400 // Synchronize Timer 5A 174 #define TIMER_5B_SYNC 0x00000800 // Synchronize Timer 5B 175 #define WTIMER_0A_SYNC 0x00001000 // Synchronize Wide Timer 0A 176 #define WTIMER_0B_SYNC 0x00002000 // Synchronize Wide Timer 0B 177 #define WTIMER_1A_SYNC 0x00004000 // Synchronize Wide Timer 1A 178 #define WTIMER_1B_SYNC 0x00008000 // Synchronize Wide Timer 1B 179 #define WTIMER_2A_SYNC 0x00010000 // Synchronize Wide Timer 2A 180 #define WTIMER_2B_SYNC 0x00020000 // Synchronize Wide Timer 2B 181 #define WTIMER_3A_SYNC 0x00040000 // Synchronize Wide Timer 3A 182 #define WTIMER_3B_SYNC 0x00080000 // Synchronize Wide Timer 3B 183 #define WTIMER_4A_SYNC 0x00100000 // Synchronize Wide Timer 4A 184 #define WTIMER_4B_SYNC 0x00200000 // Synchronize Wide Timer 4B 185 #define WTIMER_5A_SYNC 0x00400000 // Synchronize Wide Timer 5A 186 #define WTIMER_5B_SYNC 0x00800000 // Synchronize Wide Timer 5B 187 188 //***************************************************************************** 189 // 190 // Values that can be passed to TimerClockSourceSet() or returned from 191 // TimerClockSourceGet(). 192 // 193 //***************************************************************************** 194 #define TIMER_CLOCK_SYSTEM 0x00000000 195 #define TIMER_CLOCK_PIOSC 0x00000001 196 197 //***************************************************************************** 198 // 199 // Values that can be passed to TimerDMAEventSet() or returned from 200 // TimerDMAEventGet(). 201 // 202 //***************************************************************************** 203 #define TIMER_DMA_MODEMATCH_B 0x00000800 204 #define TIMER_DMA_CAPEVENT_B 0x00000400 205 #define TIMER_DMA_CAPMATCH_B 0x00000200 206 #define TIMER_DMA_TIMEOUT_B 0x00000100 207 #define TIMER_DMA_MODEMATCH_A 0x00000010 208 #define TIMER_DMA_RTC_A 0x00000008 209 #define TIMER_DMA_CAPEVENT_A 0x00000004 210 #define TIMER_DMA_CAPMATCH_A 0x00000002 211 #define TIMER_DMA_TIMEOUT_A 0x00000001 212 213 //***************************************************************************** 214 // 215 // Values that can be passed to TimerADCEventSet() or returned from 216 // TimerADCEventGet(). 217 // 218 //***************************************************************************** 219 #define TIMER_ADC_MODEMATCH_B 0x00000800 220 #define TIMER_ADC_CAPEVENT_B 0x00000400 221 #define TIMER_ADC_CAPMATCH_B 0x00000200 222 #define TIMER_ADC_TIMEOUT_B 0x00000100 223 #define TIMER_ADC_MODEMATCH_A 0x00000010 224 #define TIMER_ADC_RTC_A 0x00000008 225 #define TIMER_ADC_CAPEVENT_A 0x00000004 226 #define TIMER_ADC_CAPMATCH_A 0x00000002 227 #define TIMER_ADC_TIMEOUT_A 0x00000001 228 229 //***************************************************************************** 230 // 231 // Values that can be passed to TimerUpdateMode(). 232 // 233 //***************************************************************************** 234 #define TIMER_UP_LOAD_IMMEDIATE 0x00000000 235 #define TIMER_UP_LOAD_TIMEOUT 0x00000100 236 #define TIMER_UP_MATCH_IMMEDIATE \ 237 0x00000000 238 #define TIMER_UP_MATCH_TIMEOUT 0x00000400 239 240 //***************************************************************************** 241 // 242 // Prototypes for the APIs. 243 // 244 //***************************************************************************** 245 extern void TimerEnable(uint32_t ui32Base, uint32_t ui32Timer); 246 extern void TimerDisable(uint32_t ui32Base, uint32_t ui32Timer); 247 extern void TimerConfigure(uint32_t ui32Base, uint32_t ui32Config); 248 extern void TimerControlLevel(uint32_t ui32Base, uint32_t ui32Timer, 249 bool bInvert); 250 extern void TimerControlTrigger(uint32_t ui32Base, uint32_t ui32Timer, 251 bool bEnable); 252 extern void TimerControlEvent(uint32_t ui32Base, uint32_t ui32Timer, 253 uint32_t ui32Event); 254 extern void TimerControlStall(uint32_t ui32Base, uint32_t ui32Timer, 255 bool bStall); 256 extern void TimerControlWaitOnTrigger(uint32_t ui32Base, uint32_t ui32Timer, 257 bool bWait); 258 extern void TimerRTCEnable(uint32_t ui32Base); 259 extern void TimerRTCDisable(uint32_t ui32Base); 260 extern void TimerPrescaleSet(uint32_t ui32Base, uint32_t ui32Timer, 261 uint32_t ui32Value); 262 extern uint32_t TimerPrescaleGet(uint32_t ui32Base, uint32_t ui32Timer); 263 extern void TimerPrescaleMatchSet(uint32_t ui32Base, uint32_t ui32Timer, 264 uint32_t ui32Value); 265 extern uint32_t TimerPrescaleMatchGet(uint32_t ui32Base, uint32_t ui32Timer); 266 extern void TimerLoadSet(uint32_t ui32Base, uint32_t ui32Timer, 267 uint32_t ui32Value); 268 extern uint32_t TimerLoadGet(uint32_t ui32Base, uint32_t ui32Timer); 269 extern void TimerLoadSet64(uint32_t ui32Base, uint64_t ui64Value); 270 extern uint64_t TimerLoadGet64(uint32_t ui32Base); 271 extern uint32_t TimerValueGet(uint32_t ui32Base, uint32_t ui32Timer); 272 extern uint64_t TimerValueGet64(uint32_t ui32Base); 273 extern void TimerMatchSet(uint32_t ui32Base, uint32_t ui32Timer, 274 uint32_t ui32Value); 275 extern uint32_t TimerMatchGet(uint32_t ui32Base, uint32_t ui32Timer); 276 extern void TimerMatchSet64(uint32_t ui32Base, uint64_t ui64Value); 277 extern uint64_t TimerMatchGet64(uint32_t ui32Base); 278 extern void TimerIntRegister(uint32_t ui32Base, uint32_t ui32Timer, 279 void (*pfnHandler)(void)); 280 extern void TimerIntUnregister(uint32_t ui32Base, uint32_t ui32Timer); 281 extern void TimerIntEnable(uint32_t ui32Base, uint32_t ui32IntFlags); 282 extern void TimerIntDisable(uint32_t ui32Base, uint32_t ui32IntFlags); 283 extern uint32_t TimerIntStatus(uint32_t ui32Base, bool bMasked); 284 extern void TimerIntClear(uint32_t ui32Base, uint32_t ui32IntFlags); 285 extern void TimerSynchronize(uint32_t ui32Base, uint32_t ui32Timers); 286 extern uint32_t TimerClockSourceGet(uint32_t ui32Base); 287 extern void TimerClockSourceSet(uint32_t ui32Base, uint32_t ui32Source); 288 extern uint32_t TimerADCEventGet(uint32_t ui32Base); 289 extern void TimerADCEventSet(uint32_t ui32Base, uint32_t ui32ADCEvent); 290 extern uint32_t TimerDMAEventGet(uint32_t ui32Base); 291 extern void TimerDMAEventSet(uint32_t ui32Base, uint32_t ui32DMAEvent); 292 extern void TimerUpdateMode(uint32_t ui32Base, uint32_t ui32Timer, 293 uint32_t ui32Config); 294 //***************************************************************************** 295 // 296 // Mark the end of the C bindings section for C++ compilers. 297 // 298 //***************************************************************************** 299 #ifdef __cplusplus 300 } 301 #endif 302 303 #endif // __DRIVERLIB_TIMER_H__ 304