CC26xx Driver Library
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
pwr_ctrl.h
Go to the documentation of this file.
1 /******************************************************************************
2 * Filename: pwr_ctrl.h
3 * Revised: 2015-01-14 12:12:44 +0100 (on, 14 jan 2015)
4 * Revision: 42373
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 //
43 //
44 //*****************************************************************************
45 
46 #ifndef __PWR_CTRL_H__
47 #define __PWR_CTRL_H__
48 
49 //*****************************************************************************
50 //
51 // If building with a C++ compiler, make all of the definitions in this header
52 // have a C binding.
53 //
54 //*****************************************************************************
55 #ifdef __cplusplus
56 extern "C"
57 {
58 #endif
59 
60 #include <stdbool.h>
61 #include <stdint.h>
62 #include <inc/hw_types.h>
63 #include <inc/hw_memmap.h>
64 #include <inc/hw_ints.h>
65 #include <inc/hw_aon_wuc.h>
66 #include <inc/hw_aon_sysctl.h>
67 #include <inc/hw_aon_rtc.h>
68 #include <inc/hw_adi_2_refsys.h>
69 #include <driverlib/debug.h>
70 #include <driverlib/interrupt.h>
71 #include <driverlib/osc.h>
72 #include <driverlib/cpu.h>
73 #include <driverlib/prcm.h>
74 #include <driverlib/aon_wuc.h>
75 #include <driverlib/aon_ioc.h>
76 #include <driverlib/aux_wuc.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 // Do not define DRIVERLIB_GENERATE_ROM!
92 //
93 //*****************************************************************************
94 #ifndef DRIVERLIB_GENERATE_ROM
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 //
168 //
169 //*****************************************************************************
170 extern void PowerCtrlStateSet(uint32_t ui32Powerstate);
171 
172 //*****************************************************************************
173 //
192 //
193 //*****************************************************************************
194 extern void PowerCtrlSourceSet(uint32_t ui32PowerConfig);
195 
196 //*****************************************************************************
197 //
210 //
211 //*****************************************************************************
212 __STATIC_INLINE uint32_t
214 {
215  uint32_t ui32PowerConfig;
216 
217  //
218  // Return the current power source
219  //
220  ui32PowerConfig = HWREG(AON_SYSCTL_BASE + AON_SYSCTL_O_PWRCTL);
221  if(ui32PowerConfig & AON_SYSCTL_PWRCTL_DCDC_ACTIVE)
222  {
223  return (PWRCTRL_PWRSRC_DCDC);
224  }
225  else
226  {
227  return (PWRCTRL_PWRSRC_GLDO);
228  }
229 }
230 
231 //*****************************************************************************
232 //
243 //
244 //*****************************************************************************
245 __STATIC_INLINE void
246 PowerCtrlIoConfigSet(uint32_t ui32IoConfig)
247 {
248  //
249  // Check the arguments.
250  //
251  ASSERT(((ui32IoConfig & PWRCTRL_IOSEG2_ENABLE) ^
252  (ui32IoConfig & PWRCTRL_IOSEG2_DISABLE)) ||
253  ((ui32IoConfig & PWRCTRL_IOSEG3_ENABLE) ^
254  (ui32IoConfig & PWRCTRL_IOSEG3_DISABLE)));
255 
256  //
257  // Configure the IO ring.
258  //
259  HWREG(AON_SYSCTL_BASE + AON_SYSCTL_O_PWRCTL) = ui32IoConfig;
260 }
261 
262 //*****************************************************************************
263 //
276 //
277 //*****************************************************************************
278 __STATIC_INLINE uint32_t
280 {
281  //
282  // Get the reset source.
283  //
284  return (HWREG(AON_SYSCTL_BASE + AON_SYSCTL_O_RESETCTL) &
286 }
287 
288 //*****************************************************************************
289 //
299 //
300 //*****************************************************************************
301 __STATIC_INLINE void
303 {
304  //
305  // Close the IO latches at AON_IOC level and in the padring.
306  //
309  HWREG(AON_RTC_BASE + AON_RTC_O_SYNC);
310 }
311 
312 //*****************************************************************************
313 //
324 //
325 //*****************************************************************************
326 __STATIC_INLINE void
328 {
329  //
330  // Open the IO latches at AON_IOC level and in the padring
331  //
334  HWREG(AON_RTC_BASE + AON_RTC_O_SYNC);
335 }
336 
337 //*****************************************************************************
338 //
339 // Support for DriverLib in ROM:
340 // Redirect to implementation in ROM when available.
341 //
342 //*****************************************************************************
343 #ifndef DRIVERLIB_NOROM
344  #include <driverlib/rom.h>
345  #ifdef ROM_PowerCtrlStateSet
346  #undef PowerCtrlStateSet
347  #define PowerCtrlStateSet ROM_PowerCtrlStateSet
348  #endif
349  #ifdef ROM_PowerCtrlSourceSet
350  #undef PowerCtrlSourceSet
351  #define PowerCtrlSourceSet ROM_PowerCtrlSourceSet
352  #endif
353 #endif
354 
355 //*****************************************************************************
356 //
357 // Mark the end of the C bindings section for C++ compilers.
358 //
359 //*****************************************************************************
360 #ifdef __cplusplus
361 }
362 #endif
363 
364 #endif // __PWR_CTRL_H__
365 
366 //*****************************************************************************
367 //
370 //
371 //*****************************************************************************
__STATIC_INLINE uint32_t PowerCtrlResetSourceGet(void)
Get the last known reset source of the system.
Definition: pwr_ctrl.h:279
void PowerCtrlSourceSet(uint32_t ui32PowerConfig)
Set (Request) the main power source.
Definition: pwr_ctrl.c:260
__STATIC_INLINE void AONIOCFreezeEnable(void)
Freeze the IOs.
Definition: aon_ioc.h:200
#define ASSERT(expr)
Definition: debug.h:65
#define PWRCTRL_IOSEG3_ENABLE
Definition: pwr_ctrl.h:114
__STATIC_INLINE void AONIOCFreezeDisable(void)
Un-freeze the IOs.
Definition: aon_ioc.h:223
#define PWRCTRL_IOSEG3_DISABLE
Definition: pwr_ctrl.h:116
__STATIC_INLINE uint32_t PowerCtrlSourceGet(void)
Get the main power source.
Definition: pwr_ctrl.h:213
__STATIC_INLINE void PowerCtrlIOFreezeDisable(void)
Definition: pwr_ctrl.h:327
__STATIC_INLINE void PowerCtrlIOFreezeEnable(void)
Close the latches in the AON IOC interface and in padring.
Definition: pwr_ctrl.h:302
#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_INLINE void PowerCtrlIoConfigSet(uint32_t ui32IoConfig)
Configure the IO ring.
Definition: pwr_ctrl.h:246
#define PWRCTRL_IOSEG2_ENABLE
Definition: pwr_ctrl.h:115
#define PWRCTRL_IOSEG2_DISABLE
Definition: pwr_ctrl.h:117
#define PWRCTRL_PWRSRC_DCDC
Definition: pwr_ctrl.h:118