CC26xx Driver Library
aux_timer.h
Go to the documentation of this file.
1 /******************************************************************************
2 * Filename: aux_timer.h
3 * Revised: 2016-02-24 14:08:55 +0100 (Wed, 24 Feb 2016)
4 * Revision: 45767
5 *
6 * Description: Defines and prototypes for the AUX Timer
7 *
8 * Copyright (c) 2015 - 2016, Texas Instruments Incorporated
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions are met:
13 *
14 * 1) Redistributions of source code must retain the above copyright notice,
15 * this list of conditions and the following disclaimer.
16 *
17 * 2) Redistributions in binary form must reproduce the above copyright notice,
18 * this list of conditions and the following disclaimer in the documentation
19 * and/or other materials provided with the distribution.
20 *
21 * 3) Neither the name of the ORGANIZATION nor the names of its contributors may
22 * be used to endorse or promote products derived from this software without
23 * specific prior written permission.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
29 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 * POSSIBILITY OF SUCH DAMAGE.
36 *
37 ******************************************************************************/
38 
39 //*****************************************************************************
40 //
45 //
46 //*****************************************************************************
47 
48 #ifndef __AUX_TIMER_H__
49 #define __AUX_TIMER_H__
50 
51 //*****************************************************************************
52 //
53 // If building with a C++ compiler, make all of the definitions in this header
54 // have a C binding.
55 //
56 //*****************************************************************************
57 #ifdef __cplusplus
58 extern "C"
59 {
60 #endif
61 
62 #include <stdbool.h>
63 #include <stdint.h>
64 #include <inc/hw_types.h>
65 #include <inc/hw_ints.h>
66 #include <inc/hw_memmap.h>
67 #include <inc/hw_aux_timer.h>
68 #include <driverlib/debug.h>
69 #include <driverlib/interrupt.h>
70 
71 //*****************************************************************************
72 //
73 // Support for DriverLib in ROM:
74 // This section renames all functions that are not "static inline", so that
75 // calling these functions will default to implementation in flash. At the end
76 // of this file a second renaming will change the defaults to implementation in
77 // ROM for available functions.
78 //
79 // To force use of the implementation in flash, e.g. for debugging:
80 // - Globally: Define DRIVERLIB_NOROM at project level
81 // - Per function: Use prefix "NOROM_" when calling the function
82 //
83 //*****************************************************************************
84 #if !defined(DOXYGEN)
85  #define AUXTimerConfigure NOROM_AUXTimerConfigure
86  #define AUXTimerStart NOROM_AUXTimerStart
87  #define AUXTimerStop NOROM_AUXTimerStop
88  #define AUXTimerPrescaleSet NOROM_AUXTimerPrescaleSet
89  #define AUXTimerPrescaleGet NOROM_AUXTimerPrescaleGet
90 #endif
91 
92 //*****************************************************************************
93 //
94 // Values that can be passed to AUXTimerConfigure().
95 //
96 // Requires timer0 and timer1 to use same enumerations and values!
97 //
98 //*****************************************************************************
99 #define AUX_TIMER_CFG_ONE_SHOT (AUX_TIMER_T0CFG_RELOAD_MAN) // One-shot timer mode
100 #define AUX_TIMER_CFG_PERIODIC (AUX_TIMER_T0CFG_RELOAD_CONT) // Period timer mode
101 #define AUX_TIMER_CFG_ONE_SHOT_EDGE_COUNT ((AUX_TIMER_T0CFG_RELOAD_MAN) | (AUX_TIMER_T0CFG_MODE_TICK)) // One-shot timer with edge count
102 #define AUX_TIMER_CFG_PERIODIC_EDGE_COUNT ((AUX_TIMER_T0CFG_RELOAD_CONT) | (AUX_TIMER_T0CFG_MODE_TICK)) // Periodic timer with edge count
103 #define AUX_TIMER_CFG_RISING_EDGE (AUX_TIMER_T0CFG_TICK_SRC_POL_RISE) // Count rising edges (used with edge count mode)
104 #define AUX_TIMER_CFG_FALLING_EDGE (AUX_TIMER_T0CFG_TICK_SRC_POL_FALL) // Count falling edges (used with edge count mode)
105 
106 #define AUX_TIMER_CFG_TICK_SRC_RTC_EVENT (AUX_TIMER_T0CFG_TICK_SRC_RTC_CH2_EV) // AON wake-up event
107 #define AUX_TIMER_CFG_TICK_SRC_CMP_A (AUX_TIMER_T0CFG_TICK_SRC_AUX_COMPA) // Comparator A
108 #define AUX_TIMER_CFG_TICK_SRC_CMP_B (AUX_TIMER_T0CFG_TICK_SRC_AUX_COMPB) // Comparator B
109 #define AUX_TIMER_CFG_TICK_SRC_TDCDONE (AUX_TIMER_T0CFG_TICK_SRC_TDC_DONE) // TDC Done
110 #define AUX_TIMER_CFG_TICK_SRC_TIMER0_EVENT (AUX_TIMER_T1CFG_TICK_SRC_TIMER0_EV) // Timer 0 event
111 #define AUX_TIMER_CFG_TICK_SRC_TIMER1_EVENT (AUX_TIMER_T0CFG_TICK_SRC_TIMER1_EV) // Timer 1 event
112 #define AUX_TIMER_CFG_TICK_SRC_SMPH_RELEASE (AUX_TIMER_T0CFG_TICK_SRC_SMPH_AUTOTAKE_DONE) // Semaphore release
113 #define AUX_TIMER_CFG_TICK_SRC_ADC_DONE (AUX_TIMER_T0CFG_TICK_SRC_ADC_DONE) // ADC done
114 #define AUX_TIMER_CFG_TICK_SRC_RTC_4KHZ (AUX_TIMER_T0CFG_TICK_SRC_RTC_4KHZ)
115 #define AUX_TIMER_CFG_TICK_SRC_OBSMUX0 (AUX_TIMER_T0CFG_TICK_SRC_OBSMUX0)
116 #define AUX_TIMER_CFG_TICK_SRC_OBSMUX1 (AUX_TIMER_T0CFG_TICK_SRC_OBSMUX1)
117 #define AUX_TIMER_CFG_TICK_SRC_AON_SW (AUX_TIMER_T0CFG_TICK_SRC_AON_SW)
118 #define AUX_TIMER_CFG_TICK_SRC_AON_PROG_WU (AUX_TIMER_T0CFG_TICK_SRC_AON_PROG_WU)
119 #define AUX_TIMER_CFG_TICK_SRC_AIO0 (AUX_TIMER_T0CFG_TICK_SRC_AUXIO0) // AIO_DAT[ 0]
120 #define AUX_TIMER_CFG_TICK_SRC_AIO1 (AUX_TIMER_T0CFG_TICK_SRC_AUXIO1) // AIO_DAT[ 1]
121 #define AUX_TIMER_CFG_TICK_SRC_AIO2 (AUX_TIMER_T0CFG_TICK_SRC_AUXIO2) // AIO_DAT[ 2]
122 #define AUX_TIMER_CFG_TICK_SRC_AIO3 (AUX_TIMER_T0CFG_TICK_SRC_AUXIO3) // AIO_DAT[ 3]
123 #define AUX_TIMER_CFG_TICK_SRC_AIO4 (AUX_TIMER_T0CFG_TICK_SRC_AUXIO4) // AIO_DAT[ 4]
124 #define AUX_TIMER_CFG_TICK_SRC_AIO5 (AUX_TIMER_T0CFG_TICK_SRC_AUXIO5) // AIO_DAT[ 5]
125 #define AUX_TIMER_CFG_TICK_SRC_AIO6 (AUX_TIMER_T0CFG_TICK_SRC_AUXIO6) // AIO_DAT[ 6]
126 #define AUX_TIMER_CFG_TICK_SRC_AIO7 (AUX_TIMER_T0CFG_TICK_SRC_AUXIO7) // AIO_DAT[ 7]
127 #define AUX_TIMER_CFG_TICK_SRC_AIO8 (AUX_TIMER_T0CFG_TICK_SRC_AUXIO8) // AIO_DAT[ 8]
128 #define AUX_TIMER_CFG_TICK_SRC_AIO9 (AUX_TIMER_T0CFG_TICK_SRC_AUXIO9) // AIO_DAT[ 9]
129 #define AUX_TIMER_CFG_TICK_SRC_AIO10 (AUX_TIMER_T0CFG_TICK_SRC_AUXIO10) // AIO_DAT[10]
130 #define AUX_TIMER_CFG_TICK_SRC_AIO11 (AUX_TIMER_T0CFG_TICK_SRC_AUXIO11) // AIO_DAT[11]
131 #define AUX_TIMER_CFG_TICK_SRC_AIO12 (AUX_TIMER_T0CFG_TICK_SRC_AUXIO12) // AIO_DAT[12]
132 #define AUX_TIMER_CFG_TICK_SRC_AIO13 (AUX_TIMER_T0CFG_TICK_SRC_AUXIO13) // AIO_DAT[13]
133 #define AUX_TIMER_CFG_TICK_SRC_AIO14 (AUX_TIMER_T0CFG_TICK_SRC_AUXIO14) // AIO_DAT[14]
134 #define AUX_TIMER_CFG_TICK_SRC_AIO15 (AUX_TIMER_T0CFG_TICK_SRC_AUXIO15) // AIO_DAT[15]
135 #define AUX_TIMER_CFG_TICK_SRC_ACLK_REF (AUX_TIMER_T0CFG_TICK_SRC_ACLK_REF) // ACLK_REF_i
136 #define AUX_TIMER_CFG_TICK_SRC_MCU_EVENT (AUX_TIMER_T0CFG_TICK_SRC_MCU_EVENT) // MCU event
137 #define AUX_TIMER_CFG_TICK_SRC_ADC_IRQ (AUX_TIMER_T0CFG_TICK_SRC_ADC_IRQ) // DMA done
138 
139 //*****************************************************************************
140 //
141 // Values that can be passed to most of the timer APIs as the ui32Timer
142 // parameter.
143 //
144 //*****************************************************************************
145 #define AUX_TIMER_0 0x0000FFFF // AUX Timer 0
146 #define AUX_TIMER_1 0x00FF0000 // AUX Timer 1
147 #define AUX_TIMER_BOTH 0x00FFFFFF // AUX Timer Both 0 and 1
148 
149 //*****************************************************************************
150 //
151 // Values that can be passed to AUXTimerPrescaleSet and returned from
152 // AUXTimerPrescaleGet.
153 //
154 //*****************************************************************************
155 #define AUX_TIMER_PRESCALE_DIV_1 0x00000000 // Prescale division ratio 1
156 #define AUX_TIMER_PRESCALE_DIV_2 0x00000001 // Prescale division ratio 2
157 #define AUX_TIMER_PRESCALE_DIV_4 0x00000002 // Prescale division ratio 4
158 #define AUX_TIMER_PRESCALE_DIV_8 0x00000003 // Prescale division ratio 8
159 #define AUX_TIMER_PRESCALE_DIV_16 0x00000004 // Prescale division ratio 16
160 #define AUX_TIMER_PRESCALE_DIV_32 0x00000005 // Prescale division ratio 32
161 #define AUX_TIMER_PRESCALE_DIV_64 0x00000006 // Prescale division ratio 64
162 #define AUX_TIMER_PRESCALE_DIV_128 0x00000007 // Prescale division ratio 128
163 #define AUX_TIMER_PRESCALE_DIV_256 0x00000008 // Prescale division ratio 256
164 #define AUX_TIMER_PRESCALE_DIV_512 0x00000009 // Prescale division ratio 512
165 #define AUX_TIMER_PRESCALE_DIV_1028 0x0000000A // Prescale div. ratio 1028
166 #define AUX_TIMER_PRESCALE_DIV_2048 0x0000000B // Prescale div. ratio 2048
167 #define AUX_TIMER_PRESCALE_DIV_4096 0x0000000C // Prescale div. ratio 4096
168 #define AUX_TIMER_PRESCALE_DIV_8192 0x0000000D // Prescale div. ratio 8192
169 #define AUX_TIMER_PRESCALE_DIV_16384 0x0000000E // Prescale div. ratio 16384
170 #define AUX_TIMER_PRESCALE_DIV_32768 0x0000000F // Prescale div. ratio 32768
171 
172 //*****************************************************************************
173 //
174 // API Functions and prototypes
175 //
176 //*****************************************************************************
177 
178 //*****************************************************************************
179 //
257 //
258 //*****************************************************************************
259 extern void AUXTimerConfigure(uint32_t ui32Timer, uint32_t ui32Config);
260 
261 //*****************************************************************************
262 //
277 //
278 //*****************************************************************************
279 extern void AUXTimerStart(uint32_t ui32Timer);
280 
281 //*****************************************************************************
282 //
295 //
296 //*****************************************************************************
297 extern void AUXTimerStop(uint32_t ui32Timer);
298 
299 //*****************************************************************************
300 //
316 //
317 //*****************************************************************************
318 __STATIC_INLINE void
319 AUXTimerTargetValSet(uint32_t ui32Timer, uint32_t ui32Target)
320 {
321  uint32_t ui32Addr;
322 
323  //
324  // Check the arguments.
325  //
326  ASSERT((ui32Timer == AUX_TIMER_0) || (ui32Timer == AUX_TIMER_1));
327  ASSERT(((ui32Timer & AUX_TIMER_0) && (ui32Target <= 65535)) ||
328  ((ui32Timer & AUX_TIMER_1) && (ui32Target <= 255)));
329 
330  ui32Addr = (ui32Timer & AUX_TIMER_0) ?
333 
334  HWREG(ui32Addr) = ui32Target;
335 }
336 
337 //*****************************************************************************
338 //
352 //
353 //*****************************************************************************
354 __STATIC_INLINE uint32_t
355 AUXTimerTargetValGet(uint32_t ui32Timer)
356 {
357  //
358  // Check the arguments.
359  //
360  ASSERT((ui32Timer == AUX_TIMER_0) || (ui32Timer == AUX_TIMER_1));
361 
362  return(HWREG((ui32Timer & AUX_TIMER_0) ?
365 }
366 
367 //*****************************************************************************
368 //
401 //
402 //*****************************************************************************
403 extern void AUXTimerPrescaleSet(uint32_t ui32Timer, uint32_t ui32PrescaleDiv);
404 
405 //*****************************************************************************
406 //
434 //
435 //*****************************************************************************
436 extern uint32_t AUXTimerPrescaleGet(uint32_t ui32Timer);
437 
438 //*****************************************************************************
439 //
440 // Support for DriverLib in ROM:
441 // Redirect to implementation in ROM when available.
442 //
443 //*****************************************************************************
444 #if !defined(DRIVERLIB_NOROM) && !defined(DOXYGEN)
445  #include <driverlib/rom.h>
446  #ifdef ROM_AUXTimerConfigure
447  #undef AUXTimerConfigure
448  #define AUXTimerConfigure ROM_AUXTimerConfigure
449  #endif
450  #ifdef ROM_AUXTimerStart
451  #undef AUXTimerStart
452  #define AUXTimerStart ROM_AUXTimerStart
453  #endif
454  #ifdef ROM_AUXTimerStop
455  #undef AUXTimerStop
456  #define AUXTimerStop ROM_AUXTimerStop
457  #endif
458  #ifdef ROM_AUXTimerPrescaleSet
459  #undef AUXTimerPrescaleSet
460  #define AUXTimerPrescaleSet ROM_AUXTimerPrescaleSet
461  #endif
462  #ifdef ROM_AUXTimerPrescaleGet
463  #undef AUXTimerPrescaleGet
464  #define AUXTimerPrescaleGet ROM_AUXTimerPrescaleGet
465  #endif
466 #endif
467 
468 //*****************************************************************************
469 //
470 // Mark the end of the C bindings section for C++ compilers.
471 //
472 //*****************************************************************************
473 #ifdef __cplusplus
474 }
475 #endif
476 
477 #endif // __AUX_TIMER_H__
478 
479 //*****************************************************************************
480 //
484 //
485 //*****************************************************************************
void AUXTimerPrescaleSet(uint32_t ui32Timer, uint32_t ui32PrescaleDiv)
Set AUX timer prescale value.
Definition: aux_timer.c:269
void AUXTimerConfigure(uint32_t ui32Timer, uint32_t ui32Config)
Configure AUX timer.
Definition: aux_timer.c:66
uint32_t AUXTimerPrescaleGet(uint32_t ui32Timer)
Get AUX timer prescale value.
Definition: aux_timer.c:308
#define AUX_TIMER_0
Definition: aux_timer.h:145
#define ASSERT(expr)
Definition: debug.h:74
void AUXTimerStop(uint32_t ui32Timer)
Stop AUX timer(s).
Definition: aux_timer.c:238
static uint32_t AUXTimerTargetValGet(uint32_t ui32Timer)
Get AUX timer target value.
Definition: aux_timer.h:355
#define AUX_TIMER_1
Definition: aux_timer.h:146
void AUXTimerStart(uint32_t ui32Timer)
Start AUX timer(s).
Definition: aux_timer.c:207
static void AUXTimerTargetValSet(uint32_t ui32Timer, uint32_t ui32Target)
Set AUX timer target value.
Definition: aux_timer.h:319