CC26xx Driver Library |

- Main Page
- Related Pages
- CC26xx APIs
- Register Descriptions
- Online Resources

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
pwr_ctrl.c
Go to the documentation of this file.
1 /******************************************************************************
2 * Filename: pwr_ctrl.c
3 * Revised: 2015-01-13 16:59:55 +0100 (ti, 13 jan 2015)
4 * Revision: 42365
5 *
6 * Description: Power Control driver.
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 #include <driverlib/pwr_ctrl.h>
40
41 //*****************************************************************************
42 //
43 // Handle support for DriverLib in ROM:
44 // This section will undo prototype renaming made in the header file
45 //
46 //*****************************************************************************
47 #ifndef DRIVERLIB_GENERATE_ROM
48 #undef PowerCtrlStateSet
49 #define PowerCtrlStateSet NOROM_PowerCtrlStateSet
50 #undef PowerCtrlSourceSet
51 #define PowerCtrlSourceSet NOROM_PowerCtrlSourceSet
52 #endif
53
54 //*****************************************************************************
55 //
57 //
58 //*****************************************************************************
59 void
60 PowerCtrlStateSet(uint32_t ui32Powerstate)
61 {
62 //
63 // Check the arguments.
64 //
65 ASSERT((ui32Powerstate == PWRCTRL_STANDBY) ||
66 (ui32Powerstate == PWRCTRL_POWER_DOWN) ||
67 (ui32Powerstate == PWRCTRL_SHUTDOWN));
68
69 //
70 // Configure the desired power state.
71 //
72 if(ui32Powerstate == PWRCTRL_STANDBY)
73 {
74 //
75 //
76 // Turn of all power domains in the MCU voltage domain. This is
77 // necessary to conserve power before switching to the uLDO.
78 //
79 PRCMPowerDomainOff(PRCM_DOMAIN_RFCORE | PRCM_DOMAIN_SERIAL |
80 PRCM_DOMAIN_PERIPH | PRCM_DOMAIN_CPU |
81 PRCM_DOMAIN_VIMS);
82
83 //
84 // Make sure to request power off of the JTAG domain.
85 //
86 AONWUCJtagPowerOff();
87
88 //
89 // Configuration of clock source for MCU and AUX in standby mode.
90 //
91 AONWUCMcuPowerDownConfig(AONWUC_CLOCK_SRC_LF);
92 AONWUCAuxPowerDownConfig(AONWUC_CLOCK_SRC_LF);
93
94 //
95 // Configure the recharge controller and request the uLDO as power
96 // source.
97 //
98 AONWUCRechargeCtrlConfigSet(true, 34, 2500, 5000);
99
100 //
101 // Enable AUX power down
102 // This will tell the system that no HF source is needed and will
103 // allow the system to use the low-leakage/effect power supply.
104 // NB. This does not allow co-existence of an independent AUX
105 // controller.
106 //
107 AUXWUCPowerCtrl(AUX_WUC_POWER_DOWN);
108 while(AONWUCPowerStatus() & AONWUC_AUX_POWER_ON);
109
110 //
111 // Request the uLDO for standby power consumption.
112 //
113 PowerCtrlSourceSet(PWRCTRL_PWRSRC_ULDO);
114
115 //
116 // Sync the AON interface to ensure all writes have gone through
117 //
118 HWREG(AON_RTC_BASE + AON_RTC_O_SYNC);
119
120 //
121 // Enable transition to standby.
122 //
123 PRCMDeepSleep();
124 }
125 else if(ui32Powerstate == PWRCTRL_POWER_DOWN)
126 {
127 //
128 // Latch the current IO configuration before going to sleep to ensure
129 // the IOs retain their value even after boot and reset of the
130 // configuration.
131 //
132 AONIOCFreezeEnable();
133
134 //
135 // Make sure retention on MCU SRAM is on - on pr. default.
136 //
137 AONWUCMcuSRamConfig(MCU_RAM0_RETENTION | MCU_RAM1_RETENTION |
138 MCU_RAM2_RETENTION | MCU_RAM3_RETENTION);
139
140 //
141 // Allow power off on all domains in the MCU voltage domain.
142 // This is necessary to conserve power before switching to the uLDO.
143 //
144 PRCMPowerDomainOff(PRCM_DOMAIN_RFCORE | PRCM_DOMAIN_SERIAL |
145 PRCM_DOMAIN_PERIPH | PRCM_DOMAIN_CPU |
146 PRCM_DOMAIN_VIMS);
147
148 //
149 // Turn off the MCU voltage domain. This will not take effect until CM3
150 // is in deep sleep.
151 //
152 PRCMMcuPowerOff();
153
154 //
155 // Set the wake up mode - default value coming out of reset
156 //
157 AONWUCMcuWakeUpConfig(MCU_IMM_WAKE_UP);
158
159 //
160 // VIRTUAL POWER OFF DISABLE is the default value coming out of reset
161 //
162 AONWUCMcuPowerOffConfig(MCU_VIRT_PWOFF_DISABLE);
163
164 //
165 // Configure the recharge controller and request the uLDO as power
166 // source.
167 // Recommended maximum numbers for lowest power consumption
168 // AdaptRate = 96
169 // MaxPeriod = 21440
170 // InitPeriod = 14816
171 //
172 AONWUCRechargeCtrlConfigSet(true, 75, 5000, 7500);
173
174 //
175 // Enable AUX power down with LF clock source
176 // Turn off JTAG domain and enable powerdown - values are default.
177 //
178 AONWUCAuxPowerDownConfig(AONWUC_CLOCK_SRC_LF);
179 AUXWUCPowerCtrl(AUX_WUC_POWER_DOWN);
180 AONWUCDomainPowerDownEnable();
181 while(AONWUCPowerStatus() & AONWUC_AUX_POWER_ON);
182
183 //
184 // Sync the AON interface to ensure all writes have gone through
185 //
186 HWREG(AON_RTC_BASE + AON_RTC_O_SYNC);
187
188 //
189 // Enable transition to power down.
190 //
191 PRCMDeepSleep();
192 }
193 else
194 {
195 //
196 // Latch the current IO configuration before going to sleep to ensure
197 // the IOs retain their value even after boot and reset of the
198 // configuration.
199 //
200 AONIOCFreezeEnable();
201
202 //
203 // Turn of all power domains in the MCU voltage domain.
204 //
205 PRCMPowerDomainOff(PRCM_DOMAIN_RFCORE | PRCM_DOMAIN_SERIAL |
206 PRCM_DOMAIN_PERIPH | PRCM_DOMAIN_CPU |
207 PRCM_DOMAIN_VIMS);
208
209 //
210 // Turn off the MCU voltage domain. This will not take effect until CM3
211 // is in deep sleep.
212 //
213 PRCMMcuPowerOff();
214
215 //
216 // Set the wake up mode of MCU to immediate
217 //
218 AONWUCMcuWakeUpConfig(MCU_IMM_WAKE_UP);
219 AONWUCMcuPowerOffConfig(MCU_VIRT_PWOFF_DISABLE);
220
221 //
222 // Turn off the AUX domain and wait for power to be off.
223 //
224 // Is this required for shutdown mode? or will AUX automatically
225 // power off.
226 AUXWUCPowerCtrl(AUX_WUC_POWER_OFF);
227 while(AONWUCPowerStatus() & AONWUC_AUX_POWER_ON)
228 { }
229
230 //
231 // Latch the IOs in the padring before going to sleep to retain their
232 // value even after boot and reset of the configuration.
233 //
234 PowerCtrlIOFreezeEnable();
235
236 //
237 // Enable shutdown and make sure the AON interface is in sync on the
238 // 32kHz clock.
239 //
240 AONWUCShutDownEnable();
241
242 //
243 // Sync the AON interface to ensure all writes have gone through
244 //
245 HWREG(AON_RTC_BASE + AON_RTC_O_SYNC);
246
247 //
248 // Enable transition to shutdown.
249 //
250 PRCMDeepSleep();
251 }
252 }
253
254 //*****************************************************************************
255 //
257 //
258 //*****************************************************************************
259 void
260 PowerCtrlSourceSet(uint32_t ui32PowerConfig)
261 {
262 //
263 // Check the arguments.
264 //
265 ASSERT((ui32PowerConfig == PWRCTRL_PWRSRC_DCDC) ||
266 (ui32PowerConfig == PWRCTRL_PWRSRC_GLDO) ||
267 (ui32PowerConfig == PWRCTRL_PWRSRC_ULDO));
268
269 //
270 // Configure the power.
271 //
272 if(ui32PowerConfig == PWRCTRL_PWRSRC_DCDC) {
273 HWREG(AON_SYSCTL_BASE + AON_SYSCTL_O_PWRCTL) |=
274 (AON_SYSCTL_PWRCTL_DCDC_EN | AON_SYSCTL_PWRCTL_DCDC_ACTIVE);
275 }
276 else if (ui32PowerConfig == PWRCTRL_PWRSRC_GLDO)
277 {
278 HWREG(AON_SYSCTL_BASE + AON_SYSCTL_O_PWRCTL) &=
279 ~(AON_SYSCTL_PWRCTL_DCDC_EN | AON_SYSCTL_PWRCTL_DCDC_ACTIVE);
280 }
281 else
282 {
283 PRCMMcuUldoConfigure(true);
284 }
285 }
MCU_IMM_WAKE_UP
#define MCU_IMM_WAKE_UP
Definition: aon_wuc.h:131
AONWUCJtagPowerOff
__STATIC_INLINE void AONWUCJtagPowerOff(void)
Request power off of the JTAG domain.
Definition: aon_wuc.h:981
pwr_ctrl.h
PRCMMcuUldoConfigure
__STATIC_INLINE void PRCMMcuUldoConfigure(uint32_t ui32Enable)
Assert or deassert a request for the uLDO.
Definition: prcm.h:360
PRCMMcuPowerOff
__STATIC_INLINE void PRCMMcuPowerOff(void)
Request a power off of the MCU voltage domain.
Definition: prcm.h:310
AUX_WUC_POWER_DOWN
#define AUX_WUC_POWER_DOWN
Definition: aux_wuc.h:95
PowerCtrlSourceSet
void PowerCtrlSourceSet(uint32_t ui32PowerConfig)
Set (Request) the main power source.
Definition: pwr_ctrl.c:260
AUXWUCPowerCtrl
void AUXWUCPowerCtrl(uint32_t ui32PowerMode)
Control the power to the AUX domain.
Definition: aux_wuc.c:274
AONIOCFreezeEnable
__STATIC_INLINE void AONIOCFreezeEnable(void)
Freeze the IOs.
Definition: aon_ioc.h:200
MCU_RAM2_RETENTION
#define MCU_RAM2_RETENTION
Definition: aon_wuc.h:146
ASSERT
#define ASSERT(expr)
Definition: debug.h:65
AUX_WUC_POWER_OFF
#define AUX_WUC_POWER_OFF
Definition: aux_wuc.h:94
PRCM_DOMAIN_VIMS
#define PRCM_DOMAIN_VIMS
Definition: prcm.h:146
AONWUC_CLOCK_SRC_LF
#define AONWUC_CLOCK_SRC_LF
Definition: aon_wuc.h:103
AONWUCRechargeCtrlConfigSet
void AONWUCRechargeCtrlConfigSet(bool bAdaptEnable, uint32_t ui32AdaptRate, uint32_t ui32Period, uint32_t ui32MaxPeriod)
Configure the recharge controller.
Definition: aon_wuc.c:221
AONWUC_AUX_POWER_ON
#define AONWUC_AUX_POWER_ON
Definition: aon_wuc.h:178
PWRCTRL_PWRSRC_ULDO
#define PWRCTRL_PWRSRC_ULDO
Definition: pwr_ctrl.h:120
AONWUCMcuWakeUpConfig
__STATIC_INLINE void AONWUCMcuWakeUpConfig(uint32_t ui32WakeUp)
Configure the wake-up procedure for the MCU domain.
Definition: aon_wuc.h:331
PRCM_DOMAIN_PERIPH
#define PRCM_DOMAIN_PERIPH
Definition: prcm.h:142
MCU_RAM3_RETENTION
#define MCU_RAM3_RETENTION
Definition: aon_wuc.h:147
AONWUCMcuPowerOffConfig
__STATIC_INLINE void AONWUCMcuPowerOffConfig(uint32_t ui32Mode)
Configure the power down mode for the MCU domain.
Definition: aon_wuc.h:294
AONWUCMcuSRamConfig
__STATIC_INLINE void AONWUCMcuSRamConfig(uint32_t ui32Retention)
Configure the retention on the block RAM in the MCU domain.
Definition: aon_wuc.h:376
PowerCtrlIOFreezeEnable
__STATIC_INLINE void PowerCtrlIOFreezeEnable(void)
Close the latches in the AON IOC interface and in padring.
Definition: pwr_ctrl.h:302
PWRCTRL_PWRSRC_GLDO
#define PWRCTRL_PWRSRC_GLDO
Definition: pwr_ctrl.h:119
AONWUCShutDownEnable
__STATIC_INLINE void AONWUCShutDownEnable(void)
Enable shut-down of the device.
Definition: aon_wuc.h:732
PWRCTRL_STANDBY
#define PWRCTRL_STANDBY
Definition: pwr_ctrl.h:105
PowerCtrlStateSet
void PowerCtrlStateSet(uint32_t ui32Powerstate)
Force the system in to low power modes.
Definition: pwr_ctrl.c:60
PWRCTRL_SHUTDOWN
#define PWRCTRL_SHUTDOWN
Definition: pwr_ctrl.h:107
PRCMDeepSleep
void PRCMDeepSleep(void)
Put the processor into deep-sleep mode.
Definition: prcm.c:775
MCU_RAM1_RETENTION
#define MCU_RAM1_RETENTION
Definition: aon_wuc.h:145
AONWUCAuxPowerDownConfig
__STATIC_INLINE void AONWUCAuxPowerDownConfig(uint32_t ui32ClkSrc)
Configure the power down mode for the AUX domain.
Definition: aon_wuc.h:480
PRCM_DOMAIN_SERIAL
#define PRCM_DOMAIN_SERIAL
Definition: prcm.h:140
PRCM_DOMAIN_RFCORE
#define PRCM_DOMAIN_RFCORE
Definition: prcm.h:138
MCU_VIRT_PWOFF_DISABLE
#define MCU_VIRT_PWOFF_DISABLE
Definition: aon_wuc.h:129
PRCM_DOMAIN_CPU
#define PRCM_DOMAIN_CPU
Definition: prcm.h:148
PRCMPowerDomainOff
void PRCMPowerDomainOff(uint32_t ui32Domains)
Turn off a specific power domain.
Definition: prcm.c:561
PWRCTRL_PWRSRC_DCDC
#define PWRCTRL_PWRSRC_DCDC
Definition: pwr_ctrl.h:118
AONWUCDomainPowerDownEnable
__STATIC_INLINE void AONWUCDomainPowerDownEnable(void)
Enable power down mode on AUX and MCU domain.
Definition: aon_wuc.h:760
AONWUCPowerStatus
__STATIC_INLINE uint32_t AONWUCPowerStatus(void)
Get the power status of the device.
Definition: aon_wuc.h:707
AONWUCMcuPowerDownConfig
__STATIC_INLINE void AONWUCMcuPowerDownConfig(uint32_t ui32ClkSrc)
Configure the power down clock for the MCU domain.
Definition: aon_wuc.h:254
PWRCTRL_POWER_DOWN
#define PWRCTRL_POWER_DOWN
Definition: pwr_ctrl.h:106
MCU_RAM0_RETENTION
#define MCU_RAM0_RETENTION
Definition: aon_wuc.h:144