1 /******************************************************************************
2 *  Filename:       timer.h
3 *  Revised:        2017-05-23 12:08:52 +0200 (Tue, 23 May 2017)
4 *  Revision:       49048
5 *
6 *  Copyright (c) 2015 - 2020, Texas Instruments Incorporated
7 *  All rights reserved.
8 *
9 *  Redistribution and use in source and binary forms, with or without
10 *  modification, are permitted provided that the following conditions are met:
11 *
12 *  1) Redistributions of source code must retain the above copyright notice,
13 *     this list of conditions and the following disclaimer.
14 *
15 *  2) Redistributions in binary form must reproduce the above copyright notice,
16 *     this list of conditions and the following disclaimer in the documentation
17 *     and/or other materials provided with the distribution.
18 *
19 *  3) Neither the name of the ORGANIZATION nor the names of its contributors may
20 *     be used to endorse or promote products derived from this software without
21 *     specific prior written permission.
22 *
23 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24 *  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 *  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 *  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
27 *  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 *  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29 *  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30 *  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31 *  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32 *  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 *  POSSIBILITY OF SUCH DAMAGE.
34 *
35 ******************************************************************************/
36 
37 //****************************************************************************
38 //
39 //! \addtogroup peripheral_group
40 //! @{
41 //! \addtogroup timer_api
42 //! @{
43 //
44 //****************************************************************************
45 
46 #ifndef __GPT_H__
47 #define __GPT_H__
48 
49 //*****************************************************************************
50 //
51 // If building with a C++ compiler, make all of the definitions in this header
52 // have a C binding.
53 //
54 //*****************************************************************************
55 #ifdef __cplusplus
56 extern "C"
57 {
58 #endif
59 
60 #include <stdbool.h>
61 #include <stdint.h>
62 #include "../inc/hw_ints.h"
63 #include "../inc/hw_types.h"
64 #include "../inc/hw_memmap.h"
65 #include "../inc/hw_gpt.h"
66 #include "interrupt.h"
67 #include "debug.h"
68 
69 //*****************************************************************************
70 //
71 // Support for DriverLib in ROM:
72 // This section renames all functions that are not "static inline", so that
73 // calling these functions will default to implementation in flash. At the end
74 // of this file a second renaming will change the defaults to implementation in
75 // ROM for available functions.
76 //
77 // To force use of the implementation in flash, e.g. for debugging:
78 // - Globally: Define DRIVERLIB_NOROM at project level
79 // - Per function: Use prefix "NOROM_" when calling the function
80 //
81 //*****************************************************************************
82 #if !defined(DOXYGEN)
83     #define TimerConfigure                  NOROM_TimerConfigure
84     #define TimerLevelControl               NOROM_TimerLevelControl
85     #define TimerStallControl               NOROM_TimerStallControl
86     #define TimerWaitOnTriggerControl       NOROM_TimerWaitOnTriggerControl
87     #define TimerIntRegister                NOROM_TimerIntRegister
88     #define TimerIntUnregister              NOROM_TimerIntUnregister
89     #define TimerMatchUpdateMode            NOROM_TimerMatchUpdateMode
90     #define TimerIntervalLoadMode           NOROM_TimerIntervalLoadMode
91 #endif
92 
93 //*****************************************************************************
94 //
95 // Values that can be passed to TimerConfigure as the ui32Config parameter.
96 //
97 //*****************************************************************************
98 #define TIMER_CFG_ONE_SHOT        0x00000021  // Full-width one-shot timer
99 #define TIMER_CFG_ONE_SHOT_UP     0x00000031  // Full-width one-shot up-count timer
100 #define TIMER_CFG_PERIODIC        0x00000022  // Full-width periodic timer
101 #define TIMER_CFG_PERIODIC_UP     0x00000032  // Full-width periodic up-count timer
102 #define TIMER_CFG_SPLIT_PAIR      0x04000000  // Two half-width timers
103 #define TIMER_CFG_A_ONE_SHOT      0x00000021  // Timer A one-shot timer
104 #define TIMER_CFG_A_ONE_SHOT_UP   0x00000031  // Timer A one-shot up-count timer
105 #define TIMER_CFG_A_PERIODIC      0x00000022  // Timer A periodic timer
106 #define TIMER_CFG_A_PERIODIC_UP   0x00000032  // Timer A periodic up-count timer
107 #define TIMER_CFG_A_CAP_COUNT     0x00000003  // Timer A event counter
108 #define TIMER_CFG_A_CAP_COUNT_UP  0x00000013  // Timer A event up-counter
109 #define TIMER_CFG_A_CAP_TIME      0x00000007  // Timer A event timer
110 #define TIMER_CFG_A_CAP_TIME_UP   0x00000017  // Timer A event up-count timer
111 #define TIMER_CFG_A_PWM           0x0000000A  // Timer A PWM output
112 #define TIMER_CFG_B_ONE_SHOT      0x00002100  // Timer B one-shot timer
113 #define TIMER_CFG_B_ONE_SHOT_UP   0x00003100  // Timer B one-shot up-count timer
114 #define TIMER_CFG_B_PERIODIC      0x00002200  // Timer B periodic timer
115 #define TIMER_CFG_B_PERIODIC_UP   0x00003200  // Timer B periodic up-count timer
116 #define TIMER_CFG_B_CAP_COUNT     0x00000300  // Timer B event counter
117 #define TIMER_CFG_B_CAP_COUNT_UP  0x00001300  // Timer B event up-counter
118 #define TIMER_CFG_B_CAP_TIME      0x00000700  // Timer B event timer
119 #define TIMER_CFG_B_CAP_TIME_UP   0x00001700  // Timer B event up-count timer
120 #define TIMER_CFG_B_PWM           0x00000A00  // Timer B PWM output
121 
122 //*****************************************************************************
123 //
124 // Values that can be passed to TimerIntEnable, TimerIntDisable, and
125 // TimerIntClear as the ui32IntFlags parameter, and returned from
126 // TimerIntStatus.
127 //
128 //*****************************************************************************
129 #define TIMER_TIMB_DMA            0x00002000  // TimerB DMA Done interrupt
130 #define TIMER_TIMB_MATCH          0x00000800  // TimerB match interrupt
131 #define TIMER_CAPB_EVENT          0x00000400  // CaptureB event interrupt
132 #define TIMER_CAPB_MATCH          0x00000200  // CaptureB match interrupt
133 #define TIMER_TIMB_TIMEOUT        0x00000100  // TimerB time out interrupt
134 #define TIMER_TIMA_DMA            0x00000020  // TimerA DMA Done interrupt
135 #define TIMER_TIMA_MATCH          0x00000010  // TimerA match interrupt
136 #define TIMER_CAPA_EVENT          0x00000004  // CaptureA event interrupt
137 #define TIMER_CAPA_MATCH          0x00000002  // CaptureA match interrupt
138 #define TIMER_TIMA_TIMEOUT        0x00000001  // TimerA time out interrupt
139 
140 //*****************************************************************************
141 //
142 // Values that can be passed to TimerControlEvent as the ui32Event parameter.
143 //
144 //*****************************************************************************
145 #define TIMER_EVENT_POS_EDGE      0x00000000  // Count positive edges
146 #define TIMER_EVENT_NEG_EDGE      0x00000404  // Count negative edges
147 #define TIMER_EVENT_BOTH_EDGES    0x00000C0C  // Count both edges
148 
149 //*****************************************************************************
150 //
151 // Values that can be passed to most of the timer APIs as the ui32Timer
152 // parameter.
153 //
154 //*****************************************************************************
155 #define TIMER_A                   0x000000FF  // Timer A
156 #define TIMER_B                   0x0000FF00  // Timer B
157 #define TIMER_BOTH                0x0000FFFF  // Timer Both
158 
159 //*****************************************************************************
160 //
161 // Values that can be passed to GPTSynchronize as the ui32Timers parameter
162 //
163 //*****************************************************************************
164 #define TIMER_0A_SYNC             0x00000001  // Synchronize Timer 0A
165 #define TIMER_0B_SYNC             0x00000002  // Synchronize Timer 0B
166 #define TIMER_1A_SYNC             0x00000004  // Synchronize Timer 1A
167 #define TIMER_1B_SYNC             0x00000008  // Synchronize Timer 1B
168 #define TIMER_2A_SYNC             0x00000010  // Synchronize Timer 2A
169 #define TIMER_2B_SYNC             0x00000020  // Synchronize Timer 2B
170 #define TIMER_3A_SYNC             0x00000040  // Synchronize Timer 3A
171 #define TIMER_3B_SYNC             0x00000080  // Synchronize Timer 3B
172 
173 //*****************************************************************************
174 //
175 // Values that can be passed to TimerMatchUpdateMode
176 //
177 //*****************************************************************************
178 #define TIMER_MATCHUPDATE_NEXTCYCLE  0x00000000 // Apply match register on next cycle
179 #define TIMER_MATCHUPDATE_TIMEOUT    0x00000001 // Apply match register on next timeout
180 
181 //*****************************************************************************
182 //
183 // Values that can be passed to TimerIntervalLoad
184 //
185 //*****************************************************************************
186 #define TIMER_INTERVALLOAD_NEXTCYCLE  0x00000000 // Load TxR register with the value in the TxILR register on the next clock cycle
187 #define TIMER_INTERVALLOAD_TIMEOUT    0x00000001 // Load TxR register with the value in the TxILR register on next timeout
188 
189 //*****************************************************************************
190 //
191 // API Functions and prototypes
192 //
193 //*****************************************************************************
194 
195 #ifdef DRIVERLIB_DEBUG
196 //*****************************************************************************
197 //
198 //! \internal
199 //!
200 //! \brief Checks a timer base address.
201 //!
202 //! This function determines if a timer module base address is valid.
203 //!
204 //! \param ui32Base is the base address of the timer module.
205 //!
206 //! \return Returns \c true if the base address is valid and \c false
207 //! otherwise.
208 //
209 //*****************************************************************************
210 static bool
TimerBaseValid(uint32_t ui32Base)211 TimerBaseValid(uint32_t ui32Base)
212 {
213     return((ui32Base == GPT0_BASE) || (ui32Base == GPT1_BASE) ||
214            (ui32Base == GPT2_BASE) || (ui32Base == GPT3_BASE));
215 }
216 #endif
217 
218 //*****************************************************************************
219 //
220 //! \brief Enables the timer(s).
221 //!
222 //! This function enables operation of the timer module. The timer must be
223 //! configured before it is enabled.
224 //!
225 //! \param ui32Base is the base address of the timer module.
226 //! \param ui32Timer specifies the timer(s) to enable. Must be one of:
227 //! - \ref TIMER_A
228 //! - \ref TIMER_B
229 //! - \ref TIMER_BOTH
230 //!
231 //! \return None
232 //
233 //*****************************************************************************
234 __STATIC_INLINE void
TimerEnable(uint32_t ui32Base,uint32_t ui32Timer)235 TimerEnable(uint32_t ui32Base, uint32_t ui32Timer)
236 {
237     // Check the arguments.
238     ASSERT(TimerBaseValid(ui32Base));
239     ASSERT((ui32Timer == TIMER_A) || (ui32Timer == TIMER_B) ||
240            (ui32Timer == TIMER_BOTH));
241 
242     // Enable the timer(s) module.
243     HWREG(ui32Base + GPT_O_CTL) |= ui32Timer & (GPT_CTL_TAEN | GPT_CTL_TBEN);
244 }
245 
246 //*****************************************************************************
247 //
248 //! \brief Disables the timer(s).
249 //!
250 //! This function disables operation of the timer module.
251 //!
252 //! \param ui32Base is the base address of the timer module.
253 //! \param ui32Timer specifies the timer(s) to disable. Must be one of:
254 //! - \ref TIMER_A
255 //! - \ref TIMER_B
256 //! - \ref TIMER_BOTH
257 //!
258 //! \return None
259 //
260 //*****************************************************************************
261 __STATIC_INLINE void
TimerDisable(uint32_t ui32Base,uint32_t ui32Timer)262 TimerDisable(uint32_t ui32Base, uint32_t ui32Timer)
263 {
264     // Check the arguments.
265     ASSERT(TimerBaseValid(ui32Base));
266     ASSERT((ui32Timer == TIMER_A) || (ui32Timer == TIMER_B) ||
267            (ui32Timer == TIMER_BOTH));
268 
269     // Disable the timer module.
270     HWREG(ui32Base + GPT_O_CTL) &= ~(ui32Timer &
271                                      (GPT_CTL_TAEN | GPT_CTL_TBEN));
272 }
273 
274 //*****************************************************************************
275 //
276 //! \brief Configures the timer(s).
277 //!
278 //! This function configures the operating mode of the timer(s). The timer
279 //! module is disabled before being configured and is left in the disabled
280 //! state.
281 //!
282 //! The timers are comprised of two 16-bit timers that can
283 //! operate independently or be concatenated to form a 32-bit timer.
284 //!
285 //! \note If the timers are used independently the length of timer can be
286 //! extended to 24 bit by use of an 8 bit prescale register set using
287 //! \ref TimerPrescaleSet().
288 //!
289 //! When configuring for full-width timer \c ui32Config is set
290 //! as one of the following values:
291 //! - \ref TIMER_CFG_ONE_SHOT    : Full-width one-shot timer.
292 //! - \ref TIMER_CFG_ONE_SHOT_UP : Full-width one-shot timer that counts up
293 //!   instead of down.
294 //! - \ref TIMER_CFG_PERIODIC    : Full-width periodic timer.
295 //! - \ref TIMER_CFG_PERIODIC_UP : Full-width periodic timer that counts up
296 //!   instead of down.
297 //!
298 //! When configuring for a pair of half-width timers, each timer is separately
299 //! configured. The timers are configured by setting \c ui32Config to
300 //! the bitwise OR of one of each of the following three:
301 //! - Use half-width timers:
302 //!   - \ref TIMER_CFG_SPLIT_PAIR
303 //! - Timer A:
304 //!   - \ref TIMER_CFG_A_ONE_SHOT     : Half-width one-shot timer
305 //!   - \ref TIMER_CFG_A_ONE_SHOT_UP  : Half-width one-shot timer that counts up
306 //!     instead of down.
307 //!   - \ref TIMER_CFG_A_PERIODIC     : Half-width periodic timer
308 //!   - \ref TIMER_CFG_A_PERIODIC_UP  : Half-width periodic timer that counts up
309 //!     instead of down.
310 //!   - \ref TIMER_CFG_A_CAP_COUNT    : Half-width edge count capture
311 //!   - \ref TIMER_CFG_A_CAP_COUNT_UP : Half-width edge count capture that counts
312 //!     up instead of down.
313 //!   - \ref TIMER_CFG_A_CAP_TIME     : Half-width edge time capture
314 //!   - \ref TIMER_CFG_A_CAP_TIME_UP  : Half-width edge time capture that counts up
315 //!     instead of down.
316 //!   - \ref TIMER_CFG_A_PWM          : Half-width PWM output
317 //! - Timer B:
318 //!   - Same as Timer A but using TIMER_CFG_B_* instead.
319 //!
320 //! \param ui32Base is the base address of the timer module.
321 //! \param ui32Config is the configuration for the timer.
322 //!
323 //! \return None
324 //
325 //*****************************************************************************
326 extern void TimerConfigure(uint32_t ui32Base, uint32_t ui32Config);
327 
328 //*****************************************************************************
329 //
330 //! \brief Controls the output level.
331 //!
332 //! This function configures the PWM output level for the specified timer.
333 //!
334 //! \param ui32Base is the base address of the timer module.
335 //! \param ui32Timer specifies the timer(s) to adjust. Must be one of:
336 //! - \ref TIMER_A
337 //! - \ref TIMER_B
338 //! - \ref TIMER_BOTH
339 //! \param bInvert specifies the output level.
340 //! - \c true  : Timer's output is active low.
341 //! - \c false : Timer's output is active high.
342 //!
343 //! \return None
344 //
345 //*****************************************************************************
346 extern void TimerLevelControl(uint32_t ui32Base, uint32_t ui32Timer,
347                               bool bInvert);
348 
349 //*****************************************************************************
350 //
351 //! \brief Controls the event type.
352 //!
353 //! This function configures the signal edge(s) that triggers the timer when
354 //! in capture mode.
355 //!
356 //! \param ui32Base is the base address of the timer module.
357 //! \param ui32Timer specifies the timer(s) to be adjusted; must be one of:
358 //! - \ref TIMER_A
359 //! - \ref TIMER_B
360 //! - \ref TIMER_BOTH
361 //! \param ui32Event specifies the type of event; must be one of:
362 //! - \ref TIMER_EVENT_POS_EDGE
363 //! - \ref TIMER_EVENT_NEG_EDGE
364 //! - \ref TIMER_EVENT_BOTH_EDGES
365 //!
366 //! \return None
367 //
368 //*****************************************************************************
369 __STATIC_INLINE void
TimerEventControl(uint32_t ui32Base,uint32_t ui32Timer,uint32_t ui32Event)370 TimerEventControl(uint32_t ui32Base, uint32_t ui32Timer, uint32_t ui32Event)
371 {
372     // Check the arguments.
373     ASSERT(TimerBaseValid(ui32Base));
374     ASSERT((ui32Timer == TIMER_A) || (ui32Timer == TIMER_B) ||
375            (ui32Timer == TIMER_BOTH));
376 
377     // Set the event type.
378     ui32Timer &= GPT_CTL_TAEVENT_M | GPT_CTL_TBEVENT_M;
379     HWREG(ui32Base + GPT_O_CTL) = ((HWREG(ui32Base + GPT_O_CTL) & ~ui32Timer) |
380                                    (ui32Event & ui32Timer));
381 }
382 
383 //*****************************************************************************
384 //
385 //! \brief Controls the stall handling.
386 //!
387 //! This function controls the stall response for the specified timer. If the
388 //! \e bStall parameter is \b true, then the timer stops counting if the
389 //! processor enters debug mode; otherwise the timer keeps running while in
390 //! debug mode.
391 //!
392 //! \param ui32Base is the base address of the timer module.
393 //! \param ui32Timer specifies the timer(s) to be adjusted; must be one of:
394 //! - \ref TIMER_A
395 //! - \ref TIMER_B
396 //! - \ref TIMER_BOTH
397 //! \param bStall specifies the response to a stall signal.
398 //! - \c true  : Timer stops counting if the processor enters debug mode.
399 //! - \c false : Timer keeps running if the processor enters debug mode.
400 //!
401 //! \return None
402 //
403 //*****************************************************************************
404 extern void TimerStallControl(uint32_t ui32Base, uint32_t ui32Timer,
405                               bool bStall);
406 
407 //*****************************************************************************
408 //
409 //! \brief Controls the wait on trigger handling.
410 //!
411 //! This function controls whether or not a timer waits for a trigger input to
412 //! start counting. When enabled, the previous timer in the trigger chain must
413 //! count to its timeout in order for this timer to start counting. Refer to
414 //! the part's data sheet for a description of the trigger chain.
415 //!
416 //! \note This function should not be used for Timer 0A or Wide Timer 0A.
417 //!
418 //! \param ui32Base is the base address of the timer module.
419 //! \param ui32Timer specifies the timer(s) to be adjusted; must be one of:
420 //! - \ref TIMER_A
421 //! - \ref TIMER_B
422 //! - \ref TIMER_BOTH
423 //! \param bWait specifies if the timer should wait for a trigger input.
424 //! - \c true  : Wait for trigger.
425 //! - \c false : Do not wait for trigger.
426 //!
427 //! \return None
428 //
429 //*****************************************************************************
430 extern void TimerWaitOnTriggerControl(uint32_t ui32Base, uint32_t ui32Timer,
431                                       bool bWait);
432 
433 //*****************************************************************************
434 //
435 //! \brief Set the timer prescale value.
436 //!
437 //! This function configures the value of the timer clock prescaler. The
438 //! prescaler is only operational when in half-width mode and is used to extend
439 //! the range of the half-width timer modes.
440 //!
441 //! When in one-shot or periodic down count modes, \b ui32Value defines the
442 //! prescaler for the timer counter. When acting as a true prescaler, the
443 //! prescaler counts down to 0 before the value in timer registers are incremented.
444 //!
445 //! In all other individual/split modes, \b ui32Value is a linear extension of
446 //! the upper range of the timer counter, holding bits 23:16 in the 16-bit modes
447 //! of the 16/32-bit timer.
448 //!
449 //! \note Because the prescaler counts down to 0 the timer division ratio equals
450 //! \b ui32Value + 1. E.g. a prescale value of 15 divides the timer rate by 16.
451 //!
452 //! \param ui32Base is the base address of the timer module.
453 //! \param ui32Timer specifies the timer(s) to adjust; must be one of:
454 //! - \ref TIMER_A
455 //! - \ref TIMER_B
456 //! - \ref TIMER_BOTH
457 //! \param ui32Value is the timer prescale value which must be between 0 and 255
458 //! (both included).
459 //! - 0   : Timer division ratio = 1 (disable prescaling).
460 //! - 1   : Timer division ratio = 2.
461 //! - ...
462 //! - 255 : Timer division ratio = 256.
463 //!
464 //! \return None
465 //
466 //*****************************************************************************
467 __STATIC_INLINE void
TimerPrescaleSet(uint32_t ui32Base,uint32_t ui32Timer,uint32_t ui32Value)468 TimerPrescaleSet(uint32_t ui32Base, uint32_t ui32Timer, uint32_t ui32Value)
469 {
470     // Check the arguments.
471     ASSERT(TimerBaseValid(ui32Base));
472     ASSERT((ui32Timer == TIMER_A) || (ui32Timer == TIMER_B) ||
473            (ui32Timer == TIMER_BOTH));
474     ASSERT(ui32Value < 256);
475 
476     // Set the timer A prescaler if requested.
477     if(ui32Timer & TIMER_A)
478     {
479         HWREG(ui32Base + GPT_O_TAPR) = ui32Value;
480     }
481 
482     // Set the timer B prescaler if requested.
483     if(ui32Timer & TIMER_B)
484     {
485         HWREG(ui32Base + GPT_O_TBPR) = ui32Value;
486     }
487 }
488 
489 //*****************************************************************************
490 //
491 //! \brief Get the timer prescale value.
492 //!
493 //! This function gets the value of the timer clock prescaler. The
494 //! prescaler is only operational when in half-width mode and is used to extend
495 //! the range of the half-width timer modes.
496 //!
497 //! When in one-shot or periodic down count modes, \b ui32Value defines the
498 //! prescaler for the timer counter. When acting as a true prescaler, the
499 //! prescaler counts down to 0 before the value in timer registers are incremented.
500 //!
501 //! In all other individual/split modes, \b ui32Value is a linear extension of
502 //! the upper range of the timer counter, holding bits 23:16 in the 16-bit modes
503 //! of the 16/32-bit timer.
504 //!
505 //! \note Because the prescaler counts down to 0 the timer division ratio equals
506 //! \b ui32Value + 1. E.g. a prescale value of 15 divides the timer rate by 16.
507 //!
508 //! \param ui32Base is the base address of the timer module.
509 //! \param ui32Timer specifies the timer; must be one of:
510 //! - \ref TIMER_A
511 //! - \ref TIMER_B
512 //!
513 //! \return Returns the value of the timer prescaler.
514 //
515 //*****************************************************************************
516 __STATIC_INLINE uint32_t
TimerPrescaleGet(uint32_t ui32Base,uint32_t ui32Timer)517 TimerPrescaleGet(uint32_t ui32Base, uint32_t ui32Timer)
518 {
519     // Check the arguments.
520     ASSERT(TimerBaseValid(ui32Base));
521     ASSERT((ui32Timer == TIMER_A) || (ui32Timer == TIMER_B) ||
522            (ui32Timer == TIMER_BOTH));
523 
524     // Return the appropriate prescale value.
525     return((ui32Timer == TIMER_A) ? HWREG(ui32Base + GPT_O_TAPR) :
526            HWREG(ui32Base + GPT_O_TBPR));
527 }
528 
529 //*****************************************************************************
530 //
531 //! \brief Set the timer prescale match value.
532 //!
533 //! This function configures the value of the input clock prescaler match
534 //! value. When in a half-width mode that uses the counter match and the
535 //! prescaler, the prescale match effectively extends the range of the match.
536 //! The prescaler provides the least significant bits when counting down in
537 //! periodic and one-shot modes; in all other modes, the prescaler provides the
538 //! most significant bits.
539 //!
540 //! \param ui32Base is the base address of the timer module.
541 //! \param ui32Timer specifies the timer(s) to adjust; must be one of:
542 //! - \ref TIMER_A
543 //! - \ref TIMER_B
544 //! - \ref TIMER_BOTH
545 //! \param ui32Value is the timer prescale match value which must be between 0
546 //! and 255 (both included).
547 //!
548 //! \return None
549 //
550 //*****************************************************************************
551 __STATIC_INLINE void
TimerPrescaleMatchSet(uint32_t ui32Base,uint32_t ui32Timer,uint32_t ui32Value)552 TimerPrescaleMatchSet(uint32_t ui32Base, uint32_t ui32Timer, uint32_t ui32Value)
553 {
554     // Check the arguments.
555     ASSERT(TimerBaseValid(ui32Base));
556     ASSERT((ui32Timer == TIMER_A) || (ui32Timer == TIMER_B) ||
557            (ui32Timer == TIMER_BOTH));
558     ASSERT(ui32Value < 256);
559 
560     // Set the timer A prescale match if requested.
561     if(ui32Timer & TIMER_A)
562     {
563         HWREG(ui32Base + GPT_O_TAPMR) = ui32Value;
564     }
565 
566     // Set the timer B prescale match if requested.
567     if(ui32Timer & TIMER_B)
568     {
569         HWREG(ui32Base + GPT_O_TBPMR) = ui32Value;
570     }
571 }
572 
573 //*****************************************************************************
574 //
575 //! \brief Get the timer prescale match value.
576 //!
577 //! This function gets the value of the input clock prescaler match value.
578 //! When in a half-width mode that uses the counter match and prescaler, the
579 //! prescale match effectively extends the range of the match. The prescaler
580 //! provides the least significant bits when counting down in periodic and
581 //! one-shot modes; in all other modes, the prescaler provides the most
582 //! significant bits.
583 //!
584 //! \param ui32Base is the base address of the timer module.
585 //! \param ui32Timer specifies the timer; must be one of:
586 //! - \ref TIMER_A
587 //! - \ref TIMER_B
588 //!
589 //! \return Returns the value of the timer prescale match.
590 //
591 //*****************************************************************************
592 __STATIC_INLINE uint32_t
TimerPrescaleMatchGet(uint32_t ui32Base,uint32_t ui32Timer)593 TimerPrescaleMatchGet(uint32_t ui32Base, uint32_t ui32Timer)
594 {
595     // Check the arguments.
596     ASSERT(TimerBaseValid(ui32Base));
597     ASSERT((ui32Timer == TIMER_A) || (ui32Timer == TIMER_B));
598 
599     // Return the appropriate prescale match value.
600     return((ui32Timer == TIMER_A) ? HWREG(ui32Base + GPT_O_TAPMR) :
601            HWREG(ui32Base + GPT_O_TBPMR));
602 }
603 
604 //*****************************************************************************
605 //
606 //! \brief Sets the timer load value.
607 //!
608 //! This function configures the timer load value; if the timer is running then
609 //! the value is immediately loaded into the timer.
610 //!
611 //! \note This function can be used for both full- and half-width modes of
612 //! 16/32-bit timers.
613 //!
614 //! \note Only \ref TIMER_A should be used when the timer is configured for
615 //! full-width operation.
616 //!
617 //! \param ui32Base is the base address of the timer module.
618 //! \param ui32Timer specifies the timer(s) to adjust; must be one of:
619 //! - \ref TIMER_A
620 //! - \ref TIMER_B
621 //! - \ref TIMER_BOTH
622 //! \param ui32Value is the load value.
623 //!
624 //! \return None
625 //
626 //*****************************************************************************
627 __STATIC_INLINE void
TimerLoadSet(uint32_t ui32Base,uint32_t ui32Timer,uint32_t ui32Value)628 TimerLoadSet(uint32_t ui32Base, uint32_t ui32Timer, uint32_t ui32Value)
629 {
630     // Check the arguments.
631     ASSERT(TimerBaseValid(ui32Base));
632     ASSERT((ui32Timer == TIMER_A) || (ui32Timer == TIMER_B) ||
633            (ui32Timer == TIMER_BOTH));
634 
635     // Set the timer A load value if requested.
636     if(ui32Timer & TIMER_A)
637     {
638         HWREG(ui32Base + GPT_O_TAILR) = ui32Value;
639     }
640 
641     // Set the timer B load value if requested.
642     if(ui32Timer & TIMER_B)
643     {
644         HWREG(ui32Base + GPT_O_TBILR) = ui32Value;
645     }
646 }
647 
648 //*****************************************************************************
649 //
650 //! \brief Gets the timer load value.
651 //!
652 //! This function gets the currently programmed interval load value for the
653 //! specified timer.
654 //!
655 //! \note This function can be used for both full- and half-width modes of
656 //! 16/32-bit timers.
657 //!
658 //! \note Only \ref TIMER_A should be used when the timer is configured for
659 //! full-width operation.
660 //!
661 //! \param ui32Base is the base address of the timer module.
662 //! \param ui32Timer specifies the timer; must be one of:
663 //! - \ref TIMER_A
664 //! - \ref TIMER_B
665 //!
666 //! \return Returns the load value for the timer
667 //
668 //*****************************************************************************
669 __STATIC_INLINE uint32_t
TimerLoadGet(uint32_t ui32Base,uint32_t ui32Timer)670 TimerLoadGet(uint32_t ui32Base, uint32_t ui32Timer)
671 {
672     // Check the arguments.
673     ASSERT(TimerBaseValid(ui32Base));
674     ASSERT((ui32Timer == TIMER_A) || (ui32Timer == TIMER_B));
675 
676     // Return the appropriate load value.
677     return((ui32Timer == TIMER_A) ? HWREG(ui32Base + GPT_O_TAILR) :
678            HWREG(ui32Base + GPT_O_TBILR));
679 }
680 
681 //*****************************************************************************
682 //
683 //! \brief Gets the current timer value.
684 //!
685 //! This function reads the current value of the specified timer.
686 //!
687 //! \note This function can be used for both full- and half-width modes of
688 //! 16/32-bit timers.
689 //!
690 //! \note Only \ref TIMER_A should be used when the timer is configured for
691 //! full-width operation.
692 //!
693 //! \param ui32Base is the base address of the timer module.
694 //! \param ui32Timer specifies the timer; must be one of:
695 //! - \ref TIMER_A
696 //! - \ref TIMER_B
697 //!
698 //! \return Returns the current value of the timer.
699 //
700 //*****************************************************************************
701 __STATIC_INLINE uint32_t
TimerValueGet(uint32_t ui32Base,uint32_t ui32Timer)702 TimerValueGet(uint32_t ui32Base, uint32_t ui32Timer)
703 {
704     // Check the arguments.
705     ASSERT(TimerBaseValid(ui32Base));
706     ASSERT((ui32Timer == TIMER_A) || (ui32Timer == TIMER_B));
707 
708     // Return the appropriate timer value.
709     return((ui32Timer == TIMER_A) ? HWREG(ui32Base + GPT_O_TAR) :
710            HWREG(ui32Base + GPT_O_TBR));
711 }
712 
713 //*****************************************************************************
714 //
715 //! \brief Sets the timer match value.
716 //!
717 //! This function configures the match value for a timer. This value is used
718 //! in capture count mode to determine when to interrupt the processor and in
719 //! PWM mode to determine the duty cycle of the output signal. Match interrupts
720 //! can also be generated in periodic and one-shot modes when the value of the
721 //! counter matches this register.
722 //!
723 //! \note This function can be used for both full- and half-width modes of
724 //! 16/32-bit timers.
725 //!
726 //! \note Only \ref TIMER_A should be used when the timer is configured for
727 //! full-width operation.
728 //!
729 //! \param ui32Base is the base address of the timer module.
730 //! \param ui32Timer specifies the timer(s) to adjust; must be one of:
731 //! - \ref TIMER_A
732 //! - \ref TIMER_B
733 //! - \ref TIMER_BOTH
734 //! \param ui32Value is the match value.
735 //!
736 //! \return None
737 //
738 //*****************************************************************************
739 __STATIC_INLINE void
TimerMatchSet(uint32_t ui32Base,uint32_t ui32Timer,uint32_t ui32Value)740 TimerMatchSet(uint32_t ui32Base, uint32_t ui32Timer, uint32_t ui32Value)
741 {
742     // Check the arguments.
743     ASSERT(TimerBaseValid(ui32Base));
744     ASSERT((ui32Timer == TIMER_A) || (ui32Timer == TIMER_B) ||
745            (ui32Timer == TIMER_BOTH));
746 
747     // Set the timer A match value if requested.
748     if(ui32Timer & TIMER_A)
749     {
750         HWREG(ui32Base + GPT_O_TAMATCHR) = ui32Value;
751     }
752 
753     // Set the timer B match value if requested.
754     if(ui32Timer & TIMER_B)
755     {
756         HWREG(ui32Base + GPT_O_TBMATCHR) = ui32Value;
757     }
758 }
759 
760 //*****************************************************************************
761 //
762 //! \brief Gets the timer match value.
763 //!
764 //! This function gets the match value for the specified timer.
765 //!
766 //! \note This function can be used for both full- and half-width modes of
767 //! 16/32-bit timers.
768 //!
769 //! \note Only \ref TIMER_A should be used when the timer is configured for
770 //! full-width operation.
771 //!
772 //! \param ui32Base is the base address of the timer module.
773 //! \param ui32Timer specifies the timer; must be one of:
774 //! - \ref TIMER_A
775 //! - \ref TIMER_B
776 //! - \ref TIMER_BOTH
777 //!
778 //! \return Returns the match value for the timer
779 //
780 //*****************************************************************************
781 __STATIC_INLINE uint32_t
TimerMatchGet(uint32_t ui32Base,uint32_t ui32Timer)782 TimerMatchGet(uint32_t ui32Base, uint32_t ui32Timer)
783 {
784     // Check the arguments.
785     ASSERT(TimerBaseValid(ui32Base));
786     ASSERT((ui32Timer == TIMER_A) || (ui32Timer == TIMER_B));
787 
788     // Return the appropriate match value.
789     return((ui32Timer == TIMER_A) ? HWREG(ui32Base + GPT_O_TAMATCHR) :
790            HWREG(ui32Base + GPT_O_TBMATCHR));
791 }
792 
793 //*****************************************************************************
794 //
795 //! \brief Registers an interrupt handler for the timer interrupt in the dynamic interrupt table.
796 //!
797 //! \note Only use this function if you want to use the dynamic vector table (in SRAM)!
798 //!
799 //! This function registers a function as the interrupt handler for a specific
800 //! interrupt and enables the corresponding interrupt in the interrupt controller.
801 //!
802 //! Specific timer interrupts must be enabled via \ref TimerIntEnable(). It is the
803 //! interrupt handler's responsibility to clear the interrupt source via
804 //! \ref TimerIntClear().
805 //!
806 //! \param ui32Base is the base address of the timer module.
807 //! \param ui32Timer specifies the timer(s); must be one of:
808 //! - \ref TIMER_A
809 //! - \ref TIMER_B
810 //! - \ref TIMER_BOTH
811 //! \param pfnHandler is a pointer to the function to be called when the timer
812 //! interrupt occurs.
813 //!
814 //! \return None
815 //!
816 //! \sa \ref IntRegister() for important information about registering interrupt
817 //! handlers.
818 //
819 //*****************************************************************************
820 extern void TimerIntRegister(uint32_t ui32Base, uint32_t ui32Timer,
821                              void (*pfnHandler)(void));
822 
823 //*****************************************************************************
824 //
825 //! \brief Unregisters an interrupt handler for the timer interrupt in the dynamic interrupt table.
826 //!
827 //! This function unregisters the handler to be called when a timer interrupt
828 //! occurs. This function also masks off the interrupt in the interrupt
829 //! controller so that the interrupt handler is no longer called.
830 //!
831 //! \param ui32Base is the base address of the timer module.
832 //! \param ui32Timer specifies the timer(s); must be one of:
833 //! - \ref TIMER_A
834 //! - \ref TIMER_B
835 //! - \ref TIMER_BOTH
836 //!
837 //! \return None
838 //!
839 //! \sa \ref IntRegister() for important information about registering interrupt
840 //! handlers.
841 //
842 //*****************************************************************************
843 extern void TimerIntUnregister(uint32_t ui32Base, uint32_t ui32Timer);
844 
845 //*****************************************************************************
846 //
847 //! \brief Enables individual timer interrupt sources.
848 //!
849 //! This function enables the indicated timer interrupt sources. Only the
850 //! sources that are enabled can be reflected to the processor interrupt;
851 //! disabled sources have no effect on the processor.
852 //!
853 //! \param ui32Base is the base address of the timer module.
854 //! \param ui32IntFlags is the bit mask of the interrupt sources to be enabled.
855 //! The parameter must be the bitwise OR of any combination of
856 //! the following:
857 //! - \ref TIMER_CAPB_EVENT    : Capture B event interrupt.
858 //! - \ref TIMER_CAPB_MATCH    : Capture B match interrupt.
859 //! - \ref TIMER_TIMB_TIMEOUT  : Timer B timeout interrupt.
860 //! - \ref TIMER_CAPA_EVENT    : Capture A event interrupt.
861 //! - \ref TIMER_CAPA_MATCH    : Capture A match interrupt.
862 //! - \ref TIMER_TIMA_TIMEOUT  : Timer A timeout interrupt.
863 //!
864 //! \return None
865 //
866 //*****************************************************************************
867 __STATIC_INLINE void
TimerIntEnable(uint32_t ui32Base,uint32_t ui32IntFlags)868 TimerIntEnable(uint32_t ui32Base, uint32_t ui32IntFlags)
869 {
870     // Check the arguments.
871     ASSERT(TimerBaseValid(ui32Base));
872 
873     // Enable the specified interrupts.
874     HWREG(ui32Base + GPT_O_IMR) |= ui32IntFlags;
875 }
876 
877 //*****************************************************************************
878 //
879 //! \brief Disables individual timer interrupt sources.
880 //!
881 //! This function disables the indicated timer interrupt sources. Only the
882 //! sources that are enabled can be reflected to the processor interrupt;
883 //! disabled sources have no effect on the processor.
884 //!
885 //! \param ui32Base is the base address of the timer module.
886 //! \param ui32IntFlags is the bit mask of the interrupt sources to be disabled.
887 //! The parameter must be the bitwise OR of any combination of
888 //! the following:
889 //! - \ref TIMER_CAPB_EVENT    : Capture B event interrupt.
890 //! - \ref TIMER_CAPB_MATCH    : Capture B match interrupt.
891 //! - \ref TIMER_TIMB_TIMEOUT  : Timer B timeout interrupt.
892 //! - \ref TIMER_CAPA_EVENT    : Capture A event interrupt.
893 //! - \ref TIMER_CAPA_MATCH    : Capture A match interrupt.
894 //! - \ref TIMER_TIMA_TIMEOUT  : Timer A timeout interrupt.
895 //!
896 //! \return None
897 //
898 //*****************************************************************************
899 __STATIC_INLINE void
TimerIntDisable(uint32_t ui32Base,uint32_t ui32IntFlags)900 TimerIntDisable(uint32_t ui32Base, uint32_t ui32IntFlags)
901 {
902     // Check the arguments.
903     ASSERT(TimerBaseValid(ui32Base));
904 
905     // Disable the specified interrupts.
906     HWREG(ui32Base + GPT_O_IMR) &= ~(ui32IntFlags);
907 }
908 
909 //*****************************************************************************
910 //
911 //! \brief Gets the current interrupt status.
912 //!
913 //! This function returns the interrupt status for the timer module. Either
914 //! the raw interrupt status or the status of interrupts that are allowed to
915 //! reflect to the processor can be returned.
916 //!
917 //! \param ui32Base is the base address of the timer module.
918 //! \param bMasked selects either raw or masked interrupt status:
919 //! - \c true  : Masked interrupt.
920 //! - \c false : Raw interrupt.
921 //!
922 //! \return The current interrupt status, enumerated as a bit field of values:
923 //! - \ref TIMER_CAPB_EVENT    : Capture B event interrupt.
924 //! - \ref TIMER_CAPB_MATCH    : Capture B match interrupt.
925 //! - \ref TIMER_TIMB_TIMEOUT  : Timer B timeout interrupt.
926 //! - \ref TIMER_CAPA_EVENT    : Capture A event interrupt.
927 //! - \ref TIMER_CAPA_MATCH    : Capture A match interrupt.
928 //! - \ref TIMER_TIMA_TIMEOUT  : Timer A timeout interrupt.
929 //
930 //*****************************************************************************
931 __STATIC_INLINE uint32_t
TimerIntStatus(uint32_t ui32Base,bool bMasked)932 TimerIntStatus(uint32_t ui32Base, bool bMasked)
933 {
934     // Check the arguments.
935     ASSERT(TimerBaseValid(ui32Base));
936 
937     // Return either the interrupt status or the raw interrupt status as
938     // requested.
939     return(bMasked ? HWREG(ui32Base + GPT_O_MIS) :
940            HWREG(ui32Base + GPT_O_RIS));
941 }
942 
943 //*****************************************************************************
944 //
945 //! \brief Clears timer interrupt sources.
946 //!
947 //! The specified timer interrupt sources are cleared, so that they no longer
948 //! assert. This function must be called in the interrupt handler to keep the
949 //! interrupt from being triggered again immediately upon exit.
950 //!
951 //! \note Due to write buffers and synchronizers in the system it may take several
952 //! clock cycles from a register write clearing an event in a module and until the
953 //! event is actually cleared in the NVIC of the system CPU. It is recommended to
954 //! clear the event source early in the interrupt service routine (ISR) to allow
955 //! the event clear to propagate to the NVIC before returning from the ISR.
956 //! At the same time, an early event clear allows new events of the same type to be
957 //! pended instead of ignored if the event is cleared later in the ISR.
958 //! It is the responsibility of the programmer to make sure that enough time has passed
959 //! before returning from the ISR to avoid false re-triggering of the cleared event.
960 //! A simple, although not necessarily optimal, way of clearing an event before
961 //! returning from the ISR is:
962 //! -# Write to clear event (interrupt source). (buffered write)
963 //! -# Dummy read from the event source module. (making sure the write has propagated)
964 //! -# Wait two system CPU clock cycles (user code or two NOPs). (allowing cleared event to propagate through any synchronizers)
965 //!
966 //! \param ui32Base is the base address of the timer module.
967 //! \param ui32IntFlags is a bit mask of the interrupt sources to be cleared.
968 //! The parameter must be the bitwise OR of any combination of
969 //! the following:
970 //! - \ref TIMER_CAPB_EVENT    : Capture B event interrupt.
971 //! - \ref TIMER_CAPB_MATCH    : Capture B match interrupt.
972 //! - \ref TIMER_TIMB_TIMEOUT  : Timer B timeout interrupt.
973 //! - \ref TIMER_CAPA_EVENT    : Capture A event interrupt.
974 //! - \ref TIMER_CAPA_MATCH    : Capture A match interrupt.
975 //! - \ref TIMER_TIMA_TIMEOUT  : Timer A timeout interrupt.
976 //!
977 //! \return None
978 //
979 //*****************************************************************************
980 __STATIC_INLINE void
TimerIntClear(uint32_t ui32Base,uint32_t ui32IntFlags)981 TimerIntClear(uint32_t ui32Base, uint32_t ui32IntFlags)
982 {
983     // Check the arguments.
984     ASSERT(TimerBaseValid(ui32Base));
985 
986     // Clear the requested interrupt sources.
987     HWREG(ui32Base + GPT_O_ICLR) = ui32IntFlags;
988 }
989 
990 //*****************************************************************************
991 //
992 //! \brief Synchronizes the counters in a set of timers.
993 //!
994 //! This function synchronizes the counters in a specified set of timers.
995 //! When a timer is running in half-width mode, each half can be included or
996 //! excluded in the synchronization event. When a timer is running in
997 //! full-width mode, only the A timer can be synchronized (specifying the B
998 //! timer has no effect).
999 //!
1000 //! \param ui32Base is the base address of the timer module. This parameter must
1001 //! be the base address of Timer0 (in other words, \b GPT0_BASE).
1002 //! \param ui32Timers is the set of timers to synchronize.
1003 //! The parameter is the bitwise OR of any of the following:
1004 //! - \ref TIMER_0A_SYNC
1005 //! - \ref TIMER_0B_SYNC
1006 //! - \ref TIMER_1A_SYNC
1007 //! - \ref TIMER_1B_SYNC
1008 //! - \ref TIMER_2A_SYNC
1009 //! - \ref TIMER_2B_SYNC
1010 //! - \ref TIMER_3A_SYNC
1011 //! - \ref TIMER_3B_SYNC
1012 //!
1013 //! \return None
1014 //
1015 //*****************************************************************************
1016 __STATIC_INLINE void
TimerSynchronize(uint32_t ui32Base,uint32_t ui32Timers)1017 TimerSynchronize(uint32_t ui32Base, uint32_t ui32Timers)
1018 {
1019     // Check the arguments.
1020     ASSERT(ui32Base == GPT0_BASE);
1021 
1022     // Synchronize the specified timers.
1023     HWREG(ui32Base + GPT_O_SYNC) = ui32Timers;
1024 }
1025 
1026 //*****************************************************************************
1027 //
1028 //! \brief Enables AND'ing of the CCP outputs from Timer A and Timer B.
1029 //!
1030 //! \param ui32Base is the base address of the timer module.
1031 //!
1032 //! \return None
1033 //
1034 //*****************************************************************************
1035 __STATIC_INLINE void
TimerCcpCombineEnable(uint32_t ui32Base)1036 TimerCcpCombineEnable(uint32_t ui32Base)
1037 {
1038     // Check the arguments
1039     ASSERT(TimerBaseValid(ui32Base));
1040 
1041     // Set the bit
1042     HWREG(ui32Base + GPT_O_ANDCCP) |= GPT_ANDCCP_CCP_AND_EN;
1043 }
1044 
1045 //*****************************************************************************
1046 //
1047 //! \brief Disables AND'ing of the CCP outputs from Timer A and Timer B.
1048 //!
1049 //! \param ui32Base is the base address of the timer module.
1050 //!
1051 //! \return None
1052 //
1053 //*****************************************************************************
1054 __STATIC_INLINE void
TimerCcpCombineDisable(uint32_t ui32Base)1055 TimerCcpCombineDisable(uint32_t ui32Base)
1056 {
1057     // Check the arguments
1058     ASSERT(TimerBaseValid(ui32Base));
1059 
1060     // Clear the bit
1061     HWREG(ui32Base + GPT_O_ANDCCP) &= ~(GPT_ANDCCP_CCP_AND_EN);
1062 }
1063 
1064 //*****************************************************************************
1065 //
1066 //! \brief Sets the Match Register Update mode.
1067 //!
1068 //! This function controls when the Match Register value and Prescale Register value
1069 //! are applied after writing these registers while a timer is enabled.
1070 //!
1071 //! \note If the timer is disabled when setting the update mode the Match Register
1072 //! and Prescale Register values are applied immediately when enabling the timer.
1073 //!
1074 //! \param ui32Base is the base address of the timer module.
1075 //! \param ui32Timer specifies the timer(s) to configure; must be one of:
1076 //! - \ref TIMER_A
1077 //! - \ref TIMER_B
1078 //! - \ref TIMER_BOTH
1079 //! \param ui32Mode sets the mode:
1080 //! - \ref TIMER_MATCHUPDATE_NEXTCYCLE : Apply Match Register and Prescale Register on next clock
1081 //!        cycle after writing any of these registers.
1082 //! - \ref TIMER_MATCHUPDATE_TIMEOUT   : Apply Match Register and Prescale Register on next timeout
1083 //!        after writing any of these registers.
1084 //!
1085 //! \return None
1086 //
1087 //*****************************************************************************
1088 extern void TimerMatchUpdateMode(uint32_t ui32Base, uint32_t ui32Timer, uint32_t ui32Mode);
1089 
1090 //*****************************************************************************
1091 //
1092 //! \brief Sets the Interval Load mode.
1093 //!
1094 //! This function controls when the Timer Register and Prescale Snap-shot (if used)
1095 //! are updated.
1096 //!
1097 //! Timer Register (TAR/TBR) is updated when Interval Load Register (TAILR/TBILR) is written
1098 //! and the Prescale Snap-shot (TAPS/TBPS) is updated when Prescale Register (TAPR/TBPR) is
1099 //! written depending on the mode of operation.
1100 //!
1101 //! \param ui32Base is the base address of the timer module.
1102 //! \param ui32Timer specifies the timer(s) to configure; must be one of:
1103 //! - \ref TIMER_A
1104 //! - \ref TIMER_B
1105 //! - \ref TIMER_BOTH
1106 //! \param ui32Mode sets the mode:
1107 //! - \ref TIMER_INTERVALLOAD_NEXTCYCLE : Update Timer Register and Prescale Snap-shot on next clock
1108 //!        cycle after writing Interval Load Register or Prescale Register, respectively.
1109 //! - \ref TIMER_INTERVALLOAD_TIMEOUT   : Update Timer Register and Prescale Snap-shot on next timeout
1110 //!        after writing Interval Load Register or Prescale Register, respectively.
1111 //!
1112 //! \return None
1113 //
1114 //*****************************************************************************
1115 extern void TimerIntervalLoadMode(uint32_t ui32Base, uint32_t ui32Timer, uint32_t ui32Mode);
1116 
1117 //*****************************************************************************
1118 //
1119 // Support for DriverLib in ROM:
1120 // Redirect to implementation in ROM when available.
1121 //
1122 //*****************************************************************************
1123 #if !defined(DRIVERLIB_NOROM) && !defined(DOXYGEN)
1124     #include "../driverlib/rom.h"
1125     #ifdef ROM_TimerConfigure
1126         #undef  TimerConfigure
1127         #define TimerConfigure                  ROM_TimerConfigure
1128     #endif
1129     #ifdef ROM_TimerLevelControl
1130         #undef  TimerLevelControl
1131         #define TimerLevelControl               ROM_TimerLevelControl
1132     #endif
1133     #ifdef ROM_TimerStallControl
1134         #undef  TimerStallControl
1135         #define TimerStallControl               ROM_TimerStallControl
1136     #endif
1137     #ifdef ROM_TimerWaitOnTriggerControl
1138         #undef  TimerWaitOnTriggerControl
1139         #define TimerWaitOnTriggerControl       ROM_TimerWaitOnTriggerControl
1140     #endif
1141     #ifdef ROM_TimerIntRegister
1142         #undef  TimerIntRegister
1143         #define TimerIntRegister                ROM_TimerIntRegister
1144     #endif
1145     #ifdef ROM_TimerIntUnregister
1146         #undef  TimerIntUnregister
1147         #define TimerIntUnregister              ROM_TimerIntUnregister
1148     #endif
1149     #ifdef ROM_TimerMatchUpdateMode
1150         #undef  TimerMatchUpdateMode
1151         #define TimerMatchUpdateMode            ROM_TimerMatchUpdateMode
1152     #endif
1153     #ifdef ROM_TimerIntervalLoadMode
1154         #undef  TimerIntervalLoadMode
1155         #define TimerIntervalLoadMode           ROM_TimerIntervalLoadMode
1156     #endif
1157 #endif
1158 
1159 //*****************************************************************************
1160 //
1161 // Mark the end of the C bindings section for C++ compilers.
1162 //
1163 //*****************************************************************************
1164 #ifdef __cplusplus
1165 }
1166 #endif
1167 
1168 #endif // __GPT_H__
1169 
1170 //*****************************************************************************
1171 //
1172 //! Close the Doxygen group.
1173 //! @}
1174 //! @}
1175 //
1176 //*****************************************************************************
1177