CC26xx Driver Library |

- Main Page
- Related Pages
- CC26xx APIs
- Register Descriptions
- Online Resources

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
aux_timer.c
Go to the documentation of this file.
1 /******************************************************************************
2 * Filename: aux_timer.c
3 * Revised: 2015-01-13 16:59:55 +0100 (ti, 13 jan 2015)
4 * Revision: 42365
5 *
6 * Description: Driver for the AUX Timer Module
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 #include <driverlib/aux_timer.h>
40
41 //*****************************************************************************
42 //
43 // Handle support for DriverLib in ROM:
44 // This section will undo prototype renaming made in the header file
45 //
46 //*****************************************************************************
47 #ifndef DRIVERLIB_GENERATE_ROM
48 #undef AUXTimerConfigure
49 #define AUXTimerConfigure NOROM_AUXTimerConfigure
50 #undef AUXTimerStart
51 #define AUXTimerStart NOROM_AUXTimerStart
52 #undef AUXTimerStop
53 #define AUXTimerStop NOROM_AUXTimerStop
54 #undef AUXTimerPrescaleSet
55 #define AUXTimerPrescaleSet NOROM_AUXTimerPrescaleSet
56 #undef AUXTimerPrescaleGet
57 #define AUXTimerPrescaleGet NOROM_AUXTimerPrescaleGet
58 #endif
59
60 //*****************************************************************************
61 //
63 //
64 //*****************************************************************************
65 void
66 AUXTimerConfigure(uint32_t ui32Timer, uint32_t ui32Config)
67 {
68 uint32_t ui32Val;
69
70 //
71 // Check the arguments.
72 //
73 ASSERT((ui32Timer == AUX_TIMER_0) || (ui32Timer == AUX_TIMER_1) ||
74 (ui32Timer == AUX_TIMER_BOTH));
75 ASSERT(((ui32Config & 0x0000000F) == AUX_TIMER_CFG_ONE_SHOT) ||
76 ((ui32Config & 0x0000000F) == AUX_TIMER_CFG_PERIODIC) ||
77 ((ui32Config & 0x0000000F) == AUX_TIMER_CFG_ONE_SHOT_EDGE_COUNT) ||
78 ((ui32Config & 0x0000000F) == AUX_TIMER_CFG_PERIODIC_EDGE_COUNT) ||
79 ((ui32Config & 0x000000F0) == AUX_TIMER_CFG_RISING_EDGE) ||
80 ((ui32Config & 0x000000F0) == AUX_TIMER_CFG_FALLING_EDGE) ||
81 ((ui32Config & 0x00000F00) == AUX_TIMER_CFG_TICK_SRC_RTC_EVENT) ||
82 ((ui32Config & 0x00000F00) == AUX_TIMER_CFG_TICK_SRC_CMP_A) ||
83 ((ui32Config & 0x00000F00) == AUX_TIMER_CFG_TICK_SRC_CMP_B) ||
84 ((ui32Config & 0x00000F00) == AUX_TIMER_CFG_TICK_SRC_TDCDONE) ||
85 ((ui32Config & 0x00000F00) == AUX_TIMER_CFG_TICK_SRC_TIMER0_EVENT) ||
86 ((ui32Config & 0x00000F00) == AUX_TIMER_CFG_TICK_SRC_TIMER1_EVENT) ||
87 ((ui32Config & 0x00000F00) == AUX_TIMER_CFG_TICK_SRC_SMPH_RELEASE) ||
88 ((ui32Config & 0x00000F00) == AUX_TIMER_CFG_TICK_SRC_ADC_DONE) ||
89 ((ui32Config & 0x00000F00) == AUX_TIMER_CFG_TICK_SRC_AIO0) ||
90 ((ui32Config & 0x00000F00) == AUX_TIMER_CFG_TICK_SRC_AIO1) ||
91 ((ui32Config & 0x00000F00) == AUX_TIMER_CFG_TICK_SRC_AIO2) ||
92 ((ui32Config & 0x00000F00) == AUX_TIMER_CFG_TICK_SRC_AIO3) ||
93 ((ui32Config & 0x00000F00) == AUX_TIMER_CFG_TICK_SRC_AIO4) ||
94 ((ui32Config & 0x00000F00) == AUX_TIMER_CFG_TICK_SRC_AIO5) ||
95 ((ui32Config & 0x00000F00) == AUX_TIMER_CFG_TICK_SRC_AIO6) ||
96 ((ui32Config & 0x00000F00) == AUX_TIMER_CFG_TICK_SRC_AIO7) ||
97 ((ui32Config & 0x00000F00) == AUX_TIMER_CFG_TICK_SRC_AIO8) ||
98 ((ui32Config & 0x00000F00) == AUX_TIMER_CFG_TICK_SRC_AIO9) ||
99 ((ui32Config & 0x00000F00) == AUX_TIMER_CFG_TICK_SRC_AIO10) ||
100 ((ui32Config & 0x00000F00) == AUX_TIMER_CFG_TICK_SRC_AIO11) ||
101 ((ui32Config & 0x00000F00) == AUX_TIMER_CFG_TICK_SRC_AIO12) ||
102 ((ui32Config & 0x00000F00) == AUX_TIMER_CFG_TICK_SRC_AIO13) ||
103 ((ui32Config & 0x00000F00) == AUX_TIMER_CFG_TICK_SRC_AIO14) ||
104 ((ui32Config & 0x00000F00) == AUX_TIMER_CFG_TICK_SRC_AIO15) ||
105 ((ui32Config & 0x00000F00) == AUX_TIMER_CFG_TICK_SRC_ACLK_REF) ||
106 ((ui32Config & 0x00000F00) == AUX_TIMER_CFG_TICK_SRC_MCU_EVENT) ||
107 ((ui32Config & 0x00000F00) == AUX_TIMER_CFG_TICK_SRC_ADC_IRQ));
108
109 //
110 // Configure Timer 0.
111 //
112 if(ui32Timer & AUX_TIMER_0)
113 {
114 //
115 // Stop timer 0.
116 //
117 HWREG(AUX_TIMER_BASE + AUX_TIMER_O_T0CTL) = 0;
118
119 //
120 // Set mode.
121 //
122 ui32Val = HWREG(AUX_TIMER_BASE + AUX_TIMER_O_T0CFG);
123 ui32Val &= ~(AUX_TIMER_T0CFG_MODE_M | AUX_TIMER_T0CFG_RELOAD_M);
124 ui32Val |= (ui32Config & (AUX_TIMER_T0CFG_MODE_M |
125 AUX_TIMER_T0CFG_RELOAD_M));
126 HWREG(AUX_TIMER_BASE + AUX_TIMER_O_T0CFG) = ui32Val;
127
128 //
129 // If edge counter, set rising/falling edge and tick source.
130 //
131 if(ui32Config & AUX_TIMER_T0CFG_MODE_M)
132 {
133 ui32Val = HWREG(AUX_TIMER_BASE + AUX_TIMER_O_T0CFG);
134 ui32Val &= ~(AUX_TIMER_T0CFG_TICK_SRC_POL_M |
135 AUX_TIMER_T0CFG_TICK_SRC_M);
136
137 //
138 // Set edge polarity.
139 //
140 if(ui32Config & AUX_TIMER_CFG_FALLING_EDGE)
141 {
142 ui32Val |= AUX_TIMER_T0CFG_TICK_SRC_POL;
143 }
144
145 //
146 // Set tick source.
147 //
148 ui32Val |= ((ui32Config & 0x00000F00) >> 8) <<
149 AUX_TIMER_T0CFG_TICK_SRC_S;
150
151 HWREG(AUX_TIMER_BASE + AUX_TIMER_O_T0CFG) = ui32Val;
152 }
153 }
154
155 //
156 // Configure Timer 1.
157 //
158 if(ui32Timer & AUX_TIMER_1)
159 {
160 //
161 // Stop timer 1.
162 //
163 HWREG(AUX_TIMER_BASE + AUX_TIMER_O_T1CTL) = 0;
164
165 //
166 // Set mode.
167 //
168 ui32Val = HWREG(AUX_TIMER_BASE + AUX_TIMER_O_T1CFG);
169 ui32Val &= ~(AUX_TIMER_T1CFG_MODE_M | AUX_TIMER_T1CFG_RELOAD_M);
170 ui32Val |= ((ui32Config) & (AUX_TIMER_T1CFG_MODE_M |
171 AUX_TIMER_T1CFG_RELOAD_M));
172 HWREG(AUX_TIMER_BASE + AUX_TIMER_O_T1CFG) = ui32Val;
173
174 //
175 // If edge counter, set rising/falling edge and tick source.
176 //
177 if(ui32Config & AUX_TIMER_T1CFG_MODE)
178 {
179 ui32Val = HWREG(AUX_TIMER_BASE + AUX_TIMER_O_T1CFG);
180 ui32Val &= ~(AUX_TIMER_T1CFG_TICK_SRC_POL_M |
181 AUX_TIMER_T1CFG_TICK_SRC_M);
182
183 //
184 // Set edge polarity.
185 //
186 if(ui32Config & AUX_TIMER_CFG_FALLING_EDGE)
187 {
188 ui32Val |= AUX_TIMER_T1CFG_TICK_SRC_POL;
189 }
190
191 //
192 // Set tick source.
193 //
194 ui32Val |= ((ui32Config & 0x00000F00) >> 8) <<
195 AUX_TIMER_T1CFG_TICK_SRC_S;
196 HWREG(AUX_TIMER_BASE + AUX_TIMER_O_T1CFG) = ui32Val;
197 }
198 }
199 }
200
201 //*****************************************************************************
202 //
204 //
205 //*****************************************************************************
206 void
207 AUXTimerStart(uint32_t ui32Timer)
208 {
209 //
210 // Check the arguments.
211 //
212 ASSERT((ui32Timer == AUX_TIMER_0) ||
213 (ui32Timer == AUX_TIMER_1) ||
214 (ui32Timer == AUX_TIMER_BOTH));
215
216 if(ui32Timer & AUX_TIMER_0)
217 {
218 //
219 // Start timer 0.
220 //
221 HWREG(AUX_TIMER_BASE + AUX_TIMER_O_T0CTL) = AUX_TIMER_T0CTL_EN;
222 }
223 if(ui32Timer & AUX_TIMER_1)
224 {
225 //
226 // Start timer 1.
227 //
228 HWREG(AUX_TIMER_BASE + AUX_TIMER_O_T1CTL) = AUX_TIMER_T1CTL_EN;
229 }
230 }
231
232 //*****************************************************************************
233 //
235 //
236 //*****************************************************************************
237 void
238 AUXTimerStop(uint32_t ui32Timer)
239 {
240 //
241 // Check the arguments.
242 //
243 ASSERT((ui32Timer == AUX_TIMER_0) ||
244 (ui32Timer == AUX_TIMER_1) ||
245 (ui32Timer == AUX_TIMER_BOTH));
246
247 if(ui32Timer & AUX_TIMER_0)
248 {
249 //
250 // Stop timer 0.
251 //
252 HWREG(AUX_TIMER_BASE + AUX_TIMER_O_T0CTL) = 0;
253 }
254 if(ui32Timer & AUX_TIMER_1)
255 {
256 //
257 // Stop timer 1.
258 //
259 HWREG(AUX_TIMER_BASE + AUX_TIMER_O_T1CTL) = 0;
260 }
261 }
262
263 //*****************************************************************************
264 //
266 //
267 //*****************************************************************************
268 void
269 AUXTimerPrescaleSet(uint32_t ui32Timer, uint32_t ui32PrescaleDiv)
270 {
271 uint32_t ui32Val;
272
273 //
274 // Check the arguments.
275 //
276 ASSERT((ui32Timer == AUX_TIMER_0) || (ui32Timer == AUX_TIMER_1) ||
277 (ui32Timer == AUX_TIMER_BOTH));
278 ASSERT(ui32PrescaleDiv <= AUX_TIMER_PRESCALE_DIV_32768);
279
280 if(ui32Timer & AUX_TIMER_0)
281 {
282 //
283 // Set timer 0 prescale value.
284 //
285 ui32Val = HWREG(AUX_TIMER_BASE + AUX_TIMER_O_T0CFG);
286 ui32Val &= ~AUX_TIMER_T0CFG_PRE_M;
287 ui32Val |= ui32PrescaleDiv << AUX_TIMER_T0CFG_PRE_S;
288 HWREG(AUX_TIMER_BASE + AUX_TIMER_O_T0CFG) = ui32Val;
289 }
290 if(ui32Timer & AUX_TIMER_1)
291 {
292 //
293 // Set timer 1 prescale value.
294 //
295 ui32Val = HWREG(AUX_TIMER_BASE + AUX_TIMER_O_T1CFG);
296 ui32Val &= ~AUX_TIMER_T1CFG_PRE_M;
297 ui32Val |= ui32PrescaleDiv << AUX_TIMER_T1CFG_PRE_S;
298 HWREG(AUX_TIMER_BASE + AUX_TIMER_O_T1CFG) = ui32Val;
299 }
300 }
301
302 //*****************************************************************************
303 //
305 //
306 //*****************************************************************************
307 uint32_t
308 AUXTimerPrescaleGet(uint32_t ui32Timer)
309 {
310 uint32_t ui32Val;
311 uint32_t ui32PrescaleDiv;
312
313 //
314 // Check the arguments.
315 //
316 ASSERT((ui32Timer == AUX_TIMER_0) || (ui32Timer == AUX_TIMER_1));
317
318 ui32Val = (HWREG(AUX_TIMER_BASE + AUX_TIMER_O_T0CFG));
319 if(ui32Timer & AUX_TIMER_0)
320 {
321 //
322 // Get timer 0 prescale value.
323 //
324 ui32PrescaleDiv =
325 (ui32Val & AUX_TIMER_T0CFG_PRE_M) >> AUX_TIMER_T0CFG_PRE_S;
326 }
327 else
328 {
329 //
330 // Get timer 1 prescale value.
331 //
332 ui32PrescaleDiv =
333 (ui32Val & AUX_TIMER_T1CFG_PRE_M) >> AUX_TIMER_T1CFG_PRE_S;
334 }
335
336 return(ui32PrescaleDiv);
337 }
AUX_TIMER_CFG_TICK_SRC_AIO1
#define AUX_TIMER_CFG_TICK_SRC_AIO1
Definition: aux_timer.h:132
AUX_TIMER_CFG_ONE_SHOT_EDGE_COUNT
#define AUX_TIMER_CFG_ONE_SHOT_EDGE_COUNT
Definition: aux_timer.h:101
AUX_TIMER_CFG_TICK_SRC_AIO5
#define AUX_TIMER_CFG_TICK_SRC_AIO5
Definition: aux_timer.h:140
AUX_TIMER_CFG_TICK_SRC_AIO6
#define AUX_TIMER_CFG_TICK_SRC_AIO6
Definition: aux_timer.h:142
AUX_TIMER_CFG_TICK_SRC_AIO7
#define AUX_TIMER_CFG_TICK_SRC_AIO7
Definition: aux_timer.h:144
AUX_TIMER_CFG_ONE_SHOT
#define AUX_TIMER_CFG_ONE_SHOT
Definition: aux_timer.h:97
AUX_TIMER_CFG_TICK_SRC_AIO15
#define AUX_TIMER_CFG_TICK_SRC_AIO15
Definition: aux_timer.h:160
AUX_TIMER_BOTH
#define AUX_TIMER_BOTH
Definition: aux_timer.h:177
ASSERT
#define ASSERT(expr)
Definition: debug.h:65
AUXTimerPrescaleSet
void AUXTimerPrescaleSet(uint32_t ui32Timer, uint32_t ui32PrescaleDiv)
Set AUX timer prescale value.
Definition: aux_timer.c:269
AUX_TIMER_CFG_TICK_SRC_ACLK_REF
#define AUX_TIMER_CFG_TICK_SRC_ACLK_REF
Definition: aux_timer.h:162
AUX_TIMER_PRESCALE_DIV_32768
#define AUX_TIMER_PRESCALE_DIV_32768
Definition: aux_timer.h:215
AUX_TIMER_CFG_TICK_SRC_MCU_EVENT
#define AUX_TIMER_CFG_TICK_SRC_MCU_EVENT
Definition: aux_timer.h:164
AUX_TIMER_CFG_TICK_SRC_AIO8
#define AUX_TIMER_CFG_TICK_SRC_AIO8
Definition: aux_timer.h:146
AUX_TIMER_CFG_RISING_EDGE
#define AUX_TIMER_CFG_RISING_EDGE
Definition: aux_timer.h:105
AUXTimerConfigure
void AUXTimerConfigure(uint32_t ui32Timer, uint32_t ui32Config)
Configure AUX timer.
Definition: aux_timer.c:66
AUXTimerPrescaleGet
uint32_t AUXTimerPrescaleGet(uint32_t ui32Timer)
Get AUX timer prescale value.
Definition: aux_timer.c:308
AUX_TIMER_CFG_FALLING_EDGE
#define AUX_TIMER_CFG_FALLING_EDGE
Definition: aux_timer.h:108
AUX_TIMER_0
#define AUX_TIMER_0
Definition: aux_timer.h:175
AUX_TIMER_CFG_TICK_SRC_CMP_B
#define AUX_TIMER_CFG_TICK_SRC_CMP_B
Definition: aux_timer.h:115
AUX_TIMER_CFG_TICK_SRC_SMPH_RELEASE
#define AUX_TIMER_CFG_TICK_SRC_SMPH_RELEASE
Definition: aux_timer.h:123
AUX_TIMER_CFG_PERIODIC
#define AUX_TIMER_CFG_PERIODIC
Definition: aux_timer.h:99
AUX_TIMER_CFG_TICK_SRC_AIO3
#define AUX_TIMER_CFG_TICK_SRC_AIO3
Definition: aux_timer.h:136
AUX_TIMER_CFG_TICK_SRC_TDCDONE
#define AUX_TIMER_CFG_TICK_SRC_TDCDONE
Definition: aux_timer.h:117
AUXTimerStop
void AUXTimerStop(uint32_t ui32Timer)
Stop AUX timer.
Definition: aux_timer.c:238
AUX_TIMER_CFG_TICK_SRC_RTC_EVENT
#define AUX_TIMER_CFG_TICK_SRC_RTC_EVENT
Definition: aux_timer.h:111
AUX_TIMER_CFG_TICK_SRC_AIO2
#define AUX_TIMER_CFG_TICK_SRC_AIO2
Definition: aux_timer.h:134
AUX_TIMER_CFG_TICK_SRC_AIO9
#define AUX_TIMER_CFG_TICK_SRC_AIO9
Definition: aux_timer.h:148
AUX_TIMER_CFG_TICK_SRC_AIO4
#define AUX_TIMER_CFG_TICK_SRC_AIO4
Definition: aux_timer.h:138
AUX_TIMER_CFG_TICK_SRC_ADC_IRQ
#define AUX_TIMER_CFG_TICK_SRC_ADC_IRQ
Definition: aux_timer.h:166
AUX_TIMER_CFG_PERIODIC_EDGE_COUNT
#define AUX_TIMER_CFG_PERIODIC_EDGE_COUNT
Definition: aux_timer.h:103
AUX_TIMER_CFG_TICK_SRC_AIO0
#define AUX_TIMER_CFG_TICK_SRC_AIO0
Definition: aux_timer.h:130
AUX_TIMER_CFG_TICK_SRC_ADC_DONE
#define AUX_TIMER_CFG_TICK_SRC_ADC_DONE
Definition: aux_timer.h:127
aux_timer.h
AUX_TIMER_CFG_TICK_SRC_AIO12
#define AUX_TIMER_CFG_TICK_SRC_AIO12
Definition: aux_timer.h:154
AUX_TIMER_1
#define AUX_TIMER_1
Definition: aux_timer.h:176
AUXTimerStart
void AUXTimerStart(uint32_t ui32Timer)
Start AUX timer.
Definition: aux_timer.c:207
AUX_TIMER_CFG_TICK_SRC_AIO13
#define AUX_TIMER_CFG_TICK_SRC_AIO13
Definition: aux_timer.h:156
AUX_TIMER_CFG_TICK_SRC_CMP_A
#define AUX_TIMER_CFG_TICK_SRC_CMP_A
Definition: aux_timer.h:113
AUX_TIMER_CFG_TICK_SRC_AIO10
#define AUX_TIMER_CFG_TICK_SRC_AIO10
Definition: aux_timer.h:150
AUX_TIMER_CFG_TICK_SRC_AIO14
#define AUX_TIMER_CFG_TICK_SRC_AIO14
Definition: aux_timer.h:158
AUX_TIMER_CFG_TICK_SRC_TIMER1_EVENT
#define AUX_TIMER_CFG_TICK_SRC_TIMER1_EVENT
Definition: aux_timer.h:121
AUX_TIMER_CFG_TICK_SRC_AIO11
#define AUX_TIMER_CFG_TICK_SRC_AIO11
Definition: aux_timer.h:152
AUX_TIMER_CFG_TICK_SRC_TIMER0_EVENT
#define AUX_TIMER_CFG_TICK_SRC_TIMER0_EVENT
Definition: aux_timer.h:119