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
aux_wuc.c
Go to the documentation of this file.
1 /******************************************************************************
2 * Filename: aux_wuc.c
3 * Revised: 2015-01-13 16:59:55 +0100 (ti, 13 jan 2015)
4 * Revision: 42365
5 *
6 * Description: Driver for the AUX Wakeup 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 #include <driverlib/aux_wuc.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 AUXWUCClockEnable
49 #define AUXWUCClockEnable NOROM_AUXWUCClockEnable
50 #undef AUXWUCClockDisable
51 #define AUXWUCClockDisable NOROM_AUXWUCClockDisable
52 #undef AUXWUCClockStatus
53 #define AUXWUCClockStatus NOROM_AUXWUCClockStatus
54 #undef AUXWUCPowerCtrl
55 #define AUXWUCPowerCtrl NOROM_AUXWUCPowerCtrl
56 #endif
57
58 //****************************************************************************
59 //
61 //
62 //****************************************************************************
63 void
64 AUXWUCClockEnable(uint32_t ui32Clocks)
65 {
66 //
67 // Check the arguments.
68 //
69 ASSERT((ui32Clocks & AUX_WUC_ADI_CLOCK) ||
70 (ui32Clocks & AUX_WUC_OSCCTRL_CLOCK) ||
71 (ui32Clocks & AUX_WUC_TDCIF_CLOCK) ||
72 (ui32Clocks & AUX_WUC_SOC_CLOCK) ||
73 (ui32Clocks & AUX_WUC_TIMER_CLOCK) ||
74 (ui32Clocks & AUX_WUC_AIODIO0_CLOCK) ||
75 (ui32Clocks & AUX_WUC_AIODIO1_CLOCK) ||
76 (ui32Clocks & AUX_WUC_SMPH_CLOCK) ||
77 (ui32Clocks & AUX_WUC_TDC_CLOCK) ||
78 (ui32Clocks & AUX_WUC_ADC_CLOCK) ||
79 (ui32Clocks & AUX_WUC_REF_CLOCK));
80
81 //
82 // Enable some of the clocks in the clock register.
83 //
84 HWREG(AUX_WUC_BASE + AUX_WUC_O_MODCLKEN0) |= (ui32Clocks &
85 AUX_WUC_MODCLK_MASK);
86
87 //
88 // Check the rest.
89 //
90 if(ui32Clocks & AUX_WUC_ADC_CLOCK)
91 {
92 HWREG(AUX_WUC_BASE + AUX_WUC_O_ADCCLKCTL) =
93 AUX_WUC_ADCCLKCTL_REQ;
94 }
95 if(ui32Clocks & AUX_WUC_TDC_CLOCK)
96 {
97 HWREG(AUX_WUC_BASE + AUX_WUC_O_TDCCLKCTL) =
98 AUX_WUC_TDCCLKCTL_REQ;
99 }
100 if(ui32Clocks & AUX_WUC_REF_CLOCK)
101 {
102 HWREG(AUX_WUC_BASE + AUX_WUC_O_REFCLKCTL) =
103 AUX_WUC_REFCLKCTL_REQ;
104 }
105 }
106
107 //****************************************************************************
108 //
110 //
111 //****************************************************************************
112 void
113 AUXWUCClockDisable(uint32_t ui32Clocks)
114 {
115 //
116 // Check the arguments.
117 //
118 ASSERT((ui32Clocks & AUX_WUC_ADI_CLOCK) ||
119 (ui32Clocks & AUX_WUC_OSCCTRL_CLOCK) ||
120 (ui32Clocks & AUX_WUC_TDCIF_CLOCK) ||
121 (ui32Clocks & AUX_WUC_SOC_CLOCK) ||
122 (ui32Clocks & AUX_WUC_TIMER_CLOCK) ||
123 (ui32Clocks & AUX_WUC_AIODIO0_CLOCK) ||
124 (ui32Clocks & AUX_WUC_AIODIO1_CLOCK) ||
125 (ui32Clocks & AUX_WUC_SMPH_CLOCK) ||
126 (ui32Clocks & AUX_WUC_TDC_CLOCK) ||
127 (ui32Clocks & AUX_WUC_ADC_CLOCK) ||
128 (ui32Clocks & AUX_WUC_REF_CLOCK));
129
130 //
131 // Disable some of the clocks in the clock register.
132 //
133 HWREG(AUX_WUC_BASE + AUX_WUC_O_MODCLKEN0) &= ~(ui32Clocks &
134 AUX_WUC_MODCLK_MASK);
135
136 //
137 // Check the rest.
138 //
139 if(ui32Clocks & AUX_WUC_ADC_CLOCK)
140 {
141 HWREG(AUX_WUC_BASE + AUX_WUC_O_ADCCLKCTL) &=
142 ~AUX_WUC_ADCCLKCTL_REQ;
143 }
144 if(ui32Clocks & AUX_WUC_TDC_CLOCK)
145 {
146 HWREG(AUX_WUC_BASE + AUX_WUC_O_TDCCLKCTL) &=
147 ~AUX_WUC_TDCCLKCTL_REQ;
148 }
149 if(ui32Clocks & AUX_WUC_REF_CLOCK)
150 {
151 HWREG(AUX_WUC_BASE + AUX_WUC_O_REFCLKCTL) &=
152 ~AUX_WUC_REFCLKCTL_REQ;
153 }
154 }
155
156 //****************************************************************************
157 //
159 //
160 //****************************************************************************
161 uint32_t
162 AUXWUCClockStatus(uint32_t ui32Clocks)
163 {
164 bool bClockStatus;
165 uint32_t ui32ClockRegister;
166
167 //
168 // Check the arguments.
169 //
170 ASSERT((ui32Clocks & AUX_WUC_ADI_CLOCK) ||
171 (ui32Clocks & AUX_WUC_OSCCTRL_CLOCK) ||
172 (ui32Clocks & AUX_WUC_TDCIF_CLOCK) ||
173 (ui32Clocks & AUX_WUC_SOC_CLOCK) ||
174 (ui32Clocks & AUX_WUC_TIMER_CLOCK) ||
175 (ui32Clocks & AUX_WUC_AIODIO0_CLOCK) ||
176 (ui32Clocks & AUX_WUC_AIODIO1_CLOCK) ||
177 (ui32Clocks & AUX_WUC_SMPH_CLOCK) ||
178 (ui32Clocks & AUX_WUC_TDC_CLOCK) ||
179 (ui32Clocks & AUX_WUC_ADC_CLOCK) ||
180 (ui32Clocks & AUX_WUC_REF_CLOCK));
181
182 bClockStatus = true;
183
184 //
185 // Read the status registers.
186 //
187 ui32ClockRegister = HWREG(AUX_WUC_BASE + AUX_WUC_O_MODCLKEN0);
188
189 //
190 // Check all requested clocks
191 //
192 if(ui32Clocks & AUX_WUC_ADI_CLOCK)
193 {
194 bClockStatus = bClockStatus && (ui32ClockRegister &
195 AUX_WUC_MODCLKEN0_AUX_ADI4 ?
196 true : false);
197 }
198 if(ui32Clocks & AUX_WUC_OSCCTRL_CLOCK)
199 {
200 bClockStatus = bClockStatus && (ui32ClockRegister &
201 AUX_WUC_MODCLKEN0_AUX_DDI0_OSC ?
202 true : false);
203 }
204 if(ui32Clocks & AUX_WUC_TDCIF_CLOCK)
205 {
206 bClockStatus = bClockStatus && (ui32ClockRegister &
207 AUX_WUC_MODCLKEN0_TDC ?
208 true : false);
209 }
210 if(ui32Clocks & AUX_WUC_SOC_CLOCK)
211 {
212 bClockStatus = bClockStatus && (ui32ClockRegister &
213 AUX_WUC_MODCLKEN0_SOC ?
214 true : false);
215 }
216 if(ui32Clocks & AUX_WUC_TIMER_CLOCK)
217 {
218 bClockStatus = bClockStatus && (ui32ClockRegister &
219 AUX_WUC_MODCLKEN0_TIMER ?
220 true : false);
221 }
222 if(ui32Clocks & AUX_WUC_AIODIO0_CLOCK)
223 {
224 bClockStatus = bClockStatus && (ui32ClockRegister &
225 AUX_WUC_MODCLKEN0_AIODIO0 ?
226 true : false);
227 }
228 if(ui32Clocks & AUX_WUC_AIODIO1_CLOCK)
229 {
230 bClockStatus = bClockStatus && (ui32ClockRegister &
231 AUX_WUC_MODCLKEN0_AIODIO1 ?
232 true : false);
233 }
234 if(ui32Clocks & AUX_WUC_SMPH_CLOCK)
235 {
236 bClockStatus = bClockStatus && (ui32ClockRegister &
237 AUX_WUC_MODCLKEN0_SMPH ?
238 true : false);
239 }
240 if(ui32Clocks & AUX_WUC_ADC_CLOCK)
241 {
242 ui32ClockRegister = HWREG(AUX_WUC_BASE + AUX_WUC_O_ADCCLKCTL);
243 bClockStatus = bClockStatus && (ui32ClockRegister &
244 AUX_WUC_ADCCLKCTL_ACK ?
245 true : false);
246 }
247 if(ui32Clocks & AUX_WUC_TDC_CLOCK)
248 {
249 ui32ClockRegister = HWREG(AUX_WUC_BASE + AUX_WUC_O_TDCCLKCTL);
250 bClockStatus = bClockStatus && (ui32ClockRegister &
251 AUX_WUC_TDCCLKCTL_ACK ?
252 true : false);
253 }
254 if(ui32Clocks & AUX_WUC_REF_CLOCK)
255 {
256 ui32ClockRegister = HWREG(AUX_WUC_BASE + AUX_WUC_O_REFCLKCTL);
257 bClockStatus = bClockStatus && (ui32ClockRegister &
258 AUX_WUC_REFCLKCTL_ACK ?
259 true : false);
260 }
261
262 //
263 // Return the clock status.
264 //
265 return bClockStatus ? AUX_WUC_CLOCK_READY : AUX_WUC_CLOCK_OFF;
266 }
267
268 //****************************************************************************
269 //
271 //
272 //****************************************************************************
273 void
274 AUXWUCPowerCtrl(uint32_t ui32PowerMode)
275 {
276 //
277 // Check the arguments.
278 //
279 ASSERT((ui32PowerMode == AUX_WUC_POWER_OFF) ||
280 (ui32PowerMode == AUX_WUC_POWER_DOWN) ||
281 (ui32PowerMode == AUX_WUC_POWER_ACTIVE));
282
283 //
284 // Power on/off.
285 //
286 if(ui32PowerMode == AUX_WUC_POWER_OFF)
287 {
288 HWREG(AUX_WUC_BASE + AUX_WUC_O_PWROFFREQ) = AUX_WUC_PWROFFREQ_REQ;
289 HWREG(AUX_WUC_BASE + AUX_WUC_O_MCUBUSCTL) = AUX_WUC_MCUBUSCTL_DISCONNECT_REQ;
290 return;
291 }
292 else
293 {
294 HWREG(AUX_WUC_BASE + AUX_WUC_O_PWROFFREQ) = 0x0;
295 }
296
297 //
298 // Power down/active.
299 //
300 if(ui32PowerMode == AUX_WUC_POWER_DOWN)
301 {
302 HWREG(AUX_WUC_BASE + AUX_WUC_O_PWRDWNREQ) =
303 AUX_WUC_PWRDWNREQ_REQ;
304 HWREG(AUX_WUC_BASE + AUX_WUC_O_MCUBUSCTL) = AUX_WUC_MCUBUSCTL_DISCONNECT_REQ;
305 }
306 else
307 {
308 HWREG(AUX_WUC_BASE + AUX_WUC_O_PWRDWNREQ) = 0x0;
309 }
310 }
AUX_WUC_TDC_CLOCK
#define AUX_WUC_TDC_CLOCK
Definition: aux_wuc.h:113
AUXWUCClockEnable
void AUXWUCClockEnable(uint32_t ui32Clocks)
Enable clocks for peripherals in the AUX domain.
Definition: aux_wuc.c:64
AUX_WUC_POWER_DOWN
#define AUX_WUC_POWER_DOWN
Definition: aux_wuc.h:95
AUX_WUC_OSCCTRL_CLOCK
#define AUX_WUC_OSCCTRL_CLOCK
Definition: aux_wuc.h:109
AUXWUCPowerCtrl
void AUXWUCPowerCtrl(uint32_t ui32PowerMode)
Control the power to the AUX domain.
Definition: aux_wuc.c:274
AUXWUCClockStatus
uint32_t AUXWUCClockStatus(uint32_t ui32Clocks)
Get the status of a clock.
Definition: aux_wuc.c:162
AUX_WUC_SOC_CLOCK
#define AUX_WUC_SOC_CLOCK
Definition: aux_wuc.h:107
ASSERT
#define ASSERT(expr)
Definition: debug.h:65
AUX_WUC_CLOCK_READY
#define AUX_WUC_CLOCK_READY
Definition: aux_wuc.h:119
AUXWUCClockDisable
void AUXWUCClockDisable(uint32_t ui32Clocks)
Disable clocks for peripherals in the AUX domain.
Definition: aux_wuc.c:113
AUX_WUC_POWER_OFF
#define AUX_WUC_POWER_OFF
Definition: aux_wuc.h:94
AUX_WUC_AIODIO0_CLOCK
#define AUX_WUC_AIODIO0_CLOCK
Definition: aux_wuc.h:104
AUX_WUC_ADI_CLOCK
#define AUX_WUC_ADI_CLOCK
Definition: aux_wuc.h:110
AUX_WUC_AIODIO1_CLOCK
#define AUX_WUC_AIODIO1_CLOCK
Definition: aux_wuc.h:105
AUX_WUC_SMPH_CLOCK
#define AUX_WUC_SMPH_CLOCK
Definition: aux_wuc.h:103
AUX_WUC_REF_CLOCK
#define AUX_WUC_REF_CLOCK
Definition: aux_wuc.h:115
AUX_WUC_TDCIF_CLOCK
#define AUX_WUC_TDCIF_CLOCK
Definition: aux_wuc.h:108
AUX_WUC_MODCLK_MASK
#define AUX_WUC_MODCLK_MASK
Definition: aux_wuc.h:111
AUX_WUC_POWER_ACTIVE
#define AUX_WUC_POWER_ACTIVE
Definition: aux_wuc.h:96
AUX_WUC_ADC_CLOCK
#define AUX_WUC_ADC_CLOCK
Definition: aux_wuc.h:114
aux_wuc.h
AUX_WUC_CLOCK_OFF
#define AUX_WUC_CLOCK_OFF
Definition: aux_wuc.h:117
AUX_WUC_TIMER_CLOCK
#define AUX_WUC_TIMER_CLOCK
Definition: aux_wuc.h:106