CC26xx Driver Library
osc.h
Go to the documentation of this file.
1 /******************************************************************************
2 * Filename: osc.h
3 * Revised: 2015-11-11 17:32:44 +0100 (Wed, 11 Nov 2015)
4 * Revision: 45043
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 //
45 //
46 //*****************************************************************************
47 
48 #ifndef __OSC_H__
49 #define __OSC_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_memmap.h>
66 #include <inc/hw_ddi.h>
67 #include <inc/hw_ddi_0_osc.h>
68 #include <driverlib/aon_wuc.h>
69 #include <driverlib/aux_wuc.h>
70 #include <driverlib/rom.h>
71 #include <driverlib/ddi.h>
72 #include <driverlib/debug.h>
73 
74 //*****************************************************************************
75 //
76 // Support for DriverLib in ROM:
77 // This section renames all functions that are not "static inline", so that
78 // calling these functions will default to implementation in flash. At the end
79 // of this file a second renaming will change the defaults to implementation in
80 // ROM for available functions.
81 //
82 // To force use of the implementation in flash, e.g. for debugging:
83 // - Globally: Define DRIVERLIB_NOROM at project level
84 // - Per function: Use prefix "NOROM_" when calling the function
85 //
86 //*****************************************************************************
87 #if !defined(DOXYGEN)
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  //
156  ui32Mode);
157 }
158 
159 //*****************************************************************************
160 //
172 //
173 //*****************************************************************************
174 __STATIC_INLINE void
176 {
180 }
181 
182 //*****************************************************************************
183 //
195 //
196 //*****************************************************************************
197 __STATIC_INLINE void
199 {
203 }
204 
205 //*****************************************************************************
206 //
241 //
242 //*****************************************************************************
243 extern void OSCClockSourceSet(uint32_t ui32SrcClk, uint32_t ui32Osc);
244 
245 //*****************************************************************************
246 //
264 //
265 //*****************************************************************************
266 extern uint32_t OSCClockSourceGet(uint32_t ui32SrcClk);
267 
268 //*****************************************************************************
269 //
281 //
282 //*****************************************************************************
283 __STATIC_INLINE bool
285 {
286  //
287  // Return the readiness of the HF clock source
288  //
292  true : false;
293 }
294 
295 //*****************************************************************************
296 //
311 //
312 //*****************************************************************************
313 __STATIC_INLINE void
315 {
316  //
317  // Switch the HF clock source
318  //
320 }
321 
322 //*****************************************************************************
323 //
334 //
335 //*****************************************************************************
336 extern void OSCInterfaceEnable(void);
337 
338 //*****************************************************************************
339 //
349 //
350 //*****************************************************************************
351 __STATIC_INLINE void
353 {
354  //
355  // Disable clock for OSC_DIG
356  //
358 
359  //
360  // Release the 'force power' on AUX
361  //
363 }
364 
365 
366 //*****************************************************************************
367 //
377 //
378 //*****************************************************************************
379 uint32_t OSCHF_GetStartupTime( uint32_t timeUntilWakeupInMs );
380 
381 
382 //*****************************************************************************
383 //
390 //
391 //*****************************************************************************
392 void OSCHF_TurnOnXosc( void );
393 
394 
395 //*****************************************************************************
396 //
406 //
407 //*****************************************************************************
408 bool OSCHF_AttemptToSwitchToXosc( void );
409 
410 
411 //*****************************************************************************
412 //
419 //
420 //*****************************************************************************
421 void OSCHF_SwitchToRcOscTurnOffXosc( void );
422 
423 //*****************************************************************************
424 //
450 //
451 //*****************************************************************************
452 extern int32_t OSC_HPOSCRelativeFrequencyOffsetGet( int32_t tempDegC );
453 
454 //*****************************************************************************
455 //
478 //
479 //*****************************************************************************
480 extern int16_t OSC_HPOSCRelativeFrequencyOffsetToRFCoreFormatConvert( int32_t HPOSC_RelFreqOffset );
481 
482 
483 //*****************************************************************************
484 //
485 // Support for DriverLib in ROM:
486 // Redirect to implementation in ROM when available.
487 //
488 //*****************************************************************************
489 #if !defined(DRIVERLIB_NOROM) && !defined(DOXYGEN)
490  #include <driverlib/rom.h>
491  #ifdef ROM_OSCClockSourceSet
492  #undef OSCClockSourceSet
493  #define OSCClockSourceSet ROM_OSCClockSourceSet
494  #endif
495  #ifdef ROM_OSCClockSourceGet
496  #undef OSCClockSourceGet
497  #define OSCClockSourceGet ROM_OSCClockSourceGet
498  #endif
499  #ifdef ROM_OSCInterfaceEnable
500  #undef OSCInterfaceEnable
501  #define OSCInterfaceEnable ROM_OSCInterfaceEnable
502  #endif
503 #endif
504 
505 //*****************************************************************************
506 //
507 // Mark the end of the C bindings section for C++ compilers.
508 //
509 //*****************************************************************************
510 #ifdef __cplusplus
511 }
512 #endif
513 
514 
515 #endif // __OSC_H__
516 
517 //*****************************************************************************
518 //
522 //
523 //*****************************************************************************
static void AONWUCAuxWakeupEvent(uint32_t ui32Mode)
Control the wake up procedure of the AUX domain.
Definition: aon_wuc.h:476
#define LOW_POWER_XOSC
Definition: osc.h:98
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
static void OSCHfSourceSwitch(void)
Switch the high frequency clock.
Definition: osc.h:314
#define HIGH_POWER_XOSC
Definition: osc.h:99
#define HapiHFSourceSafeSwitch()
Definition: rom.h:166
static void OSCClockLossEventEnable(void)
Enables OSC clock loss event detection.
Definition: osc.h:175
#define AUX_WUC_OSCCTRL_CLOCK
Definition: aux_wuc.h:109
uint32_t OSCClockSourceGet(uint32_t ui32SrcClk)
Get the source clock settings.
Definition: osc.c:145
void DDI16BitfieldWrite(uint32_t ui32Base, uint32_t ui32Reg, uint32_t ui32Mask, uint32_t ui32Shift, uint16_t ui32Data)
Write a bitfield via the DDI using 16-bit maskable write.
Definition: ddi.c:108
void AUXWUCClockDisable(uint32_t ui32Clocks)
Disable clocks for peripherals in the AUX domain.
Definition: aux_wuc.c:113
void OSCInterfaceEnable(void)
Enable System CPU access to the OSC_DIG module.
Definition: osc.c:179
uint32_t OSCHF_GetStartupTime(uint32_t timeUntilWakeupInMs)
Returns maximum startup time (in microseconds) of XOSC_HF.
Definition: osc.c:203
bool OSCHF_AttemptToSwitchToXosc(void)
Switch to XOSC_HF if XOSC_HF is ready.
Definition: osc.c:265
static bool OSCHfSourceReady(void)
Check if the HF clock source is ready to be switched.
Definition: osc.h:284
static void OSCClockLossEventDisable(void)
Disables OSC clock loss event detection.
Definition: osc.h:198
#define AONWUC_AUX_ALLOW_SLEEP
Definition: aon_wuc.h:153
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
#define ASSERT(expr)
Definition: debug.h:74
static void OSCXHfPowerModeSet(uint32_t ui32Mode)
Set Power Mode for High Frequency XTAL Oscillator.
Definition: osc.h:144
int32_t OSC_HPOSCRelativeFrequencyOffsetGet(int32_t tempDegC)
Calculate the temperature dependent relative frequency offset of HPOSC.
Definition: osc.c:325
void OSCHF_SwitchToRcOscTurnOffXosc(void)
Switch to RCOSC_HF and turn off XOSC_HF.
Definition: osc.c:300
void OSCClockSourceSet(uint32_t ui32SrcClk, uint32_t ui32Osc)
Configure the oscillator input to the a source clock.
Definition: osc.c:86
void OSCHF_TurnOnXosc(void)
Turns on XOSC_HF (but without switching to XOSC_HF).
Definition: osc.c:252
static void OSCInterfaceDisable(void)
Disable System CPU access to the OSC_DIG module.
Definition: osc.h:352
int16_t OSC_HPOSCRelativeFrequencyOffsetToRFCoreFormatConvert(int32_t HPOSC_RelFreqOffset)
Converts the relative frequency offset of HPOSC to the RF Core parameter format.
Definition: osc.c:364