CC26xx Driver Library
sys_ctrl.h
Go to the documentation of this file.
1 /******************************************************************************
2 * Filename: sys_ctrl.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 Controller.
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 __SYSCTRL_H__
49 #define __SYSCTRL_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_ints.h>
67 #include <inc/hw_sysctl.h>
68 #include <inc/hw_prcm.h>
69 #include <inc/hw_nvic.h>
70 #include <inc/hw_aon_wuc.h>
71 #include <inc/hw_aux_wuc.h>
72 #include <inc/hw_aon_ioc.h>
73 #include <inc/hw_ddi_0_osc.h>
74 #include <inc/hw_rfc_pwr.h>
75 #include <inc/hw_prcm.h>
76 #include <inc/hw_adi_3_refsys.h>
77 #include <inc/hw_aon_sysctl.h>
78 #include <inc/hw_aon_rtc.h>
79 #include <inc/hw_fcfg1.h>
80 #include <driverlib/interrupt.h>
81 #include <driverlib/debug.h>
82 #include <driverlib/pwr_ctrl.h>
83 #include <driverlib/osc.h>
84 #include <driverlib/prcm.h>
85 #include <driverlib/aux_wuc.h>
86 #include <driverlib/aon_wuc.h>
87 #include <driverlib/adi.h>
88 #include <driverlib/ddi.h>
89 #include <driverlib/cpu.h>
90 #include <driverlib/vims.h>
91 
92 //*****************************************************************************
93 //
94 // Support for DriverLib in ROM:
95 // This section renames all functions that are not "static inline", so that
96 // calling these functions will default to implementation in flash. At the end
97 // of this file a second renaming will change the defaults to implementation in
98 // ROM for available functions.
99 //
100 // To force use of the implementation in flash, e.g. for debugging:
101 // - Globally: Define DRIVERLIB_NOROM at project level
102 // - Per function: Use prefix "NOROM_" when calling the function
103 //
104 //*****************************************************************************
105 #if !defined(DOXYGEN)
106  #define SysCtrlPowerEverything NOROM_SysCtrlPowerEverything
107  #define SysCtrlSetRechargeBeforePowerDown NOROM_SysCtrlSetRechargeBeforePowerDown
108  #define SysCtrlAdjustRechargeAfterPowerDown NOROM_SysCtrlAdjustRechargeAfterPowerDown
109  #define SysCtrl_DCDC_VoltageConditionalControl NOROM_SysCtrl_DCDC_VoltageConditionalControl
110  #define SysCtrlResetSourceGet NOROM_SysCtrlResetSourceGet
111 #endif
112 
113 //*****************************************************************************
114 //
115 // Defines for the settings of the main XOSC
116 //
117 //*****************************************************************************
118 #define SYSCTRL_SYSBUS_ON 0x00000001
119 #define SYSCTRL_SYSBUS_OFF 0x00000000
120 
121 //*****************************************************************************
122 //
123 // Defines for the different power modes of the System CPU
124 //
125 //*****************************************************************************
126 #define CPU_RUN 0x00000000
127 #define CPU_SLEEP 0x00000001
128 #define CPU_DEEP_SLEEP 0x00000002
129 
130 //*****************************************************************************
131 //
132 // Defines for SysCtrlSetRechargeBeforePowerDown
133 //
134 //*****************************************************************************
135 #define XOSC_IN_HIGH_POWER_MODE 0 // When xosc_hf is in HIGH_POWER_XOSC
136 #define XOSC_IN_LOW_POWER_MODE 1 // When xosc_hf is in LOW_POWER_XOSC
137 
138 //*****************************************************************************
139 //
140 // API Functions and prototypes
141 //
142 //*****************************************************************************
143 
144 //*****************************************************************************
145 //
156 //
157 //*****************************************************************************
158 extern void SysCtrlPowerEverything(void);
159 
160 //*****************************************************************************
161 //
170 //
171 //*****************************************************************************
172 __STATIC_INLINE uint32_t
174 {
175  //
176  // Return fixed clock speed
177  //
178  return( GET_MCU_CLOCK );
179 }
180 
181 //*****************************************************************************
182 //
193 //
194 //*****************************************************************************
195 __STATIC_INLINE void
197 {
198  //
199  // Sync the AON interface
200  //
201  HWREG(AON_RTC_BASE + AON_RTC_O_SYNC);
202 }
203 
204 //*****************************************************************************
205 //
220 //
221 //*****************************************************************************
222 __STATIC_INLINE void
224 {
225  //
226  // Force a clock cycle on the AON interface to guarantee all registers are
227  // in sync.
228  //
229  HWREG(AON_RTC_BASE + AON_RTC_O_SYNC) = 1;
230  HWREG(AON_RTC_BASE + AON_RTC_O_SYNC);
231 }
232 
233 
234 //*****************************************************************************
235 //
255 //
256 //*****************************************************************************
257 extern void SysCtrlSetRechargeBeforePowerDown( uint32_t xoscPowerMode );
258 
259 
260 //*****************************************************************************
261 //
277 //
278 //*****************************************************************************
279 extern void SysCtrlAdjustRechargeAfterPowerDown( void );
280 
281 
282 //*****************************************************************************
283 //
295 //
296 //*****************************************************************************
297 extern void SysCtrl_DCDC_VoltageConditionalControl( void );
298 
299 
300 //*****************************************************************************
301 // \name Return values from calling SysCtrlResetSourceGet()
303 //*****************************************************************************
312 #define RSTSRC_WAKEUP_FROM_SHUTDOWN ((( AON_SYSCTL_RESETCTL_RESET_SRC_M ) >> ( AON_SYSCTL_RESETCTL_RESET_SRC_S )) + 1 )
313 
314 
315 //*****************************************************************************
316 //
320 //
321 //*****************************************************************************
322 extern uint32_t SysCtrlResetSourceGet( void );
323 
324 //*****************************************************************************
325 //
329 //
330 //*****************************************************************************
331 __STATIC_INLINE void
333 {
334  // Disable CPU interrupts
335  CPUcpsid();
336  // Write reset register
338  // Finally, wait until the above write propagates
339  while ( 1 ) {
340  // Do nothing, just wait for the reset (and never return from here)
341  }
342 }
343 
344 //*****************************************************************************
345 //
359 //
360 //*****************************************************************************
361 __STATIC_INLINE void
363 {
364  //
365  // Set clock loss enable bit in AON_SYSCTRL using bit banding
366  //
368 }
369 
370 //*****************************************************************************
371 //
381 //
382 //*****************************************************************************
383 __STATIC_INLINE void
385 {
386  //
387  // Clear clock loss enable bit in AON_SYSCTRL using bit banding
388  //
390 }
391 
392 //*****************************************************************************
393 //
394 // Support for DriverLib in ROM:
395 // Redirect to implementation in ROM when available.
396 //
397 //*****************************************************************************
398 #if !defined(DRIVERLIB_NOROM) && !defined(DOXYGEN)
399  #include <driverlib/rom.h>
400  #ifdef ROM_SysCtrlPowerEverything
401  #undef SysCtrlPowerEverything
402  #define SysCtrlPowerEverything ROM_SysCtrlPowerEverything
403  #endif
404  #ifdef ROM_SysCtrlSetRechargeBeforePowerDown
405  #undef SysCtrlSetRechargeBeforePowerDown
406  #define SysCtrlSetRechargeBeforePowerDown ROM_SysCtrlSetRechargeBeforePowerDown
407  #endif
408  #ifdef ROM_SysCtrlAdjustRechargeAfterPowerDown
409  #undef SysCtrlAdjustRechargeAfterPowerDown
410  #define SysCtrlAdjustRechargeAfterPowerDown ROM_SysCtrlAdjustRechargeAfterPowerDown
411  #endif
412  #ifdef ROM_SysCtrl_DCDC_VoltageConditionalControl
413  #undef SysCtrl_DCDC_VoltageConditionalControl
414  #define SysCtrl_DCDC_VoltageConditionalControl ROM_SysCtrl_DCDC_VoltageConditionalControl
415  #endif
416  #ifdef ROM_SysCtrlResetSourceGet
417  #undef SysCtrlResetSourceGet
418  #define SysCtrlResetSourceGet ROM_SysCtrlResetSourceGet
419  #endif
420 #endif
421 
422 //*****************************************************************************
423 //
424 // Mark the end of the C bindings section for C++ compilers.
425 //
426 //*****************************************************************************
427 #ifdef __cplusplus
428 }
429 #endif
430 
431 #endif // __SYSCTRL_H__
432 
433 //*****************************************************************************
434 //
438 //
439 //*****************************************************************************
static void SysCtrlAonSync(void)
Sync all accesses to the AON register interface.
Definition: sys_ctrl.h:196
void SysCtrl_DCDC_VoltageConditionalControl(void)
Turns DCDC on or off depending of what is considered to be optimal usage.
Definition: sys_ctrl.c:473
static void SysCtrlClockLossResetEnable(void)
Enables reset if OSC clock loss event is asserted.
Definition: sys_ctrl.h:362
uint32_t SysCtrlResetSourceGet(void)
Returns last reset source (including "wakeup from shutdown").
Definition: sys_ctrl.c:538
static uint32_t SysCtrlClockGet(void)
Get the CPU core clock frequency.
Definition: sys_ctrl.h:173
static void SysCtrlAonUpdate(void)
Update all interfaces to AON.
Definition: sys_ctrl.h:223
void SysCtrlAdjustRechargeAfterPowerDown(void)
Adjust Recharge calculations to be used next.
Definition: sys_ctrl.c:426
uint32_t CPUcpsid(void)
Disable all external interrupts.
Definition: cpu.c:97
void SysCtrlSetRechargeBeforePowerDown(uint32_t xoscPowerMode)
Set Recharge values before entering Power Down.
Definition: sys_ctrl.c:218
static void SysCtrlSystemReset(void)
Perform a full system reset.
Definition: sys_ctrl.h:332
static void SysCtrlClockLossResetDisable(void)
Disables reset due to OSC clock loss event.
Definition: sys_ctrl.h:384
void SysCtrlPowerEverything(void)
Power up everything.
Definition: sys_ctrl.c:121