CC26xx Driver Library
aux_wuc.c
Go to the documentation of this file.
1 /******************************************************************************
2 * Filename: aux_wuc.c
3 * Revised: 2016-07-07 19:12:02 +0200 (Thu, 07 Jul 2016)
4 * Revision: 46848
5 *
6 * Description: Driver for the AUX Wakeup Controller.
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 #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 #if !defined(DOXYGEN)
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_ANAIF_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 &
86 
87  //
88  // Check the rest.
89  //
90  if(ui32Clocks & AUX_WUC_ADC_CLOCK)
91  {
94  }
95  if(ui32Clocks & AUX_WUC_TDC_CLOCK)
96  {
99  }
100  if(ui32Clocks & AUX_WUC_REF_CLOCK)
101  {
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_ANAIF_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 &
135 
136  //
137  // Check the rest.
138  //
139  if(ui32Clocks & AUX_WUC_ADC_CLOCK)
140  {
143  }
144  if(ui32Clocks & AUX_WUC_TDC_CLOCK)
145  {
148  }
149  if(ui32Clocks & AUX_WUC_REF_CLOCK)
150  {
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_ANAIF_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 &
196  true : false);
197  }
198  if(ui32Clocks & AUX_WUC_OSCCTRL_CLOCK)
199  {
200  bClockStatus = bClockStatus && (ui32ClockRegister &
202  true : false);
203  }
204  if(ui32Clocks & AUX_WUC_TDCIF_CLOCK)
205  {
206  bClockStatus = bClockStatus && (ui32ClockRegister &
208  true : false);
209  }
210  if(ui32Clocks & AUX_WUC_ANAIF_CLOCK)
211  {
212  bClockStatus = bClockStatus && (ui32ClockRegister &
214  true : false);
215  }
216  if(ui32Clocks & AUX_WUC_TIMER_CLOCK)
217  {
218  bClockStatus = bClockStatus && (ui32ClockRegister &
220  true : false);
221  }
222  if(ui32Clocks & AUX_WUC_AIODIO0_CLOCK)
223  {
224  bClockStatus = bClockStatus && (ui32ClockRegister &
226  true : false);
227  }
228  if(ui32Clocks & AUX_WUC_AIODIO1_CLOCK)
229  {
230  bClockStatus = bClockStatus && (ui32ClockRegister &
232  true : false);
233  }
234  if(ui32Clocks & AUX_WUC_SMPH_CLOCK)
235  {
236  bClockStatus = bClockStatus && (ui32ClockRegister &
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 &
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 &
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 &
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  {
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  {
305  }
306  else
307  {
308  HWREG(AUX_WUC_BASE + AUX_WUC_O_PWRDWNREQ) = 0x0;
309  }
310 }
#define AUX_WUC_TDC_CLOCK
Definition: aux_wuc.h:113
void AUXWUCClockEnable(uint32_t ui32Clocks)
Enable clocks for peripherals in the AUX domain.
Definition: aux_wuc.c:64
#define AUX_WUC_POWER_DOWN
Definition: aux_wuc.h:95
#define AUX_WUC_OSCCTRL_CLOCK
Definition: aux_wuc.h:109
void AUXWUCPowerCtrl(uint32_t ui32PowerMode)
Control the power to the AUX domain.
Definition: aux_wuc.c:274
uint32_t AUXWUCClockStatus(uint32_t ui32Clocks)
Get the status of a clock.
Definition: aux_wuc.c:162
#define AUX_WUC_CLOCK_READY
Definition: aux_wuc.h:119
void AUXWUCClockDisable(uint32_t ui32Clocks)
Disable clocks for peripherals in the AUX domain.
Definition: aux_wuc.c:113
#define AUX_WUC_POWER_OFF
Definition: aux_wuc.h:94
#define AUX_WUC_AIODIO0_CLOCK
Definition: aux_wuc.h:104
#define AUX_WUC_ADI_CLOCK
Definition: aux_wuc.h:110
#define AUX_WUC_AIODIO1_CLOCK
Definition: aux_wuc.h:105
#define AUX_WUC_SMPH_CLOCK
Definition: aux_wuc.h:103
#define ASSERT(expr)
Definition: debug.h:74
#define AUX_WUC_REF_CLOCK
Definition: aux_wuc.h:115
#define AUX_WUC_TDCIF_CLOCK
Definition: aux_wuc.h:108
#define AUX_WUC_MODCLK_MASK
Definition: aux_wuc.h:111
#define AUX_WUC_ANAIF_CLOCK
Definition: aux_wuc.h:107
#define AUX_WUC_POWER_ACTIVE
Definition: aux_wuc.h:96
#define AUX_WUC_ADC_CLOCK
Definition: aux_wuc.h:114
#define AUX_WUC_CLOCK_OFF
Definition: aux_wuc.h:117
#define AUX_WUC_TIMER_CLOCK
Definition: aux_wuc.h:106