CC26xx Driver Library
sys_ctrl.h
Go to the documentation of this file.
1 /******************************************************************************
2 * Filename: sys_ctrl.h
3 * Revised: 2015-11-09 11:32:42 +0100 (Mon, 09 Nov 2015)
4 * Revision: 45004
5 *
6 * Description: Defines and prototypes for the System Controller.
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 __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 SysCtrlStandby NOROM_SysCtrlStandby
108  #define SysCtrlPowerdown NOROM_SysCtrlPowerdown
109  #define SysCtrlShutdown NOROM_SysCtrlShutdown
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 extern void SysCtrlStandby(void);
173 
174 //*****************************************************************************
175 //
184 //
185 //*****************************************************************************
186 extern void SysCtrlPowerdown(void);
187 
188 //*****************************************************************************
189 //
203 //
204 //*****************************************************************************
205 extern void SysCtrlShutdown(void);
206 
207 //*****************************************************************************
208 //
217 //
218 //*****************************************************************************
219 __STATIC_INLINE uint32_t
221 {
222  //
223  // Return fixed clock speed
224  //
225  return( GET_MCU_CLOCK );
226 }
227 
228 
229 //*****************************************************************************
230 //
241 //
242 //*****************************************************************************
243 __STATIC_INLINE void
245 {
246  //
247  // Sync the AON interface
248  //
249  HWREG(AON_RTC_BASE + AON_RTC_O_SYNC);
250 }
251 
252 //*****************************************************************************
253 //
268 //
269 //*****************************************************************************
270 __STATIC_INLINE void
272 {
273  //
274  // Force a clock cycle on the AON interface to guarantee all registers are
275  // in sync.
276  //
277  HWREG(AON_RTC_BASE + AON_RTC_O_SYNC) = 1;
278  HWREG(AON_RTC_BASE + AON_RTC_O_SYNC);
279 }
280 
281 
282 //*****************************************************************************
283 //
303 //
304 //*****************************************************************************
305 void
306 SysCtrlSetRechargeBeforePowerDown( uint32_t xoscPowerMode );
307 
308 
309 //*****************************************************************************
310 //
328 //
329 //*****************************************************************************
330 void
332 
333 
334 //*****************************************************************************
335 //
347 //
348 //*****************************************************************************
349 void
351 
352 
353 //*****************************************************************************
354 // \name Return values from calling SysCtrlResetSourceGet()
356 //*****************************************************************************
365 #define RSTSRC_WAKEUP_FROM_SHUTDOWN ((( AON_SYSCTL_RESETCTL_RESET_SRC_M ) >> ( AON_SYSCTL_RESETCTL_RESET_SRC_S )) + 1 )
366 
367 
368 //*****************************************************************************
369 //
373 //
374 //*****************************************************************************
375 extern uint32_t SysCtrlResetSourceGet( void );
376 
377 //*****************************************************************************
378 //
382 //
383 //*****************************************************************************
384 __STATIC_INLINE void
386 {
387  // Disable CPU interrupts
388  CPUcpsid();
389  // Write reset register
391  // Finally, wait until the above write propagates
392  while ( 1 ) {
393  // Do nothing, just wait for the reset (and never return from here)
394  }
395 }
396 
397 //*****************************************************************************
398 //
412 //
413 //*****************************************************************************
414 __STATIC_INLINE void
416 {
417  //
418  // Set clock loss enable bit in AON_SYSCTRL using bit banding
419  //
421 }
422 
423 //*****************************************************************************
424 //
434 //
435 //*****************************************************************************
436 __STATIC_INLINE void
438 {
439  //
440  // Clear clock loss enable bit in AON_SYSCTRL using bit banding
441  //
443 }
444 
445 //*****************************************************************************
446 //
447 // Support for DriverLib in ROM:
448 // Redirect to implementation in ROM when available.
449 //
450 //*****************************************************************************
451 #if !defined(DRIVERLIB_NOROM) && !defined(DOXYGEN)
452  #include <driverlib/rom.h>
453  #ifdef ROM_SysCtrlPowerEverything
454  #undef SysCtrlPowerEverything
455  #define SysCtrlPowerEverything ROM_SysCtrlPowerEverything
456  #endif
457  #ifdef ROM_SysCtrlStandby
458  #undef SysCtrlStandby
459  #define SysCtrlStandby ROM_SysCtrlStandby
460  #endif
461  #ifdef ROM_SysCtrlPowerdown
462  #undef SysCtrlPowerdown
463  #define SysCtrlPowerdown ROM_SysCtrlPowerdown
464  #endif
465  #ifdef ROM_SysCtrlShutdown
466  #undef SysCtrlShutdown
467  #define SysCtrlShutdown ROM_SysCtrlShutdown
468  #endif
469  #ifdef ROM_SysCtrlResetSourceGet
470  #undef SysCtrlResetSourceGet
471  #define SysCtrlResetSourceGet ROM_SysCtrlResetSourceGet
472  #endif
473 #endif
474 
475 //*****************************************************************************
476 //
477 // Mark the end of the C bindings section for C++ compilers.
478 //
479 //*****************************************************************************
480 #ifdef __cplusplus
481 }
482 #endif
483 
484 #endif // __SYSCTRL_H__
485 
486 //*****************************************************************************
487 //
491 //
492 //*****************************************************************************
static void SysCtrlAonSync(void)
Sync all accesses to the AON register interface.
Definition: sys_ctrl.h:244
void SysCtrl_DCDC_VoltageConditionalControl(void)
Turns DCDC on or off depending of what is considered to be optimal usage.
Definition: sys_ctrl.c:585
static void SysCtrlClockLossResetEnable(void)
Enables reset if OSC clock loss event is asserted.
Definition: sys_ctrl.h:415
uint32_t SysCtrlResetSourceGet(void)
Returns last reset source (including "wakeup from shutdown").
Definition: sys_ctrl.c:648
static uint32_t SysCtrlClockGet(void)
Get the CPU core clock frequency.
Definition: sys_ctrl.h:220
static void SysCtrlAonUpdate(void)
Update all interfaces to AON.
Definition: sys_ctrl.h:271
void SysCtrlAdjustRechargeAfterPowerDown(void)
Adjust Recharge calculations to be used next.
Definition: sys_ctrl.c:538
void SysCtrlShutdown(void)
Force the system into shutdown.
Definition: sys_ctrl.c:288
void SysCtrlStandby(void)
Force the system into standby mode.
Definition: sys_ctrl.c:217
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:330
static void SysCtrlSystemReset(void)
Perform a full system reset.
Definition: sys_ctrl.h:385
static void SysCtrlClockLossResetDisable(void)
Disables reset due to OSC clock loss event.
Definition: sys_ctrl.h:437
void SysCtrlPowerdown(void)
Force the system into power down.
Definition: sys_ctrl.c:247
void SysCtrlPowerEverything(void)
Power up everything.
Definition: sys_ctrl.c:121