CC13xx Driver Library
osc.h
Go to the documentation of this file.
1 /******************************************************************************
2 * Filename: osc.h
3 * Revised: 2015-07-16 12:12:04 +0200 (Thu, 16 Jul 2015)
4 * Revision: 44151
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 //
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
236 {
237  //
238  // Return the readiness of the HF clock source
239  //
243  true : false;
244 }
245 
246 //*****************************************************************************
247 //
262 //
263 //*****************************************************************************
264 __STATIC_INLINE void
266 {
267  //
268  // Switch the HF clock source
269  //
271 }
272 
273 //*****************************************************************************
274 //
285 //
286 //*****************************************************************************
287 extern void OSCInterfaceEnable(void);
288 
289 //*****************************************************************************
290 //
300 //
301 //*****************************************************************************
302 __STATIC_INLINE void
304 {
305  //
306  // Disable clock for OSC_DIG
307  //
309 
310  //
311  // Release the 'force power' on AUX
312  //
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 #if !defined(DRIVERLIB_NOROM) && !defined(DOXYGEN)
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 //
414 //
415 //*****************************************************************************
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:265
#define HIGH_POWER_XOSC
Definition: osc.h:99
#define HapiHFSourceSafeSwitch()
Definition: rom.h:166
#define AUX_WUC_OSCCTRL_CLOCK
Definition: aux_wuc.h:109
uint32_t OSCClockSourceGet(uint32_t ui32SrcClk)
Get the source clock settings.
Definition: osc.c:144
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:178
uint32_t OSCHF_GetStartupTime(uint32_t timeUntilWakeupInMs)
Returns maximum startup time (in microseconds) of XOSC_HF.
Definition: osc.c:202
bool OSCHF_AttemptToSwitchToXosc(void)
Switch to XOSC_HF if XOSC_HF is ready.
Definition: osc.c:264
static bool OSCHfSourceReady(void)
Check if the HF clock source is ready to be switched.
Definition: osc.h:235
#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
void OSCHF_SwitchToRcOscTurnOffXosc(void)
Switch to RCOSC_HF and turn off XOSC_HF.
Definition: osc.c:299
void OSCClockSourceSet(uint32_t ui32SrcClk, uint32_t ui32Osc)
Configure the oscillator input to the a source clock.
Definition: osc.c:85
void OSCHF_TurnOnXosc(void)
Turns on XOSC_HF (but without switching to XOSC_HF).
Definition: osc.c:251
static void OSCInterfaceDisable(void)
Disable System CPU access to the OSC_DIG module.
Definition: osc.h:303