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