Fix USB Host mode compile errors for the UC3B architecture.
[pub/USBasp.git] / LUFA / Drivers / USB / Core / UC3B / USBInterrupt_UC3B.h
1 /*
2 LUFA Library
3 Copyright (C) Dean Camera, 2011.
4
5 dean [at] fourwalledcubicle [dot] com
6 www.lufa-lib.org
7 */
8
9 /*
10 Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
11
12 Permission to use, copy, modify, distribute, and sell this
13 software and its documentation for any purpose is hereby granted
14 without fee, provided that the above copyright notice appear in
15 all copies and that both that the copyright notice and this
16 permission notice and warranty disclaimer appear in supporting
17 documentation, and that the name of the author not be used in
18 advertising or publicity pertaining to distribution of the
19 software without specific, written prior permission.
20
21 The author disclaim all warranties with regard to this
22 software, including all implied warranties of merchantability
23 and fitness. In no event shall the author be liable for any
24 special, indirect or consequential damages or any damages
25 whatsoever resulting from loss of use, data or profits, whether
26 in an action of contract, negligence or other tortious action,
27 arising out of or in connection with the use or performance of
28 this software.
29 */
30
31 /** \file
32 * \brief USB Controller Interrupt definitions for the AVR32 UC3B microcontrollers.
33 *
34 * This file contains definitions required for the correct handling of low level USB service routine interrupts
35 * from the USB controller.
36 *
37 * \note This file should not be included directly. It is automatically included as needed by the USB driver
38 * dispatch header located in LUFA/Drivers/USB/USB.h.
39 */
40
41 #ifndef __USBINTERRUPT_UC3B_H__
42 #define __USBINTERRUPT_UC3B_H__
43
44 /* Includes: */
45 #include "../../../../Common/Common.h"
46
47 /* Enable C linkage for C++ Compilers: */
48 #if defined(__cplusplus)
49 extern "C" {
50 #endif
51
52 /* Preprocessor Checks: */
53 #if !defined(__INCLUDE_FROM_USB_DRIVER)
54 #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
55 #endif
56
57 /* Private Interface - For use in library only: */
58 #if !defined(__DOXYGEN__)
59 /* Macros: */
60 enum USB_Interrupts_t
61 {
62 USB_INT_VBUS = 0,
63 USB_INT_IDTI = 1,
64 USB_INT_WAKEUPI = 2,
65 USB_INT_SUSPI = 3,
66 USB_INT_EORSTI = 4,
67 USB_INT_DCONNI = 5,
68 USB_INT_DDISCI = 6,
69 USB_INT_BCERRI = 7,
70 USB_INT_VBERRI = 8,
71 USB_INT_SOFI = 9,
72 USB_INT_HSOFI = 10,
73 USB_INT_RSTI = 11,
74 USB_INT_SRPI = 12,
75 USB_INT_RXSTPI = 13,
76 };
77
78 static inline void USB_INT_Enable(const uint8_t Interrupt) ATTR_ALWAYS_INLINE;
79 static inline void USB_INT_Enable(const uint8_t Interrupt)
80 {
81 switch (Interrupt)
82 {
83 case USB_INT_VBUS:
84 AVR32_USBB.USBCON.vbuste = true;
85 break;
86 case USB_INT_IDTI:
87 AVR32_USBB.USBCON.idte = true;
88 break;
89 case USB_INT_WAKEUPI:
90 AVR32_USBB.UDINTESET.wakeupes = true;
91 break;
92 case USB_INT_SUSPI:
93 AVR32_USBB.UDINTESET.suspes = true;
94 break;
95 case USB_INT_EORSTI:
96 AVR32_USBB.UDINTESET.eorstes = true;
97 break;
98 case USB_INT_DCONNI:
99 AVR32_USBB.UHINTESET.dconnies = true;
100 break;
101 case USB_INT_DDISCI:
102 AVR32_USBB.UHINTESET.ddiscies = true;
103 break;
104 case USB_INT_BCERRI:
105 AVR32_USBB.USBCON.bcerre = true;
106 break;
107 case USB_INT_VBERRI:
108 AVR32_USBB.USBCON.vberre = true;
109 break;
110 case USB_INT_SOFI:
111 AVR32_USBB.UDINTESET.sofes = true;
112 break;
113 case USB_INT_HSOFI:
114 AVR32_USBB.UHINTESET.hsofies = true;
115 break;
116 case USB_INT_RSTI:
117 AVR32_USBB.UHINTESET.rsties = true;
118 break;
119 case USB_INT_SRPI:
120 case USB_INT_RXSTPI:
121 // TODO
122 return;
123 }
124 }
125
126 static inline void USB_INT_Disable(const uint8_t Interrupt) ATTR_ALWAYS_INLINE;
127 static inline void USB_INT_Disable(const uint8_t Interrupt)
128 {
129 switch (Interrupt)
130 {
131 case USB_INT_VBUS:
132 AVR32_USBB.USBCON.vbuste = false;
133 break;
134 case USB_INT_IDTI:
135 AVR32_USBB.USBCON.idte = false;
136 break;
137 case USB_INT_WAKEUPI:
138 AVR32_USBB.UDINTECLR.wakeupec = true;
139 break;
140 case USB_INT_SUSPI:
141 AVR32_USBB.UDINTECLR.suspec = true;
142 break;
143 case USB_INT_EORSTI:
144 AVR32_USBB.UDINTECLR.eorstec = true;
145 break;
146 case USB_INT_DCONNI:
147 AVR32_USBB.UHINTECLR.dconniec = true;
148 break;
149 case USB_INT_DDISCI:
150 AVR32_USBB.UHINTECLR.ddisciec = true;
151 break;
152 case USB_INT_BCERRI:
153 AVR32_USBB.USBCON.bcerre = false;
154 break;
155 case USB_INT_VBERRI:
156 AVR32_USBB.USBCON.vberre = false;
157 break;
158 case USB_INT_SOFI:
159 AVR32_USBB.UDINTECLR.sofec = true;
160 break;
161 case USB_INT_HSOFI:
162 AVR32_USBB.UHINTECLR.hsofiec = true;
163 break;
164 case USB_INT_RSTI:
165 AVR32_USBB.UHINTECLR.rstiec = true;
166 break;
167 case USB_INT_SRPI:
168 case USB_INT_RXSTPI:
169 // TODO
170 return;
171 }
172 }
173
174 static inline void USB_INT_Clear(const uint8_t Interrupt) ATTR_ALWAYS_INLINE;
175 static inline void USB_INT_Clear(const uint8_t Interrupt)
176 {
177 switch (Interrupt)
178 {
179 case USB_INT_VBUS:
180 AVR32_USBB.USBSTACLR.vbustic = true;
181 break;
182 case USB_INT_IDTI:
183 AVR32_USBB.USBSTACLR.idtic = true;
184 break;
185 case USB_INT_WAKEUPI:
186 AVR32_USBB.UDINTCLR.wakeupc = true;
187 break;
188 case USB_INT_SUSPI:
189 AVR32_USBB.UDINTCLR.suspc = true;
190 break;
191 case USB_INT_EORSTI:
192 AVR32_USBB.UDINTCLR.eorstc = true;
193 break;
194 case USB_INT_DCONNI:
195 AVR32_USBB.UHINTCLR.dconnic = true;
196 break;
197 case USB_INT_DDISCI:
198 AVR32_USBB.UHINTCLR.ddiscic = true;
199 break;
200 case USB_INT_BCERRI:
201 AVR32_USBB.USBSTACLR.bcerric = true;
202 break;
203 case USB_INT_VBERRI:
204 AVR32_USBB.USBSTACLR.vberric = true;
205 break;
206 case USB_INT_SOFI:
207 AVR32_USBB.UDINTCLR.sofc = true;
208 break;
209 case USB_INT_HSOFI:
210 AVR32_USBB.UHINTCLR.hsofic = true;
211 break;
212 case USB_INT_RSTI:
213 AVR32_USBB.UHINTCLR.rstic = true;
214 break;
215 case USB_INT_SRPI:
216 case USB_INT_RXSTPI:
217 // TODO
218 return;
219 }
220 }
221
222 static inline bool USB_INT_IsEnabled(const uint8_t Interrupt) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;
223 static inline bool USB_INT_IsEnabled(const uint8_t Interrupt)
224 {
225 switch (Interrupt)
226 {
227 case USB_INT_VBUS:
228 return AVR32_USBB.USBCON.vbuste;
229 case USB_INT_IDTI:
230 return AVR32_USBB.USBCON.idte;
231 case USB_INT_WAKEUPI:
232 return AVR32_USBB.UDINTE.wakeupe;
233 case USB_INT_SUSPI:
234 return AVR32_USBB.UDINTE.suspe;
235 case USB_INT_EORSTI:
236 return AVR32_USBB.UDINTE.eorste;
237 case USB_INT_DCONNI:
238 return AVR32_USBB.UHINTE.dconnie;
239 case USB_INT_DDISCI:
240 return AVR32_USBB.UHINTE.ddiscie;
241 case USB_INT_BCERRI:
242 return AVR32_USBB.USBCON.bcerre;
243 case USB_INT_VBERRI:
244 return AVR32_USBB.USBCON.vberre;
245 case USB_INT_SOFI:
246 return AVR32_USBB.UDINTE.sofe;
247 case USB_INT_HSOFI:
248 return AVR32_USBB.UHINTE.hsofie;
249 case USB_INT_RSTI:
250 return AVR32_USBB.UHINTE.rstie;
251 case USB_INT_SRPI:
252 case USB_INT_RXSTPI:
253 // TODO
254 return false;
255 }
256
257 return false;
258 }
259
260 static inline bool USB_INT_HasOccurred(const uint8_t Interrupt) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;
261 static inline bool USB_INT_HasOccurred(const uint8_t Interrupt)
262 {
263 switch (Interrupt)
264 {
265 case USB_INT_VBUS:
266 return AVR32_USBB.USBSTA.vbusti;
267 case USB_INT_IDTI:
268 return AVR32_USBB.USBSTA.idti;
269 case USB_INT_WAKEUPI:
270 return AVR32_USBB.UDINT.wakeup;
271 case USB_INT_SUSPI:
272 return AVR32_USBB.UDINT.susp;
273 case USB_INT_EORSTI:
274 return AVR32_USBB.UDINT.eorst;
275 case USB_INT_DCONNI:
276 return AVR32_USBB.UHINT.dconni;
277 case USB_INT_DDISCI:
278 return AVR32_USBB.UHINT.ddisci;
279 case USB_INT_BCERRI:
280 return AVR32_USBB.USBSTA.bcerri;
281 case USB_INT_VBERRI:
282 return AVR32_USBB.USBSTA.vberri;
283 case USB_INT_SOFI:
284 return AVR32_USBB.UDINT.sof;
285 case USB_INT_HSOFI:
286 return AVR32_USBB.UHINT.hsofi;
287 case USB_INT_RSTI:
288 return AVR32_USBB.UHINT.rsti;
289 case USB_INT_SRPI:
290 case USB_INT_RXSTPI:
291 // TODO
292 return false;
293 }
294
295 return false;
296 }
297
298 /* Includes: */
299 #include "../USBMode.h"
300 #include "../Events.h"
301 #include "../USBController.h"
302
303 /* Function Prototypes: */
304 void USB_INT_ClearAllInterrupts(void);
305 void USB_INT_DisableAllInterrupts(void);
306 #endif
307
308 /* Disable C linkage for C++ Compilers: */
309 #if defined(__cplusplus)
310 }
311 #endif
312
313 #endif
314