CC26xx Driver Library
pwr_ctrl.h
Go to the documentation of this file.
1 /******************************************************************************
2 * Filename: pwr_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 Power Control.
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 __PWR_CTRL_H__
49 #define __PWR_CTRL_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_aon_wuc.h>
68 #include <inc/hw_aon_sysctl.h>
69 #include <inc/hw_aon_rtc.h>
70 #include <inc/hw_adi_2_refsys.h>
71 #include <driverlib/debug.h>
72 #include <driverlib/interrupt.h>
73 #include <driverlib/osc.h>
74 #include <driverlib/cpu.h>
75 #include <driverlib/prcm.h>
76 #include <driverlib/aon_ioc.h>
77 #include <driverlib/adi.h>
78 
79 //*****************************************************************************
80 //
81 // Support for DriverLib in ROM:
82 // This section renames all functions that are not "static inline", so that
83 // calling these functions will default to implementation in flash. At the end
84 // of this file a second renaming will change the defaults to implementation in
85 // ROM for available functions.
86 //
87 // To force use of the implementation in flash, e.g. for debugging:
88 // - Globally: Define DRIVERLIB_NOROM at project level
89 // - Per function: Use prefix "NOROM_" when calling the function
90 //
91 //*****************************************************************************
92 #if !defined(DOXYGEN)
93  #define PowerCtrlSourceSet NOROM_PowerCtrlSourceSet
94 #endif
95 
96 //*****************************************************************************
97 //
98 // Defines for the system power states
99 //
100 //*****************************************************************************
101 #define PWRCTRL_ACTIVE 0x00000001
102 #define PWRCTRL_STANDBY 0x00000002
103 #define PWRCTRL_POWER_DOWN 0x00000004
104 #define PWRCTRL_SHUTDOWN 0x00000008
105 
106 //*****************************************************************************
107 //
108 // Defines for the power configuration in the AON System Control 1.2 V
109 //
110 //*****************************************************************************
111 #define PWRCTRL_IOSEG3_ENABLE 0x00000800
112 #define PWRCTRL_IOSEG2_ENABLE 0x00000400
113 #define PWRCTRL_IOSEG3_DISABLE 0x00000200
114 #define PWRCTRL_IOSEG2_DISABLE 0x00000100
115 #define PWRCTRL_PWRSRC_DCDC 0x00000001
116 #define PWRCTRL_PWRSRC_GLDO 0x00000000
117 #define PWRCTRL_PWRSRC_ULDO 0x00000002
118 
119 //*****************************************************************************
120 //
121 // The following are defines for the various reset source for the device.
122 //
123 //*****************************************************************************
124 #define PWRCTRL_RST_POWER_ON 0x00000000 // Reset by power on
125 #define PWRCTRL_RST_PIN 0x00000001 // Pin reset
126 #define PWRCTRL_RST_VDDS_BOD 0x00000002 // VDDS Brown Out Detect
127 #define PWRCTRL_RST_VDD_BOD 0x00000003 // VDD Brown Out Detect
128 #define PWRCTRL_RST_VDDR_BOD 0x00000004 // VDDR Brown Out Detect
129 #define PWRCTRL_RST_CLK_LOSS 0x00000005 // Clock loss Reset
130 #define PWRCTRL_RST_SW_PIN 0x00000006 // SYSRESET or pin reset
131 #define PWRCTRL_RST_WARM 0x00000007 // Reset via PRCM warm reset request
132 
133 //*****************************************************************************
134 //
135 // API Functions and prototypes
136 //
137 //*****************************************************************************
138 
139 //*****************************************************************************
140 //
159 //
160 //*****************************************************************************
161 extern void PowerCtrlSourceSet(uint32_t ui32PowerConfig);
162 
163 //*****************************************************************************
164 //
177 //
178 //*****************************************************************************
179 __STATIC_INLINE uint32_t
181 {
182  uint32_t ui32PowerConfig;
183 
184  //
185  // Return the current power source
186  //
187  ui32PowerConfig = HWREG(AON_SYSCTL_BASE + AON_SYSCTL_O_PWRCTL);
188  if(ui32PowerConfig & AON_SYSCTL_PWRCTL_DCDC_ACTIVE)
189  {
190  return (PWRCTRL_PWRSRC_DCDC);
191  }
192  else
193  {
194  return (PWRCTRL_PWRSRC_GLDO);
195  }
196 }
197 
198 //*****************************************************************************
199 //
219 //
220 //*****************************************************************************
221 __STATIC_INLINE uint32_t
223 {
224  //
225  // Get the reset source.
226  //
227  return (( HWREG( AON_SYSCTL_BASE + AON_SYSCTL_O_RESETCTL ) &
230 }
231 
232 //*****************************************************************************
233 //
243 //
244 //*****************************************************************************
245 __STATIC_INLINE void
247 {
248  //
249  // Close the IO latches at AON_IOC level and in the padring.
250  //
253  HWREG(AON_RTC_BASE + AON_RTC_O_SYNC);
254 }
255 
256 //*****************************************************************************
257 //
268 //
269 //*****************************************************************************
270 __STATIC_INLINE void
272 {
273  //
274  // Open the IO latches at AON_IOC level and in the padring
275  //
278  HWREG(AON_RTC_BASE + AON_RTC_O_SYNC);
279 }
280 
281 //*****************************************************************************
282 //
283 // Support for DriverLib in ROM:
284 // Redirect to implementation in ROM when available.
285 //
286 //*****************************************************************************
287 #if !defined(DRIVERLIB_NOROM) && !defined(DOXYGEN)
288  #include <driverlib/rom.h>
289  #ifdef ROM_PowerCtrlSourceSet
290  #undef PowerCtrlSourceSet
291  #define PowerCtrlSourceSet ROM_PowerCtrlSourceSet
292  #endif
293 #endif
294 
295 //*****************************************************************************
296 //
297 // Mark the end of the C bindings section for C++ compilers.
298 //
299 //*****************************************************************************
300 #ifdef __cplusplus
301 }
302 #endif
303 
304 #endif // __PWR_CTRL_H__
305 
306 //*****************************************************************************
307 //
311 //
312 //*****************************************************************************
static void AONIOCFreezeEnable(void)
Freeze the IOs.
Definition: aon_ioc.h:214
void PowerCtrlSourceSet(uint32_t ui32PowerConfig)
Set (Request) the main power source.
Definition: pwr_ctrl.c:59
static void PowerCtrlIOFreezeDisable(void)
Definition: pwr_ctrl.h:271
static void AONIOCFreezeDisable(void)
Un-freeze the IOs.
Definition: aon_ioc.h:237
static void PowerCtrlIOFreezeEnable(void)
Close the latches in the AON IOC interface and in padring.
Definition: pwr_ctrl.h:246
#define PWRCTRL_PWRSRC_GLDO
Definition: pwr_ctrl.h:116
static uint32_t PowerCtrlResetSourceGet(void)
OBSOLETE: Get the last known reset source of the system.
Definition: pwr_ctrl.h:222
static uint32_t PowerCtrlSourceGet(void)
Get the main power source.
Definition: pwr_ctrl.h:180
#define PWRCTRL_PWRSRC_DCDC
Definition: pwr_ctrl.h:115