CC26xx Driver Library
osc.h
Go to the documentation of this file.
1 /******************************************************************************
2 * Filename: osc.h
3 * Revised: 2016-07-07 19:12:02 +0200 (Thu, 07 Jul 2016)
4 * Revision: 46848
5 *
6 * Description: Defines and prototypes for the system oscillator control.
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 __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_aon_wuc.h>
65 #include <inc/hw_types.h>
66 #include <inc/hw_memmap.h>
67 #include <inc/hw_ddi.h>
68 #include <inc/hw_ddi_0_osc.h>
69 #include <driverlib/rom.h>
70 #include <driverlib/ddi.h>
71 #include <driverlib/debug.h>
72 
73 //*****************************************************************************
74 //
75 // Support for DriverLib in ROM:
76 // This section renames all functions that are not "static inline", so that
77 // calling these functions will default to implementation in flash. At the end
78 // of this file a second renaming will change the defaults to implementation in
79 // ROM for available functions.
80 //
81 // To force use of the implementation in flash, e.g. for debugging:
82 // - Globally: Define DRIVERLIB_NOROM at project level
83 // - Per function: Use prefix "NOROM_" when calling the function
84 //
85 //*****************************************************************************
86 #if !defined(DOXYGEN)
87  #define OSCClockSourceSet NOROM_OSCClockSourceSet
88  #define OSCClockSourceGet NOROM_OSCClockSourceGet
89  #define OSCHF_GetStartupTime NOROM_OSCHF_GetStartupTime
90  #define OSCHF_TurnOnXosc NOROM_OSCHF_TurnOnXosc
91  #define OSCHF_AttemptToSwitchToXosc NOROM_OSCHF_AttemptToSwitchToXosc
92  #define OSCHF_SwitchToRcOscTurnOffXosc NOROM_OSCHF_SwitchToRcOscTurnOffXosc
93  #define OSCHF_DebugGetCrystalAmplitude NOROM_OSCHF_DebugGetCrystalAmplitude
94  #define OSCHF_DebugGetExpectedAverageCrystalAmplitude NOROM_OSCHF_DebugGetExpectedAverageCrystalAmplitude
95  #define OSC_HPOSCRelativeFrequencyOffsetGet NOROM_OSC_HPOSCRelativeFrequencyOffsetGet
96  #define OSC_HPOSCRelativeFrequencyOffsetToRFCoreFormatConvert NOROM_OSC_HPOSCRelativeFrequencyOffsetToRFCoreFormatConvert
97 #endif
98 
99 //*****************************************************************************
100 //
101 // Defines for the High Frequency XTAL Power mode
102 //
103 //*****************************************************************************
104 #define LOW_POWER_XOSC 1
105 #define HIGH_POWER_XOSC 0
106 
107 //*****************************************************************************
108 //
109 // Defines for the High Frequency XTAL Power mode
110 //
111 //*****************************************************************************
112 #define OSC_SRC_CLK_HF 0x00000001
113 #define OSC_SRC_CLK_MF 0x00000002
114 #define OSC_SRC_CLK_LF 0x00000004
115 
116 #define OSC_RCOSC_HF 0x00000000
117 #define OSC_XOSC_HF 0x00000001
118 #define OSC_RCOSC_LF 0x00000002
119 #define OSC_XOSC_LF 0x00000003
120 
121 #define SCLK_HF_RCOSC_HF 0
122 #define SCLK_HF_XOSC_HF 1
123 
124 #define SCLK_MF_RCOSC_HF 0
125 #define SCLK_MF_XOSC_HF 1
126 
127 #define SCLK_LF_FROM_RCOSC_HF 0
128 #define SCLK_LF_FROM_XOSC_HF 1
129 #define SCLK_LF_FROM_RCOSC_LF 2
130 #define SCLK_LF_FROM_XOSC_LF 3
131 
132 //*****************************************************************************
133 //
134 // API Functions and prototypes
135 //
136 //*****************************************************************************
137 
138 //*****************************************************************************
139 //
147 //
148 //*****************************************************************************
149 __STATIC_INLINE void
150 OSCXHfPowerModeSet(uint32_t ui32Mode)
151 {
152  //
153  // Check the arguments.
154  //
155  ASSERT((ui32Mode == LOW_POWER_XOSC) ||
156  (ui32Mode == HIGH_POWER_XOSC));
157 
158  //
159  // Change the power mode.
160  //
162  ui32Mode);
163 }
164 
165 //*****************************************************************************
166 //
178 //
179 //*****************************************************************************
180 __STATIC_INLINE void
182 {
186 }
187 
188 //*****************************************************************************
189 //
201 //
202 //*****************************************************************************
203 __STATIC_INLINE void
205 {
209 }
210 
211 //*****************************************************************************
212 //
247 //
248 //*****************************************************************************
249 extern void OSCClockSourceSet(uint32_t ui32SrcClk, uint32_t ui32Osc);
250 
251 //*****************************************************************************
252 //
270 //
271 //*****************************************************************************
272 extern uint32_t OSCClockSourceGet(uint32_t ui32SrcClk);
273 
274 //*****************************************************************************
275 //
287 //
288 //*****************************************************************************
289 __STATIC_INLINE bool
291 {
292  //
293  // Return the readiness of the HF clock source
294  //
298  true : false;
299 }
300 
301 //*****************************************************************************
302 //
317 //
318 //*****************************************************************************
319 __STATIC_INLINE void
321 {
322  //
323  // Switch the HF clock source
324  //
326 }
327 
328 //*****************************************************************************
329 //
345 //
346 //*****************************************************************************
347 __STATIC_INLINE void
349 {
350 }
351 
352 //*****************************************************************************
353 //
368 //
369 //*****************************************************************************
370 __STATIC_INLINE void
372 {
373 }
374 
375 //*****************************************************************************
376 //
386 //
387 //*****************************************************************************
388 extern uint32_t OSCHF_GetStartupTime( uint32_t timeUntilWakeupInMs );
389 
390 
391 //*****************************************************************************
392 //
399 //
400 //*****************************************************************************
401 extern void OSCHF_TurnOnXosc( void );
402 
403 
404 //*****************************************************************************
405 //
415 //
416 //*****************************************************************************
417 extern bool OSCHF_AttemptToSwitchToXosc( void );
418 
419 
420 //*****************************************************************************
421 //
428 //
429 //*****************************************************************************
430 extern void OSCHF_SwitchToRcOscTurnOffXosc( void );
431 
432 //*****************************************************************************
433 //
448 //
449 //*****************************************************************************
450 extern uint32_t OSCHF_DebugGetCrystalAmplitude( void );
451 
452 //*****************************************************************************
453 //
465 //
466 //*****************************************************************************
467 extern uint32_t OSCHF_DebugGetExpectedAverageCrystalAmplitude( void );
468 
469 //*****************************************************************************
470 //
496 //
497 //*****************************************************************************
498 extern int32_t OSC_HPOSCRelativeFrequencyOffsetGet( int32_t tempDegC );
499 
500 //*****************************************************************************
501 //
524 //
525 //*****************************************************************************
526 extern int16_t OSC_HPOSCRelativeFrequencyOffsetToRFCoreFormatConvert( int32_t HPOSC_RelFreqOffset );
527 
528 
529 //*****************************************************************************
530 //
531 // Support for DriverLib in ROM:
532 // Redirect to implementation in ROM when available.
533 //
534 //*****************************************************************************
535 #if !defined(DRIVERLIB_NOROM) && !defined(DOXYGEN)
536  #include <driverlib/rom.h>
537  #ifdef ROM_OSCClockSourceSet
538  #undef OSCClockSourceSet
539  #define OSCClockSourceSet ROM_OSCClockSourceSet
540  #endif
541  #ifdef ROM_OSCClockSourceGet
542  #undef OSCClockSourceGet
543  #define OSCClockSourceGet ROM_OSCClockSourceGet
544  #endif
545  #ifdef ROM_OSCHF_GetStartupTime
546  #undef OSCHF_GetStartupTime
547  #define OSCHF_GetStartupTime ROM_OSCHF_GetStartupTime
548  #endif
549  #ifdef ROM_OSCHF_TurnOnXosc
550  #undef OSCHF_TurnOnXosc
551  #define OSCHF_TurnOnXosc ROM_OSCHF_TurnOnXosc
552  #endif
553  #ifdef ROM_OSCHF_AttemptToSwitchToXosc
554  #undef OSCHF_AttemptToSwitchToXosc
555  #define OSCHF_AttemptToSwitchToXosc ROM_OSCHF_AttemptToSwitchToXosc
556  #endif
557  #ifdef ROM_OSCHF_SwitchToRcOscTurnOffXosc
558  #undef OSCHF_SwitchToRcOscTurnOffXosc
559  #define OSCHF_SwitchToRcOscTurnOffXosc ROM_OSCHF_SwitchToRcOscTurnOffXosc
560  #endif
561  #ifdef ROM_OSCHF_DebugGetCrystalAmplitude
562  #undef OSCHF_DebugGetCrystalAmplitude
563  #define OSCHF_DebugGetCrystalAmplitude ROM_OSCHF_DebugGetCrystalAmplitude
564  #endif
565  #ifdef ROM_OSCHF_DebugGetExpectedAverageCrystalAmplitude
566  #undef OSCHF_DebugGetExpectedAverageCrystalAmplitude
567  #define OSCHF_DebugGetExpectedAverageCrystalAmplitude ROM_OSCHF_DebugGetExpectedAverageCrystalAmplitude
568  #endif
569  #ifdef ROM_OSC_HPOSCRelativeFrequencyOffsetGet
570  #undef OSC_HPOSCRelativeFrequencyOffsetGet
571  #define OSC_HPOSCRelativeFrequencyOffsetGet ROM_OSC_HPOSCRelativeFrequencyOffsetGet
572  #endif
573  #ifdef ROM_OSC_HPOSCRelativeFrequencyOffsetToRFCoreFormatConvert
574  #undef OSC_HPOSCRelativeFrequencyOffsetToRFCoreFormatConvert
575  #define OSC_HPOSCRelativeFrequencyOffsetToRFCoreFormatConvert ROM_OSC_HPOSCRelativeFrequencyOffsetToRFCoreFormatConvert
576  #endif
577 #endif
578 
579 //*****************************************************************************
580 //
581 // Mark the end of the C bindings section for C++ compilers.
582 //
583 //*****************************************************************************
584 #ifdef __cplusplus
585 }
586 #endif
587 
588 
589 #endif // __OSC_H__
590 
591 //*****************************************************************************
592 //
596 //
597 //*****************************************************************************
#define LOW_POWER_XOSC
Definition: osc.h:104
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:87
static void OSCHfSourceSwitch(void)
Switch the high frequency clock.
Definition: osc.h:320
#define HIGH_POWER_XOSC
Definition: osc.h:105
#define HapiHFSourceSafeSwitch()
Definition: rom.h:167
static void OSCClockLossEventEnable(void)
Enables OSC clock loss event detection.
Definition: osc.h:181
uint32_t OSCHF_DebugGetCrystalAmplitude(void)
Get crystal amplitude (assuming crystal is running).
Definition: osc.c:400
uint32_t OSCHF_DebugGetExpectedAverageCrystalAmplitude(void)
Get the expected average crystal amplitude.
Definition: osc.c:437
uint32_t OSCClockSourceGet(uint32_t ui32SrcClk)
Get the source clock settings.
Definition: osc.c:160
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:131
uint32_t OSCHF_GetStartupTime(uint32_t timeUntilWakeupInMs)
Returns maximum startup time (in microseconds) of XOSC_HF.
Definition: osc.c:194
bool OSCHF_AttemptToSwitchToXosc(void)
Switch to XOSC_HF if XOSC_HF is ready.
Definition: osc.c:256
static bool OSCHfSourceReady(void)
Check if the HF clock source is ready to be switched.
Definition: osc.h:290
static void OSCClockLossEventDisable(void)
Disables OSC clock loss event detection.
Definition: osc.h:204
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:221
#define ASSERT(expr)
Definition: debug.h:74
static void OSCXHfPowerModeSet(uint32_t ui32Mode)
Set Power Mode for High Frequency XTAL Oscillator.
Definition: osc.h:150
int32_t OSC_HPOSCRelativeFrequencyOffsetGet(int32_t tempDegC)
Calculate the temperature dependent relative frequency offset of HPOSC.
Definition: osc.c:316
void OSCHF_SwitchToRcOscTurnOffXosc(void)
Switch to RCOSC_HF and turn off XOSC_HF.
Definition: osc.c:291
static void OSCInterfaceEnable(void)
Deprecated: Empty function - original functionality is removed.
Definition: osc.h:348
void OSCClockSourceSet(uint32_t ui32SrcClk, uint32_t ui32Osc)
Configure the oscillator input to the a source clock.
Definition: osc.c:101
void OSCHF_TurnOnXosc(void)
Turns on XOSC_HF (but without switching to XOSC_HF).
Definition: osc.c:243
static void OSCInterfaceDisable(void)
Deprecated: Empty function - original functionality is removed.
Definition: osc.h:371
int16_t OSC_HPOSCRelativeFrequencyOffsetToRFCoreFormatConvert(int32_t HPOSC_RelFreqOffset)
Converts the relative frequency offset of HPOSC to the RF Core parameter format.
Definition: osc.c:355