CC13xx Driver Library
sys_ctrl.h
Go to the documentation of this file.
1 /******************************************************************************
2 * Filename: sys_ctrl.h
3 * Revised: 2015-09-25 13:16:58 +0200 (Fri, 25 Sep 2015)
4 * Revision: 44667
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 //
237 //
238 //*****************************************************************************
239 __STATIC_INLINE void
241 {
242  //
243  // Sync the AON interface
244  //
245  HWREG(AON_RTC_BASE + AON_RTC_O_SYNC);
246 }
247 
248 //*****************************************************************************
249 //
262 //
263 //*****************************************************************************
264 __STATIC_INLINE void
266 {
267  //
268  // Force a clock cycle on the AON interface to guarantee all registers are
269  // in sync.
270  //
271  HWREG(AON_RTC_BASE + AON_RTC_O_SYNC) = 1;
272  HWREG(AON_RTC_BASE + AON_RTC_O_SYNC);
273 }
274 
275 
276 //*****************************************************************************
277 //
297 //
298 //*****************************************************************************
299 void
300 SysCtrlSetRechargeBeforePowerDown( uint32_t xoscPowerMode );
301 
302 
303 //*****************************************************************************
304 //
322 //
323 //*****************************************************************************
324 void
326 
327 
328 //*****************************************************************************
329 //
341 //
342 //*****************************************************************************
343 void
345 
346 
347 //*****************************************************************************
348 // \name Return values from calling SysCtrlResetSourceGet()
350 //*****************************************************************************
359 #define RSTSRC_WAKEUP_FROM_SHUTDOWN (( AON_SYSCTL_RESETCTL_RESET_SRC_M >> AON_SYSCTL_RESETCTL_RESET_SRC_S ) + 1 )
360 
361 
362 //*****************************************************************************
363 //
367 //
368 //*****************************************************************************
369 extern uint32_t SysCtrlResetSourceGet( void );
370 
371 //*****************************************************************************
372 //
376 //
377 //*****************************************************************************
378 __STATIC_INLINE void
380 {
381  // Disable CPU interrupts
382  CPUcpsid();
383  // Write reset register
385  // Finally, wait until the above write propagates
386  while ( 1 ) {
387  // Do nothing, just wait for the reset (and never return from here)
388  }
389 }
390 
391 //*****************************************************************************
392 //
406 //
407 //*****************************************************************************
408 __STATIC_INLINE void
410 {
411  //
412  // Set clock loss enable bit in AON_SYSCTRL using bit banding
413  //
415 }
416 
417 //*****************************************************************************
418 //
428 //
429 //*****************************************************************************
430 __STATIC_INLINE void
432 {
433  //
434  // Clear clock loss enable bit in AON_SYSCTRL using bit banding
435  //
437 }
438 
439 //*****************************************************************************
440 //
441 // Support for DriverLib in ROM:
442 // Redirect to implementation in ROM when available.
443 //
444 //*****************************************************************************
445 #if !defined(DRIVERLIB_NOROM) && !defined(DOXYGEN)
446  #include <driverlib/rom.h>
447  #ifdef ROM_SysCtrlPowerEverything
448  #undef SysCtrlPowerEverything
449  #define SysCtrlPowerEverything ROM_SysCtrlPowerEverything
450  #endif
451  #ifdef ROM_SysCtrlStandby
452  #undef SysCtrlStandby
453  #define SysCtrlStandby ROM_SysCtrlStandby
454  #endif
455  #ifdef ROM_SysCtrlPowerdown
456  #undef SysCtrlPowerdown
457  #define SysCtrlPowerdown ROM_SysCtrlPowerdown
458  #endif
459  #ifdef ROM_SysCtrlShutdown
460  #undef SysCtrlShutdown
461  #define SysCtrlShutdown ROM_SysCtrlShutdown
462  #endif
463  #ifdef ROM_SysCtrlResetSourceGet
464  #undef SysCtrlResetSourceGet
465  #define SysCtrlResetSourceGet ROM_SysCtrlResetSourceGet
466  #endif
467 #endif
468 
469 //*****************************************************************************
470 //
471 // Mark the end of the C bindings section for C++ compilers.
472 //
473 //*****************************************************************************
474 #ifdef __cplusplus
475 }
476 #endif
477 
478 #endif // __SYSCTRL_H__
479 
480 //*****************************************************************************
481 //
485 //
486 //*****************************************************************************
static void SysCtrlAonSync(void)
Sync all accesses to the AON register interface.
Definition: sys_ctrl.h:240
void SysCtrl_DCDC_VoltageConditionalControl(void)
Turns DCDC on or off depending of what is considered to be optimal usage.
Definition: sys_ctrl.c:604
static void SysCtrlClockLossResetEnable(void)
Enables reset if OSC clock loss event is asserted.
Definition: sys_ctrl.h:409
uint32_t SysCtrlResetSourceGet(void)
Returns last reset source (including "wakeup from shutdown").
Definition: sys_ctrl.c:667
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:265
void SysCtrlAdjustRechargeAfterPowerDown(void)
Adjust Recharge calculations to be used next.
Definition: sys_ctrl.c:557
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:68
void SysCtrlSetRechargeBeforePowerDown(uint32_t xoscPowerMode)
Set Recharge values before entering Power Down.
Definition: sys_ctrl.c:337
static void SysCtrlSystemReset(void)
Perform a full system reset.
Definition: sys_ctrl.h:379
static void SysCtrlClockLossResetDisable(void)
Disables reset due to OSC clock loss event.
Definition: sys_ctrl.h:431
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