CC26xx Driver Library
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
aux_timer.h
Go to the documentation of this file.
1 /******************************************************************************
2 * Filename: aux_timer.h
3 * Revised: 2015-01-14 12:12:44 +0100 (on, 14 jan 2015)
4 * Revision: 42373
5 *
6 * Description: Defines and prototypes for the AUX Timer
7 *
8 * Copyright (c) 2015, 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 //
43 //
44 //*****************************************************************************
45 
46 #ifndef __AUX_TIMER_H__
47 #define __AUX_TIMER_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_types.h>
63 #include <inc/hw_ints.h>
64 #include <inc/hw_memmap.h>
65 #include <inc/hw_aux_timer.h>
66 #include <driverlib/debug.h>
67 #include <driverlib/interrupt.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 // Do not define DRIVERLIB_GENERATE_ROM!
82 //
83 //*****************************************************************************
84 #ifndef DRIVERLIB_GENERATE_ROM
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 //*****************************************************************************
97 #define AUX_TIMER_CFG_ONE_SHOT \
98  0x00000000 // One-shot timer mode
99 #define AUX_TIMER_CFG_PERIODIC \
100  0x00000001 // Period timer mode
101 #define AUX_TIMER_CFG_ONE_SHOT_EDGE_COUNT \
102  0x00000002 // One-shot timer with edge count
103 #define AUX_TIMER_CFG_PERIODIC_EDGE_COUNT \
104  0x00000003 // Periodic timer with edge count
105 #define AUX_TIMER_CFG_RISING_EDGE \
106  0x00000000 // Count rising edges (used with
107  // edge count mode)
108 #define AUX_TIMER_CFG_FALLING_EDGE \
109  0x00002000 // Count falling edges (used with
110  // edge count mode)
111 #define AUX_TIMER_CFG_TICK_SRC_RTC_EVENT \
112  0x00000000 // AON wake-up event
113 #define AUX_TIMER_CFG_TICK_SRC_CMP_A \
114  0x00000100 // Comperator A
115 #define AUX_TIMER_CFG_TICK_SRC_CMP_B \
116  0x00000200 // Comperator B
117 #define AUX_TIMER_CFG_TICK_SRC_TDCDONE \
118  0x00000300 // TDC Done
119 #define AUX_TIMER_CFG_TICK_SRC_TIMER0_EVENT \
120  0x00000400 // Timer 0 event
121 #define AUX_TIMER_CFG_TICK_SRC_TIMER1_EVENT \
122  0x00000500 // Timer 1 event
123 #define AUX_TIMER_CFG_TICK_SRC_SMPH_RELEASE \
124  0x00000600 // Semaphore release
125 #define AUX_TIMER_CFG_TICK_SRC_ADC_DONE \
126  0x00000700 // ADC done
127 #define AUX_TIMER_CFG_TICK_SRC_ADC_DONE \
128  0x00000700 // ADC done
129 
130 #define AUX_TIMER_CFG_TICK_SRC_AIO0 \
131  0x00000d00 // AIO_DAT[ 0]
132 #define AUX_TIMER_CFG_TICK_SRC_AIO1 \
133  0x00000e00 // AIO_DAT[ 1]
134 #define AUX_TIMER_CFG_TICK_SRC_AIO2 \
135  0x00000f00 // AIO_DAT[ 2]
136 #define AUX_TIMER_CFG_TICK_SRC_AIO3 \
137  0x00001000 // AIO_DAT[ 3]
138 #define AUX_TIMER_CFG_TICK_SRC_AIO4 \
139  0x00001100 // AIO_DAT[ 4]
140 #define AUX_TIMER_CFG_TICK_SRC_AIO5 \
141  0x00001200 // AIO_DAT[ 5]
142 #define AUX_TIMER_CFG_TICK_SRC_AIO6 \
143  0x00001300 // AIO_DAT[ 6]
144 #define AUX_TIMER_CFG_TICK_SRC_AIO7 \
145  0x00001400 // AIO_DAT[ 7]
146 #define AUX_TIMER_CFG_TICK_SRC_AIO8 \
147  0x00001500 // AIO_DAT[ 8]
148 #define AUX_TIMER_CFG_TICK_SRC_AIO9 \
149  0x00001600 // AIO_DAT[ 9]
150 #define AUX_TIMER_CFG_TICK_SRC_AIO10 \
151  0x00001700 // AIO_DAT[10]
152 #define AUX_TIMER_CFG_TICK_SRC_AIO11 \
153  0x00001800 // AIO_DAT[11]
154 #define AUX_TIMER_CFG_TICK_SRC_AIO12 \
155  0x00001900 // AIO_DAT[12]
156 #define AUX_TIMER_CFG_TICK_SRC_AIO13 \
157  0x00001A00 // AIO_DAT[13]
158 #define AUX_TIMER_CFG_TICK_SRC_AIO14 \
159  0x00001B00 // AIO_DAT[14]
160 #define AUX_TIMER_CFG_TICK_SRC_AIO15 \
161  0x00001C00 // AIO_DAT[15]
162 #define AUX_TIMER_CFG_TICK_SRC_ACLK_REF \
163  0x00001D00 // ACLK_REF_i
164 #define AUX_TIMER_CFG_TICK_SRC_MCU_EVENT \
165  0x00001E00 // MCU event
166 #define AUX_TIMER_CFG_TICK_SRC_ADC_IRQ \
167  0x00001F00 // DMA done
168 
169 //*****************************************************************************
170 //
171 // Values that can be passed to most of the timer APIs as the ui32Timer
172 // parameter.
173 //
174 //*****************************************************************************
175 #define AUX_TIMER_0 0x0000FFFF // AUX Timer 0
176 #define AUX_TIMER_1 0x00FF0000 // AUX Timer 1
177 #define AUX_TIMER_BOTH 0x00FFFFFF // AUX Timer Both 0 and 1
178 
179 //*****************************************************************************
180 //
181 // Values that can be passed to AUXTimerPrescaleSet and returned from
182 // AUXTimerPrescaleGet.
183 //
184 //*****************************************************************************
185 #define AUX_TIMER_PRESCALE_DIV_1 \
186  0x00000000 // Prescale division ratio 1
187 #define AUX_TIMER_PRESCALE_DIV_2 \
188  0x00000010 // Prescale division ratio 2
189 #define AUX_TIMER_PRESCALE_DIV_4 \
190  0x00000020 // Prescale division ratio 4
191 #define AUX_TIMER_PRESCALE_DIV_8 \
192  0x00000030 // Prescale division ratio 8
193 #define AUX_TIMER_PRESCALE_DIV_16 \
194  0x00000040 // Prescale division ratio 16
195 #define AUX_TIMER_PRESCALE_DIV_32 \
196  0x00000050 // Prescale division ratio 32
197 #define AUX_TIMER_PRESCALE_DIV_64 \
198  0x00000060 // Prescale division ratio 64
199 #define AUX_TIMER_PRESCALE_DIV_128 \
200  0x00000070 // Prescale division ratio 128
201 #define AUX_TIMER_PRESCALE_DIV_256 \
202  0x00000080 // Prescale division ratio 256
203 #define AUX_TIMER_PRESCALE_DIV_512 \
204  0x00000090 // Prescale division ratio 512
205 #define AUX_TIMER_PRESCALE_DIV_1028 \
206  0x000000A0 // Prescale div. ratio 1028
207 #define AUX_TIMER_PRESCALE_DIV_2048 \
208  0x000000B0 // Prescale div. ratio 2048
209 #define AUX_TIMER_PRESCALE_DIV_4096 \
210  0x000000C0 // Prescale div. ratio 4096
211 #define AUX_TIMER_PRESCALE_DIV_8192 \
212  0x000000D0 // Prescale div. ratio 8192
213 #define AUX_TIMER_PRESCALE_DIV_16384 \
214  0x000000E0 // Prescale div. ratio 16384
215 #define AUX_TIMER_PRESCALE_DIV_32768 \
216  0x000000F0 // Prescale div. ratio 32768
217 
218 //*****************************************************************************
219 //
220 // API Functions and prototypes
221 //
222 //*****************************************************************************
223 
224 //*****************************************************************************
225 //
298 //
299 //*****************************************************************************
300 extern void AUXTimerConfigure(uint32_t ui32Timer, uint32_t ui32Config);
301 
302 //*****************************************************************************
303 //
318 //
319 //*****************************************************************************
320 extern void AUXTimerStart(uint32_t ui32Timer);
321 
322 //*****************************************************************************
323 //
336 //
337 //*****************************************************************************
338 extern void AUXTimerStop(uint32_t ui32Timer);
339 
340 //*****************************************************************************
341 //
357 //
358 //*****************************************************************************
359 __STATIC_INLINE void
360 AUXTimerTargetValSet(uint32_t ui32Timer, uint32_t ui32Target)
361 {
362  uint32_t ui32Addr;
363 
364  //
365  // Check the arguments.
366  //
367  ASSERT((ui32Timer == AUX_TIMER_0) || (ui32Timer == AUX_TIMER_1));
368  ASSERT(((ui32Timer & AUX_TIMER_0) && (ui32Target <= 65535)) ||
369  ((ui32Timer & AUX_TIMER_1) && (ui32Target <= 255)));
370 
371  ui32Addr = (ui32Timer & AUX_TIMER_0) ?
374 
375  HWREG(ui32Addr) = ui32Target;
376 }
377 
378 //*****************************************************************************
379 //
393 //
394 //*****************************************************************************
395 __STATIC_INLINE uint32_t
396 AUXTimerTargetValGet(uint32_t ui32Timer)
397 {
398  //
399  // Check the arguments.
400  //
401  ASSERT((ui32Timer == AUX_TIMER_0) || (ui32Timer == AUX_TIMER_1));
402 
403  return(HWREG((ui32Timer & AUX_TIMER_0) ?
406 }
407 
408 //*****************************************************************************
409 //
442 //
443 //*****************************************************************************
444 extern void AUXTimerPrescaleSet(uint32_t ui32Timer, uint32_t ui32PrescaleDiv);
445 
446 //*****************************************************************************
447 //
475 //
476 //*****************************************************************************
477 extern uint32_t AUXTimerPrescaleGet(uint32_t ui32Timer);
478 
479 //*****************************************************************************
480 //
481 // Support for DriverLib in ROM:
482 // Redirect to implementation in ROM when available.
483 //
484 //*****************************************************************************
485 #ifndef DRIVERLIB_NOROM
486  #include <driverlib/rom.h>
487  #ifdef ROM_AUXTimerConfigure
488  #undef AUXTimerConfigure
489  #define AUXTimerConfigure ROM_AUXTimerConfigure
490  #endif
491  #ifdef ROM_AUXTimerStart
492  #undef AUXTimerStart
493  #define AUXTimerStart ROM_AUXTimerStart
494  #endif
495  #ifdef ROM_AUXTimerStop
496  #undef AUXTimerStop
497  #define AUXTimerStop ROM_AUXTimerStop
498  #endif
499  #ifdef ROM_AUXTimerPrescaleSet
500  #undef AUXTimerPrescaleSet
501  #define AUXTimerPrescaleSet ROM_AUXTimerPrescaleSet
502  #endif
503  #ifdef ROM_AUXTimerPrescaleGet
504  #undef AUXTimerPrescaleGet
505  #define AUXTimerPrescaleGet ROM_AUXTimerPrescaleGet
506  #endif
507 #endif
508 
509 //*****************************************************************************
510 //
511 // Mark the end of the C bindings section for C++ compilers.
512 //
513 //*****************************************************************************
514 #ifdef __cplusplus
515 }
516 #endif
517 
518 #endif // __AUX_TIMER_H__
519 
520 //*****************************************************************************
521 //
524 //
525 //*****************************************************************************
#define ASSERT(expr)
Definition: debug.h:65
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:175
void AUXTimerStop(uint32_t ui32Timer)
Stop AUX timer(s).
Definition: aux_timer.c:238
__STATIC_INLINE void AUXTimerTargetValSet(uint32_t ui32Timer, uint32_t ui32Target)
Set AUX timer target value.
Definition: aux_timer.h:360
__STATIC_INLINE uint32_t AUXTimerTargetValGet(uint32_t ui32Timer)
Get AUX timer target value.
Definition: aux_timer.h:396
#define AUX_TIMER_1
Definition: aux_timer.h:176
void AUXTimerStart(uint32_t ui32Timer)
Start AUX timer(s).
Definition: aux_timer.c:207