CC13xx Driver Library
pwr_ctrl.h
Go to the documentation of this file.
1 /******************************************************************************
2 * Filename: pwr_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 Power Control.
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 __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_wuc.h>
77 #include <driverlib/aon_ioc.h>
78 #include <driverlib/aux_wuc.h>
79 #include <driverlib/adi.h>
80 
81 //*****************************************************************************
82 //
83 // Support for DriverLib in ROM:
84 // This section renames all functions that are not "static inline", so that
85 // calling these functions will default to implementation in flash. At the end
86 // of this file a second renaming will change the defaults to implementation in
87 // ROM for available functions.
88 //
89 // To force use of the implementation in flash, e.g. for debugging:
90 // - Globally: Define DRIVERLIB_NOROM at project level
91 // - Per function: Use prefix "NOROM_" when calling the function
92 //
93 //*****************************************************************************
94 #if !defined(DOXYGEN)
95  #define PowerCtrlStateSet NOROM_PowerCtrlStateSet
96  #define PowerCtrlSourceSet NOROM_PowerCtrlSourceSet
97 #endif
98 
99 //*****************************************************************************
100 //
101 // Defines for the system power states
102 //
103 //*****************************************************************************
104 #define PWRCTRL_ACTIVE 0x00000001
105 #define PWRCTRL_STANDBY 0x00000002
106 #define PWRCTRL_POWER_DOWN 0x00000004
107 #define PWRCTRL_SHUTDOWN 0x00000008
108 
109 //*****************************************************************************
110 //
111 // Defines for the power configuration in the AON System Control 1.2 V
112 //
113 //*****************************************************************************
114 #define PWRCTRL_IOSEG3_ENABLE 0x00000800
115 #define PWRCTRL_IOSEG2_ENABLE 0x00000400
116 #define PWRCTRL_IOSEG3_DISABLE 0x00000200
117 #define PWRCTRL_IOSEG2_DISABLE 0x00000100
118 #define PWRCTRL_PWRSRC_DCDC 0x00000001
119 #define PWRCTRL_PWRSRC_GLDO 0x00000000
120 #define PWRCTRL_PWRSRC_ULDO 0x00000002
121 
122 //*****************************************************************************
123 //
124 // The following are defines for the various reset source for the device.
125 //
126 //*****************************************************************************
127 #define PWRCTRL_RST_POWER_ON 0x00000000 // Reset by power on
128 #define PWRCTRL_RST_PIN 0x00000001 // Pin reset
129 #define PWRCTRL_RST_VDDS_BOD 0x00000002 // VDDS Brown Out Detect
130 #define PWRCTRL_RST_VDD_BOD 0x00000003 // VDD Brown Out Detect
131 #define PWRCTRL_RST_VDDR_BOD 0x00000004 // VDDR Brown Out Detect
132 #define PWRCTRL_RST_CLK_LOSS 0x00000005 // Clock loss Reset
133 #define PWRCTRL_RST_SW_PIN 0x00000006 // Clock loss Reset
134 #define PWRCTRL_RST_WARM 0x00000007 // Warm Reset
135 
136 //*****************************************************************************
137 //
138 // API Functions and prototypes
139 //
140 //*****************************************************************************
141 
142 //*****************************************************************************
143 //
170 //
171 //*****************************************************************************
172 extern void PowerCtrlStateSet(uint32_t ui32Powerstate);
173 
174 //*****************************************************************************
175 //
194 //
195 //*****************************************************************************
196 extern void PowerCtrlSourceSet(uint32_t ui32PowerConfig);
197 
198 //*****************************************************************************
199 //
212 //
213 //*****************************************************************************
214 __STATIC_INLINE uint32_t
216 {
217  uint32_t ui32PowerConfig;
218 
219  //
220  // Return the current power source
221  //
222  ui32PowerConfig = HWREG(AON_SYSCTL_BASE + AON_SYSCTL_O_PWRCTL);
223  if(ui32PowerConfig & AON_SYSCTL_PWRCTL_DCDC_ACTIVE)
224  {
225  return (PWRCTRL_PWRSRC_DCDC);
226  }
227  else
228  {
229  return (PWRCTRL_PWRSRC_GLDO);
230  }
231 }
232 
233 
234 //*****************************************************************************
235 //
248 //
249 //*****************************************************************************
250 __STATIC_INLINE uint32_t
252 {
253  //
254  // Get the reset source.
255  //
256  return (HWREG(AON_SYSCTL_BASE + AON_SYSCTL_O_RESETCTL) &
258 }
259 
260 //*****************************************************************************
261 //
271 //
272 //*****************************************************************************
273 __STATIC_INLINE void
275 {
276  //
277  // Close the IO latches at AON_IOC level and in the padring.
278  //
281  HWREG(AON_RTC_BASE + AON_RTC_O_SYNC);
282 }
283 
284 //*****************************************************************************
285 //
296 //
297 //*****************************************************************************
298 __STATIC_INLINE void
300 {
301  //
302  // Open the IO latches at AON_IOC level and in the padring
303  //
306  HWREG(AON_RTC_BASE + AON_RTC_O_SYNC);
307 }
308 
309 //*****************************************************************************
310 //
311 // Support for DriverLib in ROM:
312 // Redirect to implementation in ROM when available.
313 //
314 //*****************************************************************************
315 #if !defined(DRIVERLIB_NOROM) && !defined(DOXYGEN)
316  #include <driverlib/rom.h>
317  #ifdef ROM_PowerCtrlStateSet
318  #undef PowerCtrlStateSet
319  #define PowerCtrlStateSet ROM_PowerCtrlStateSet
320  #endif
321  #ifdef ROM_PowerCtrlSourceSet
322  #undef PowerCtrlSourceSet
323  #define PowerCtrlSourceSet ROM_PowerCtrlSourceSet
324  #endif
325 #endif
326 
327 //*****************************************************************************
328 //
329 // Mark the end of the C bindings section for C++ compilers.
330 //
331 //*****************************************************************************
332 #ifdef __cplusplus
333 }
334 #endif
335 
336 #endif // __PWR_CTRL_H__
337 
338 //*****************************************************************************
339 //
343 //
344 //*****************************************************************************
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:260
static void PowerCtrlIOFreezeDisable(void)
Definition: pwr_ctrl.h:299
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:274
#define PWRCTRL_PWRSRC_GLDO
Definition: pwr_ctrl.h:119
void PowerCtrlStateSet(uint32_t ui32Powerstate)
Force the system into low power modes.
Definition: pwr_ctrl.c:60
static uint32_t PowerCtrlResetSourceGet(void)
Get the last known reset source of the system.
Definition: pwr_ctrl.h:251
static uint32_t PowerCtrlSourceGet(void)
Get the main power source.
Definition: pwr_ctrl.h:215
#define PWRCTRL_PWRSRC_DCDC
Definition: pwr_ctrl.h:118