CC13xx Driver Library
aon_event.c
Go to the documentation of this file.
1 /******************************************************************************
2 * Filename: aon_event.c
3 * Revised: 2015-06-09 12:16:53 +0200 (Tue, 09 Jun 2015)
4 * Revision: 43826
5 *
6 * Description: Driver for the AON Event fabric.
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/aon_event.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 AONEventMcuWakeUpSet
49  #define AONEventMcuWakeUpSet NOROM_AONEventMcuWakeUpSet
50  #undef AONEventMcuWakeUpGet
51  #define AONEventMcuWakeUpGet NOROM_AONEventMcuWakeUpGet
52  #undef AONEventAuxWakeUpSet
53  #define AONEventAuxWakeUpSet NOROM_AONEventAuxWakeUpSet
54  #undef AONEventAuxWakeUpGet
55  #define AONEventAuxWakeUpGet NOROM_AONEventAuxWakeUpGet
56  #undef AONEventMcuSet
57  #define AONEventMcuSet NOROM_AONEventMcuSet
58  #undef AONEventMcuGet
59  #define AONEventMcuGet NOROM_AONEventMcuGet
60 #endif
61 
62 //*****************************************************************************
63 //
65 //
66 //*****************************************************************************
67 void
68 AONEventMcuWakeUpSet(uint32_t ui32MCUWUEvent, uint32_t ui32EventSrc)
69 {
70  uint32_t ui32Ctrl;
71 
72  //
73  // Check the arguments.
74  //
75  ASSERT((ui32MCUWUEvent == AON_EVENT_MCU_WU0) ||
76  (ui32MCUWUEvent == AON_EVENT_MCU_WU1) ||
77  (ui32MCUWUEvent == AON_EVENT_MCU_WU2) ||
78  (ui32MCUWUEvent == AON_EVENT_MCU_WU3));
79  ASSERT(ui32EventSrc <= AON_EVENT_NONE);
80 
81  ui32Ctrl = HWREG(AON_EVENT_BASE + AON_EVENT_O_MCUWUSEL);
82 
83  if(ui32MCUWUEvent == AON_EVENT_MCU_WU0)
84  {
85  ui32Ctrl &= ~(AON_EVENT_MCUWUSEL_WU0_EV_M);
86  ui32Ctrl |= (ui32EventSrc & 0x3f) << AON_EVENT_MCUWUSEL_WU0_EV_S;
87  }
88  else if(ui32MCUWUEvent == AON_EVENT_MCU_WU1)
89  {
90  ui32Ctrl &= ~(AON_EVENT_MCUWUSEL_WU1_EV_M);
91  ui32Ctrl |= (ui32EventSrc & 0x3f) << AON_EVENT_MCUWUSEL_WU1_EV_S;
92  }
93  else if(ui32MCUWUEvent == AON_EVENT_MCU_WU2)
94  {
95  ui32Ctrl &= ~(AON_EVENT_MCUWUSEL_WU2_EV_M);
96  ui32Ctrl |= (ui32EventSrc & 0x3f) << AON_EVENT_MCUWUSEL_WU2_EV_S;
97  }
98  else if(ui32MCUWUEvent == AON_EVENT_MCU_WU3)
99  {
100  ui32Ctrl &= ~(AON_EVENT_MCUWUSEL_WU3_EV_M);
101  ui32Ctrl |= (ui32EventSrc & 0x3f) << AON_EVENT_MCUWUSEL_WU3_EV_S;
102  }
103 
104  HWREG(AON_EVENT_BASE + AON_EVENT_O_MCUWUSEL) = ui32Ctrl;
105 }
106 
107 //*****************************************************************************
108 //
110 //
111 //*****************************************************************************
112 uint32_t
113 AONEventMcuWakeUpGet(uint32_t ui32MCUWUEvent)
114 {
115  uint32_t ui32EventSrc;
116 
117  //
118  // Check the arguments.
119  //
120  ASSERT((ui32MCUWUEvent == AON_EVENT_MCU_WU0) ||
121  (ui32MCUWUEvent == AON_EVENT_MCU_WU1) ||
122  (ui32MCUWUEvent == AON_EVENT_MCU_WU2) ||
123  (ui32MCUWUEvent == AON_EVENT_MCU_WU3));
124 
125  ui32EventSrc = HWREG(AON_EVENT_BASE + AON_EVENT_O_MCUWUSEL);
126 
127  if(ui32MCUWUEvent == AON_EVENT_MCU_WU0)
128  {
129  return((ui32EventSrc & AON_EVENT_MCUWUSEL_WU0_EV_M) >>
131  }
132  else if(ui32MCUWUEvent == AON_EVENT_MCU_WU1)
133  {
134  return((ui32EventSrc & AON_EVENT_MCUWUSEL_WU1_EV_M) >>
136  }
137  else if(ui32MCUWUEvent == AON_EVENT_MCU_WU2)
138  {
139  return((ui32EventSrc & AON_EVENT_MCUWUSEL_WU2_EV_M) >>
141  }
142  else if(ui32MCUWUEvent == AON_EVENT_MCU_WU3)
143  {
144  return((ui32EventSrc & AON_EVENT_MCUWUSEL_WU3_EV_M) >>
146  }
147 
148  //
149  // Should never get to this statement, but suppress warning.
150  //
151  ASSERT(0);
152  return(0);
153 }
154 
155 //*****************************************************************************
156 //
158 //
159 //*****************************************************************************
160 void
161 AONEventAuxWakeUpSet(uint32_t ui32AUXWUEvent, uint32_t ui32EventSrc)
162 {
163  uint32_t ui32Ctrl;
164 
165  //
166  // Check the arguments.
167  //
168  ASSERT((ui32AUXWUEvent == AON_EVENT_AUX_WU0) ||
169  (ui32AUXWUEvent == AON_EVENT_AUX_WU1) ||
170  (ui32AUXWUEvent == AON_EVENT_AUX_WU2));
171  ASSERT(ui32EventSrc <= AON_EVENT_NONE);
172 
173  ui32Ctrl = HWREG(AON_EVENT_BASE + AON_EVENT_O_AUXWUSEL);
174 
175  if(ui32AUXWUEvent == AON_EVENT_AUX_WU0)
176  {
177  ui32Ctrl &= ~(AON_EVENT_AUXWUSEL_WU0_EV_M);
178  ui32Ctrl |= (ui32EventSrc & 0x3f) << AON_EVENT_AUXWUSEL_WU0_EV_S;
179  }
180  else if(ui32AUXWUEvent == AON_EVENT_AUX_WU1)
181  {
182  ui32Ctrl &= ~(AON_EVENT_AUXWUSEL_WU1_EV_M);
183  ui32Ctrl |= (ui32EventSrc & 0x3f) << AON_EVENT_AUXWUSEL_WU1_EV_S;
184  }
185  else if(ui32AUXWUEvent == AON_EVENT_AUX_WU2)
186  {
187  ui32Ctrl &= ~(AON_EVENT_AUXWUSEL_WU2_EV_M);
188  ui32Ctrl |= (ui32EventSrc & 0x3f) << AON_EVENT_AUXWUSEL_WU2_EV_S;
189  }
190 
191  HWREG(AON_EVENT_BASE + AON_EVENT_O_AUXWUSEL) = ui32Ctrl;
192 }
193 
194 //*****************************************************************************
195 //
197 //
198 //*****************************************************************************
199 uint32_t
200 AONEventAuxWakeUpGet(uint32_t ui32AUXWUEvent)
201 {
202  uint32_t ui32EventSrc;
203 
204  //
205  // Check the arguments.
206  //
207  ASSERT((ui32AUXWUEvent == AON_EVENT_AUX_WU0) ||
208  (ui32AUXWUEvent == AON_EVENT_AUX_WU1) ||
209  (ui32AUXWUEvent == AON_EVENT_AUX_WU2));
210 
211  ui32EventSrc = HWREG(AON_EVENT_BASE + AON_EVENT_O_AUXWUSEL);
212 
213  if(ui32AUXWUEvent == AON_EVENT_AUX_WU0)
214  {
215  return((ui32EventSrc & AON_EVENT_AUXWUSEL_WU0_EV_M) >>
217  }
218  else if(ui32AUXWUEvent == AON_EVENT_AUX_WU1)
219  {
220  return((ui32EventSrc & AON_EVENT_AUXWUSEL_WU1_EV_M) >>
222  }
223  else if(ui32AUXWUEvent == AON_EVENT_AUX_WU2)
224  {
225  return((ui32EventSrc & AON_EVENT_AUXWUSEL_WU2_EV_M) >>
227  }
228 
229  //
230  // Should never get to this statement, but suppress warning.
231  //
232  ASSERT(0);
233  return(0);
234 }
235 
236 //*****************************************************************************
237 //
240 //
241 //*****************************************************************************
242 void
243 AONEventMcuSet(uint32_t ui32MCUEvent, uint32_t ui32EventSrc)
244 {
245  uint32_t ui32Ctrl;
246 
247  //
248  // Check the arguments.
249  //
250  ASSERT((ui32MCUEvent == AON_EVENT_MCU_EVENT0) ||
251  (ui32MCUEvent == AON_EVENT_MCU_EVENT1) ||
252  (ui32MCUEvent == AON_EVENT_MCU_EVENT2));
253  ASSERT(ui32EventSrc <= AON_EVENT_NONE);
254 
255  ui32Ctrl = HWREG(AON_EVENT_BASE + AON_EVENT_O_EVTOMCUSEL);
256 
257  if(ui32MCUEvent == AON_EVENT_MCU_EVENT0)
258  {
260  ui32Ctrl |= (ui32EventSrc & 0x3f) << AON_EVENT_EVTOMCUSEL_AON_PROG0_EV_S;
261  }
262  else if(ui32MCUEvent == AON_EVENT_MCU_EVENT1)
263  {
265  ui32Ctrl |= (ui32EventSrc & 0x3f) << AON_EVENT_EVTOMCUSEL_AON_PROG1_EV_S;
266  }
267  else if(ui32MCUEvent == AON_EVENT_MCU_EVENT2)
268  {
270  ui32Ctrl |= (ui32EventSrc & 0x3f) << AON_EVENT_EVTOMCUSEL_AON_PROG2_EV_S;
271  }
272 
273  HWREG(AON_EVENT_BASE + AON_EVENT_O_EVTOMCUSEL) = ui32Ctrl;
274 }
275 
276 //*****************************************************************************
277 //
280 //
281 //*****************************************************************************
282 uint32_t
283 AONEventMcuGet(uint32_t ui32MCUEvent)
284 {
285  uint32_t ui32EventSrc;
286 
287  //
288  // Check the arguments.
289  //
290  ASSERT((ui32MCUEvent == AON_EVENT_MCU_EVENT0) ||
291  (ui32MCUEvent == AON_EVENT_MCU_EVENT1) ||
292  (ui32MCUEvent == AON_EVENT_MCU_EVENT2));
293 
294  ui32EventSrc = HWREG(AON_EVENT_BASE + AON_EVENT_O_EVTOMCUSEL);
295 
296  if(ui32MCUEvent == AON_EVENT_MCU_EVENT0)
297  {
298  return((ui32EventSrc & AON_EVENT_EVTOMCUSEL_AON_PROG0_EV_M) >>
300  }
301  else if(ui32MCUEvent == AON_EVENT_MCU_EVENT1)
302  {
303  return((ui32EventSrc & AON_EVENT_EVTOMCUSEL_AON_PROG1_EV_M) >>
305  }
306  else if(ui32MCUEvent == AON_EVENT_MCU_EVENT2)
307  {
308  return((ui32EventSrc & AON_EVENT_EVTOMCUSEL_AON_PROG2_EV_M) >>
310  }
311 
312  //
313  // Should never get to this statement, but suppress warning.
314  //
315  ASSERT(0);
316  return(0);
317 }
#define AON_EVENT_AUX_WU2
Definition: aon_event.h:152
#define AON_EVENT_MCU_WU3
Definition: aon_event.h:143
#define AON_EVENT_MCU_WU0
Definition: aon_event.h:140
#define AON_EVENT_AUX_WU1
Definition: aon_event.h:151
#define AON_EVENT_NONE
Definition: aon_event.h:127
void AONEventMcuWakeUpSet(uint32_t ui32MCUWUEvent, uint32_t ui32EventSrc)
Select event source for the specified MCU wakeup programmable event.
Definition: aon_event.c:68
#define AON_EVENT_AUX_WU0
Definition: aon_event.h:150
uint32_t AONEventAuxWakeUpGet(uint32_t ui32AUXWUEvent)
Get event source for the specified AUX wakeup programmable event.
Definition: aon_event.c:200
#define AON_EVENT_MCU_EVENT2
Definition: aon_event.h:161
void AONEventAuxWakeUpSet(uint32_t ui32AUXWUEvent, uint32_t ui32EventSrc)
Select event source for the specified AUX wakeup programmable event.
Definition: aon_event.c:161
void AONEventMcuSet(uint32_t ui32MCUEvent, uint32_t ui32EventSrc)
Select event source for the specified programmable event forwarded to the MCU event fabric...
Definition: aon_event.c:243
#define AON_EVENT_MCU_EVENT0
Definition: aon_event.h:159
#define ASSERT(expr)
Definition: debug.h:74
#define AON_EVENT_MCU_EVENT1
Definition: aon_event.h:160
uint32_t AONEventMcuWakeUpGet(uint32_t ui32MCUWUEvent)
Get event source for the specified MCU wakeup programmable event.
Definition: aon_event.c:113
#define AON_EVENT_MCU_WU1
Definition: aon_event.h:141
#define AON_EVENT_MCU_WU2
Definition: aon_event.h:142
uint32_t AONEventMcuGet(uint32_t ui32MCUEvent)
Get source for the specified programmable event forwarded to the MCU event fabric.
Definition: aon_event.c:283