CC13xx Driver Library
sys_ctrl.h
Go to the documentation of this file.
1 /******************************************************************************
2 * Filename: sys_ctrl.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 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 // Keeping backward compatibility until major revision number is incremented
140 //
141 #define XoscInHighPowerMode ( XOSC_IN_HIGH_POWER_MODE )
142 #define XoscInLowPowerMode ( XOSC_IN_LOW_POWER_MODE )
143 
144 //*****************************************************************************
145 //
146 // API Functions and prototypes
147 //
148 //*****************************************************************************
149 
150 //*****************************************************************************
151 //
162 //
163 //*****************************************************************************
164 extern void SysCtrlPowerEverything(void);
165 
166 //*****************************************************************************
167 //
176 //
177 //*****************************************************************************
178 extern void SysCtrlStandby(void);
179 
180 //*****************************************************************************
181 //
190 //
191 //*****************************************************************************
192 extern void SysCtrlPowerdown(void);
193 
194 //*****************************************************************************
195 //
209 //
210 //*****************************************************************************
211 extern void SysCtrlShutdown(void);
212 
213 //*****************************************************************************
214 //
223 //
224 //*****************************************************************************
225 __STATIC_INLINE uint32_t
227 {
228  //
229  // Return fixed clock speed
230  //
231  return( GET_MCU_CLOCK );
232 }
233 
234 
235 //*****************************************************************************
236 //
243 //
244 //*****************************************************************************
245 __STATIC_INLINE void
247 {
248  //
249  // Sync the AON interface
250  //
251  HWREG(AON_RTC_BASE + AON_RTC_O_SYNC);
252 }
253 
254 //*****************************************************************************
255 //
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 //*****************************************************************************
399 //
400 // Support for DriverLib in ROM:
401 // Redirect to implementation in ROM when available.
402 //
403 //*****************************************************************************
404 #if !defined(DRIVERLIB_NOROM) && !defined(DOXYGEN)
405  #include <driverlib/rom.h>
406  #ifdef ROM_SysCtrlPowerEverything
407  #undef SysCtrlPowerEverything
408  #define SysCtrlPowerEverything ROM_SysCtrlPowerEverything
409  #endif
410  #ifdef ROM_SysCtrlStandby
411  #undef SysCtrlStandby
412  #define SysCtrlStandby ROM_SysCtrlStandby
413  #endif
414  #ifdef ROM_SysCtrlPowerdown
415  #undef SysCtrlPowerdown
416  #define SysCtrlPowerdown ROM_SysCtrlPowerdown
417  #endif
418  #ifdef ROM_SysCtrlShutdown
419  #undef SysCtrlShutdown
420  #define SysCtrlShutdown ROM_SysCtrlShutdown
421  #endif
422  #ifdef ROM_SysCtrlResetSourceGet
423  #undef SysCtrlResetSourceGet
424  #define SysCtrlResetSourceGet ROM_SysCtrlResetSourceGet
425  #endif
426 #endif
427 
428 //*****************************************************************************
429 //
430 // Mark the end of the C bindings section for C++ compilers.
431 //
432 //*****************************************************************************
433 #ifdef __cplusplus
434 }
435 #endif
436 
437 #endif // __SYSCTRL_H__
438 
439 //*****************************************************************************
440 //
444 //
445 //*****************************************************************************
static void SysCtrlAonSync(void)
Sync all accesses to the AON register interface.
Definition: sys_ctrl.h:246
void SysCtrl_DCDC_VoltageConditionalControl(void)
Turns DCDC on or off depending of what is considered to be optimal usage.
Definition: sys_ctrl.c:558
uint32_t SysCtrlResetSourceGet(void)
Returns last reset source (including "wakeup from shutdown").
Definition: sys_ctrl.c:621
static uint32_t SysCtrlClockGet(void)
Get the CPU core clock frequency.
Definition: sys_ctrl.h:226
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:511
void SysCtrlShutdown(void)
Force the system into shutdown.
Definition: sys_ctrl.c:285
void SysCtrlStandby(void)
Force the system into standby mode.
Definition: sys_ctrl.c:214
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:334
static void SysCtrlSystemReset(void)
Perform a full system reset.
Definition: sys_ctrl.h:385
void SysCtrlPowerdown(void)
Force the system into power down.
Definition: sys_ctrl.c:244
void SysCtrlPowerEverything(void)
Power up everything.
Definition: sys_ctrl.c:118