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
osc.h
Go to the documentation of this file.
1 /******************************************************************************
2 * Filename: osc.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 system oscillator control.
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 __OSC_H__
47 #define __OSC_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_memmap.h>
64 #include <inc/hw_ddi.h>
65 #include <inc/hw_ddi_0_osc.h>
66 #include <driverlib/aon_wuc.h>
67 #include <driverlib/aux_wuc.h>
68 #include <driverlib/rom.h>
69 #include <driverlib/ddi.h>
70 #include <driverlib/debug.h>
71
72 //*****************************************************************************
73 //
74 // Support for DriverLib in ROM:
75 // This section renames all functions that are not "static inline", so that
76 // calling these functions will default to implementation in flash. At the end
77 // of this file a second renaming will change the defaults to implementation in
78 // ROM for available functions.
79 //
80 // To force use of the implementation in flash, e.g. for debugging:
81 // - Globally: Define DRIVERLIB_NOROM at project level
82 // - Per function: Use prefix "NOROM_" when calling the function
83 //
84 // Do not define DRIVERLIB_GENERATE_ROM!
85 //
86 //*****************************************************************************
87 #ifndef DRIVERLIB_GENERATE_ROM
88 #define OSCClockSourceSet NOROM_OSCClockSourceSet
89 #define OSCClockSourceGet NOROM_OSCClockSourceGet
90 #define OSCInterfaceEnable NOROM_OSCInterfaceEnable
91 #endif
92
93 //*****************************************************************************
94 //
95 // Defines for the High Frequency XTAL Power mode
96 //
97 //*****************************************************************************
98 #define LOW_POWER_XOSC 1
99 #define HIGH_POWER_XOSC 0
100
101 //*****************************************************************************
102 //
103 // Defines for the High Frequency XTAL Power mode
104 //
105 //*****************************************************************************
106 #define OSC_SRC_CLK_HF 0x00000001
107 #define OSC_SRC_CLK_MF 0x00000002
108 #define OSC_SRC_CLK_LF 0x00000004
109
110 #define OSC_RCOSC_HF 0x00000000
111 #define OSC_XOSC_HF 0x00000001
112 #define OSC_RCOSC_LF 0x00000002
113 #define OSC_XOSC_LF 0x00000003
114
115 #define SCLK_HF_RCOSC_HF 0
116 #define SCLK_HF_XOSC_HF 1
117
118 #define SCLK_MF_RCOSC_HF 0
119 #define SCLK_MF_XOSC_HF 1
120
121 #define SCLK_LF_FROM_RCOSC_HF 0
122 #define SCLK_LF_FROM_XOSC_HF 1
123 #define SCLK_LF_FROM_RCOSC_LF 2
124 #define SCLK_LF_FROM_XOSC_LF 3
125
126 //*****************************************************************************
127 //
128 // API Functions and prototypes
129 //
130 //*****************************************************************************
131
132 //*****************************************************************************
133 //
141 //
142 //*****************************************************************************
143 __STATIC_INLINE void
144 OSCXHfPowerModeSet(uint32_t ui32Mode)
145 {
146 //
147 // Check the arguments.
148 //
149 ASSERT((ui32Mode == LOW_POWER_XOSC) ||
150 (ui32Mode == HIGH_POWER_XOSC));
151
152 //
153 // Change the power mode.
154 //
155 DDI16BitWrite(AUX_DDI0_OSC_BASE, DDI_0_OSC_O_CTL0, DDI_0_OSC_CTL0_XOSC_HF_POWER_MODE,
156 ui32Mode);
157 }
158
159 //*****************************************************************************
160 //
192 //
193 //*****************************************************************************
194 extern void OSCClockSourceSet(uint32_t ui32SrcClk, uint32_t ui32Osc);
195
196 //*****************************************************************************
197 //
215 //
216 //*****************************************************************************
217 extern uint32_t OSCClockSourceGet(uint32_t ui32SrcClk);
218
219 //*****************************************************************************
220 //
232 //
233 //*****************************************************************************
234 __STATIC_INLINE bool
235 OSCHfSourceReady(void)
236 {
237 //
238 // Return the readyness of the HF clock source
239 //
240 return (DDI16BitfieldRead(AUX_DDI0_OSC_BASE, DDI_0_OSC_O_STAT0,
241 DDI_0_OSC_STAT0_PENDINGSCLKHFSWITCHING_M,
242 DDI_0_OSC_STAT0_PENDINGSCLKHFSWITCHING_S)) ?
243 true : false;
244 }
245
246 //*****************************************************************************
247 //
262 //
263 //*****************************************************************************
264 __STATIC_INLINE void
265 OSCHfSourceSwitch(void)
266 {
267 //
268 // Switch the HF clock source
269 //
270 HapiHFSourceSafeSwitch();
271 }
272
273 //*****************************************************************************
274 //
285 //
286 //*****************************************************************************
287 extern void OSCInterfaceEnable(void);
288
289 //*****************************************************************************
290 //
300 //
301 //*****************************************************************************
302 __STATIC_INLINE void
303 OSCInterfaceDisable(void)
304 {
305 //
306 // Disable clock for OSC_DIG
307 //
308 AUXWUCClockDisable(AUX_WUC_OSCCTRL_CLOCK);
309
310 //
311 // Release the 'force power' on AUX
312 //
313 AONWUCAuxWakeupEvent(AONWUC_AUX_ALLOW_SLEEP);
314 }
315
316
317 //*****************************************************************************
318 //
328 //
329 //*****************************************************************************
330 uint32_t OSCHF_GetStartupTime( uint32_t timeUntilWakeupInMs );
331
332
333 //*****************************************************************************
334 //
341 //
342 //*****************************************************************************
343 void OSCHF_TurnOnXosc( void );
344
345
346 //*****************************************************************************
347 //
357 //
358 //*****************************************************************************
359 bool OSCHF_AttemptToSwitchToXosc( void );
360
361
362 //*****************************************************************************
363 //
370 //
371 //*****************************************************************************
372 void OSCHF_SwitchToRcOscTurnOffXosc( void );
373
374
375 //*****************************************************************************
376 //
377 // Support for DriverLib in ROM:
378 // Redirect to implementation in ROM when available.
379 //
380 //*****************************************************************************
381 #ifndef DRIVERLIB_NOROM
382 #include <driverlib/rom.h>
383 #ifdef ROM_OSCClockSourceSet
384 #undef OSCClockSourceSet
385 #define OSCClockSourceSet ROM_OSCClockSourceSet
386 #endif
387 #ifdef ROM_OSCClockSourceGet
388 #undef OSCClockSourceGet
389 #define OSCClockSourceGet ROM_OSCClockSourceGet
390 #endif
391 #ifdef ROM_OSCInterfaceEnable
392 #undef OSCInterfaceEnable
393 #define OSCInterfaceEnable ROM_OSCInterfaceEnable
394 #endif
395 #endif
396
397 //*****************************************************************************
398 //
399 // Mark the end of the C bindings section for C++ compilers.
400 //
401 //*****************************************************************************
402 #ifdef __cplusplus
403 }
404 #endif
405
406
407 #endif // __OSC_H__
408
409 //*****************************************************************************
410 //
413 //
414 //*****************************************************************************
LOW_POWER_XOSC
#define LOW_POWER_XOSC
Definition: osc.h:98
DDI16BitWrite
void DDI16BitWrite(uint32_t ui32Base, uint32_t ui32Reg, uint32_t ui32Mask, uint32_t ui32WrData)
Write a single bit using a 16-bit maskable write.
Definition: ddi.c:64
HIGH_POWER_XOSC
#define HIGH_POWER_XOSC
Definition: osc.h:99
OSCXHfPowerModeSet
__STATIC_INLINE void OSCXHfPowerModeSet(uint32_t ui32Mode)
Set Power Mode for High Frequency XTAL Oscillator.
Definition: osc.h:144
debug.h
AUX_WUC_OSCCTRL_CLOCK
#define AUX_WUC_OSCCTRL_CLOCK
Definition: aux_wuc.h:109
OSCClockSourceGet
uint32_t OSCClockSourceGet(uint32_t ui32SrcClk)
Get the source clock settings.
Definition: osc.c:155
ASSERT
#define ASSERT(expr)
Definition: debug.h:65
AUXWUCClockDisable
void AUXWUCClockDisable(uint32_t ui32Clocks)
Disable clocks for peripherals in the AUX domain.
Definition: aux_wuc.c:113
OSCInterfaceEnable
void OSCInterfaceEnable(void)
Enable CM3 access to the OSC_DIG module.
Definition: osc.c:189
OSCHF_GetStartupTime
uint32_t OSCHF_GetStartupTime(uint32_t timeUntilWakeupInMs)
Returns maximum startup time (in microseconds) of XOSC_HF.
Definition: osc.c:213
OSCHfSourceReady
__STATIC_INLINE bool OSCHfSourceReady(void)
Check if the HF clock source is ready to be switched.
Definition: osc.h:235
OSCHF_AttemptToSwitchToXosc
bool OSCHF_AttemptToSwitchToXosc(void)
Switch to XOSC_HF if XOSC_HF is ready.
Definition: osc.c:275
AONWUC_AUX_ALLOW_SLEEP
#define AONWUC_AUX_ALLOW_SLEEP
Definition: aon_wuc.h:159
DDI16BitfieldRead
uint16_t DDI16BitfieldRead(uint32_t ui32Base, uint32_t ui32Reg, uint32_t ui32Mask, uint32_t ui32Shift)
Read a bitfield via the DDI using 16-bit read.
Definition: ddi.c:198
ddi.h
AONWUCAuxWakeupEvent
void AONWUCAuxWakeupEvent(uint32_t ui32Mode)
Control the wake up procedure of the AUX domain.
Definition: aon_wuc.c:158
OSCInterfaceDisable
__STATIC_INLINE void OSCInterfaceDisable(void)
Disable CM3 access to the OSC_DIG module.
Definition: osc.h:303
aon_wuc.h
OSCHF_SwitchToRcOscTurnOffXosc
void OSCHF_SwitchToRcOscTurnOffXosc(void)
Switch to RCOSC_HF and turn off XOSC_HF.
Definition: osc.c:310
rom.h
OSCClockSourceSet
void OSCClockSourceSet(uint32_t ui32SrcClk, uint32_t ui32Osc)
Configure the oscillator input to the a source clock.
Definition: osc.c:85
OSCHfSourceSwitch
__STATIC_INLINE void OSCHfSourceSwitch(void)
Switch the high frequency clock.
Definition: osc.h:265
HapiHFSourceSafeSwitch
#define HapiHFSourceSafeSwitch()
Definition: rom.h:190
OSCHF_TurnOnXosc
void OSCHF_TurnOnXosc(void)
Turns on XOSC_HF (but without switching to XOSC_HF).
Definition: osc.c:262
aux_wuc.h