]> git.gir.st - tmk_keyboard.git/blob - protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/USBMode.h
Squashed 'tmk_core/' changes from caca2c0..dc0e46e
[tmk_keyboard.git] / protocol / lufa / LUFA-git / LUFA / Drivers / USB / Core / USBMode.h
1 /*
2 LUFA Library
3 Copyright (C) Dean Camera, 2014.
4
5 dean [at] fourwalledcubicle [dot] com
6 www.lufa-lib.org
7 */
8
9 /*
10 Copyright 2014 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 disclaims 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 mode and feature support definitions.
33 * \copydetails Group_USBMode
34 *
35 * \note This file should not be included directly. It is automatically included as needed by the USB driver
36 * dispatch header located in LUFA/Drivers/USB/USB.h.
37 */
38
39 /** \ingroup Group_USB
40 * \defgroup Group_USBMode USB Mode Tokens
41 * \brief USB mode and feature support definitions.
42 *
43 * This file defines macros indicating the type of USB controller the library is being compiled for, and its
44 * capabilities. These macros may then be referenced in the user application to selectively enable or disable
45 * code sections depending on if they are defined or not.
46 *
47 * After the inclusion of the master USB driver header, one or more of the following tokens may be defined, to
48 * allow the user code to conditionally enable or disable code based on the USB controller family and allowable
49 * USB modes. These tokens may be tested against to eliminate code relating to a USB mode which is not enabled for
50 * the given compilation.
51 *
52 * @{
53 */
54
55 #ifndef __USBMODE_H__
56 #define __USBMODE_H__
57
58 /* Enable C linkage for C++ Compilers: */
59 #if defined(__cplusplus)
60 extern "C" {
61 #endif
62
63 /* Preprocessor Checks: */
64 #if !defined(__INCLUDE_FROM_USB_DRIVER)
65 #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
66 #endif
67
68 /* Includes: */
69 #include "../../../Common/Common.h"
70
71 /* Public Interface - May be used in end-application: */
72 #if defined(__DOXYGEN__)
73 /** Indicates that the target AVR microcontroller belongs to the Series 2 AVR8 USB controller
74 * (i.e. AT90USBxxx2 or ATMEGAxxU2) when defined.
75 */
76 #define USB_SERIES_2_AVR
77
78 /** Indicates that the target AVR microcontroller belongs to the Series 4 AVR8 USB controller
79 * (i.e. ATMEGAxxU4) when defined.
80 */
81 #define USB_SERIES_4_AVR
82
83 /** Indicates that the target AVR microcontroller belongs to the Series 6 AVR8 USB controller
84 * (i.e. AT90USBxxx6) when defined.
85 */
86 #define USB_SERIES_6_AVR
87
88 /** Indicates that the target AVR microcontroller belongs to the Series 7 AVR8 USB controller
89 * (i.e. AT90USBxxx7) when defined.
90 */
91 #define USB_SERIES_7_AVR
92
93 /** Indicates that the target AVR microcontroller belongs to the AVR32 UC3A0 Series USB controller
94 * (i.e. AT32UC3A0*) when defined.
95 */
96 #define USB_SERIES_UC3A0_AVR
97
98 /** Indicates that the target AVR microcontroller belongs to the AVR32 UC3A1 Series USB controller
99 * (i.e. AT32UC3A1*) when defined.
100 */
101 #define USB_SERIES_UC3A1_AVR
102
103 /** Indicates that the target AVR microcontroller belongs to the AVR32 UC3A3 Series USB controller
104 * (i.e. AT32UC3A3*) when defined.
105 */
106 #define USB_SERIES_UC3A3_AVR
107
108 /** Indicates that the target AVR microcontroller belongs to the AVR32 UC3A4 Series USB controller
109 * (i.e. AT32UC3A4*) when defined.
110 */
111 #define USB_SERIES_UC3A4_AVR
112
113 /** Indicates that the target AVR microcontroller belongs to the AVR32 UC3B0 Series USB controller
114 * (i.e. AT32UC3B0*) when defined.
115 */
116 #define USB_SERIES_UC3B0_AVR
117
118 /** Indicates that the target AVR microcontroller belongs to the AVR32 UC3B1 Series USB controller
119 * (i.e. AT32UC3B1*) when defined.
120 */
121 #define USB_SERIES_UC3B1_AVR
122
123 /** Indicates that the target AVR microcontroller belongs to the XMEGA A1U Series USB controller
124 * (i.e. ATXMEGA*A1U) when defined.
125 */
126 #define USB_SERIES_A1U_XMEGA
127
128 /** Indicates that the target AVR microcontroller belongs to the XMEGA A3U Series USB controller
129 * (i.e. ATXMEGA*A3U) when defined.
130 */
131 #define USB_SERIES_A3U_XMEGA
132
133 /** Indicates that the target AVR microcontroller belongs to the XMEGA A4U Series USB controller
134 * (i.e. ATXMEGA*A4U) when defined.
135 */
136 #define USB_SERIES_A4U_XMEGA
137
138 /** Indicates that the target AVR microcontroller belongs to the XMEGA B1 Series USB controller
139 * (i.e. ATXMEGA*B1) when defined.
140 */
141 #define USB_SERIES_B1_XMEGA
142
143 /** Indicates that the target AVR microcontroller belongs to the XMEGA B3 Series USB controller
144 * (i.e. ATXMEGA*B3) when defined.
145 */
146 #define USB_SERIES_B3_XMEGA
147
148 /** Indicates that the target AVR microcontroller belongs to the XMEGA C3 Series USB controller
149 * (i.e. ATXMEGA*C3) when defined.
150 */
151 #define USB_SERIES_C3_XMEGA
152
153 /** Indicates that the target AVR microcontroller belongs to the XMEGA C4 Series USB controller
154 * (i.e. ATXMEGA*C4) when defined.
155 */
156 #define USB_SERIES_C4_XMEGA
157
158 /** Indicates that the target microcontroller and compilation settings allow for the
159 * target to be configured in USB Device mode when defined.
160 */
161 #define USB_CAN_BE_DEVICE
162
163 /** Indicates that the target microcontroller and compilation settings allow for the
164 * target to be configured in USB Host mode when defined.
165 */
166 #define USB_CAN_BE_HOST
167
168 /** Indicates that the target microcontroller and compilation settings allow for the
169 * target to be configured in either USB Device or Host mode when defined.
170 */
171 #define USB_CAN_BE_BOTH
172 #else
173 /* Macros: */
174 #if (defined(__AVR_AT90USB162__) || defined(__AVR_AT90USB82__) || \
175 defined(__AVR_ATmega32U2__) || defined(__AVR_ATmega16U2__) || defined(__AVR_ATmega8U2__))
176 #define USB_SERIES_2_AVR
177 #define USB_CAN_BE_DEVICE
178 #elif (defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega16U4__))
179 #define USB_SERIES_4_AVR
180 #define USB_CAN_BE_DEVICE
181 #elif (defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__))
182 #define USB_SERIES_6_AVR
183 #define USB_CAN_BE_DEVICE
184 #elif (defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1287__))
185 #define USB_SERIES_7_AVR
186 #define USB_CAN_BE_DEVICE
187 #define USB_CAN_BE_HOST
188 #elif (defined(__AVR32_UC3A0512__) || defined(__AVR32_UC3A0256__) || \
189 defined(__AVR32_UC3A0128__) || defined(__AVR32_UC3A064__))
190 #define USB_SERIES_UC3A0_AVR32
191 #define USB_CAN_BE_DEVICE
192 #define USB_CAN_BE_HOST
193 #elif (defined(__AVR32_UC3A1512__) || defined(__AVR32_UC3A1256__) || \
194 defined(__AVR32_UC3A1128__) || defined(__AVR32_UC3A164__))
195 #define USB_SERIES_UC3A1_AVR32
196 #define USB_CAN_BE_DEVICE
197 #define USB_CAN_BE_HOST
198 #elif (defined(__AVR32_UC3A3256__) || defined(__AVR32_UC3A3256S__) || \
199 defined(__AVR32_UC3A3128__) || defined(__AVR32_UC3A3128S__) || \
200 defined(__AVR32_UC3A364__) || defined(__AVR32_UC3A364S__))
201 #define USB_SERIES_UC3A3_AVR32
202 #define USB_CAN_BE_DEVICE
203 #define USB_CAN_BE_HOST
204 #elif (defined(__AVR32_UC3A4256__) || defined(__AVR32_UC3A4256S__) || \
205 defined(__AVR32_UC3A4128__) || defined(__AVR32_UC3A4128S__) || \
206 defined(__AVR32_UC3A464__) || defined(__AVR32_UC3A464S__))
207 #define USB_SERIES_UC3A4_AVR32
208 #define USB_CAN_BE_DEVICE
209 #define USB_CAN_BE_HOST
210 #elif (defined(__AVR32_UC3B0512__) || defined(__AVR32_UC3B0256__) || \
211 defined(__AVR32_UC3B0128__) || defined(__AVR32_UC3B064__))
212 #define USB_SERIES_UC3B0_AVR32
213 #define USB_CAN_BE_DEVICE
214 #define USB_CAN_BE_HOST
215 #elif (defined(__AVR32_UC3B1512__) || defined(__AVR32_UC3B1256__) || \
216 defined(__AVR32_UC3B1128__) || defined(__AVR32_UC3B164__))
217 #define USB_SERIES_UC3B1_AVR32
218 #define USB_CAN_BE_DEVICE
219 #define USB_CAN_BE_HOST
220 #elif (defined(__AVR_ATxmega128A1U__) || defined(__AVR_ATxmega64A1U__))
221 #define USB_SERIES_A1U_XMEGA
222 #define USB_CAN_BE_DEVICE
223 #elif (defined(__AVR_ATxmega64A3U__) || defined(__AVR_ATxmega128A3U__) || \
224 defined(__AVR_ATxmega192A3U__) || defined(__AVR_ATxmega256A3U__))
225 #define USB_SERIES_A3U_XMEGA
226 #define USB_CAN_BE_DEVICE
227 #elif (defined(__AVR_ATxmega256A3BU__))
228 #define USB_SERIES_A3BU_XMEGA
229 #define USB_CAN_BE_DEVICE
230 #elif (defined(__AVR_ATxmega16A4U__) || defined(__AVR_ATxmega32A4U__) || \
231 defined(__AVR_ATxmega64A4U__) || defined(__AVR_ATxmega128A4U__))
232 #define USB_SERIES_A4U_XMEGA
233 #define USB_CAN_BE_DEVICE
234 #elif (defined(__AVR_ATxmega128B1__) || defined(__AVR_ATxmega64B1__))
235 #define USB_SERIES_B1_XMEGA
236 #define USB_CAN_BE_DEVICE
237 #elif (defined(__AVR_ATxmega128B3__) || defined(__AVR_ATxmega64B3__))
238 #define USB_SERIES_B3_XMEGA
239 #define USB_CAN_BE_DEVICE
240 #elif (defined(__AVR_ATxmega128C3__) || defined(__AVR_ATxmega64C3__) || \
241 defined(__AVR_ATxmega192C3__) || defined(__AVR_ATxmega256C3__) || \
242 defined(__AVR_ATxmega384C3__))
243 #define USB_SERIES_C3_XMEGA
244 #define USB_CAN_BE_DEVICE
245 #elif (defined(__AVR_ATxmega16C4__) || defined(__AVR_ATxmega32C4__))
246 #define USB_SERIES_C4_XMEGA
247 #define USB_CAN_BE_DEVICE
248 #endif
249
250 #if (defined(USB_HOST_ONLY) && defined(USB_DEVICE_ONLY))
251 #error USB_HOST_ONLY and USB_DEVICE_ONLY are mutually exclusive.
252 #elif defined(USB_HOST_ONLY)
253 #if !defined(USB_CAN_BE_HOST)
254 #error USB_HOST_ONLY is not available for the currently selected microcontroller model.
255 #else
256 #undef USB_CAN_BE_DEVICE
257 #endif
258 #elif defined(USB_DEVICE_ONLY)
259 #if !defined(USB_CAN_BE_DEVICE)
260 #error USB_DEVICE_ONLY is not available for the currently selected microcontroller model.
261 #else
262 #undef USB_CAN_BE_HOST
263 #endif
264 #endif
265
266 #if (defined(USB_CAN_BE_DEVICE) && defined(USB_CAN_BE_HOST))
267 #define USB_CAN_BE_BOTH
268 #endif
269
270 #if (!defined(USB_CAN_BE_DEVICE) && !defined(USB_CAN_BE_HOST))
271 #error The currently selected device, USB mode or architecture is not supported.
272 #endif
273 #endif
274
275 /* Disable C linkage for C++ Compilers: */
276 #if defined(__cplusplus)
277 }
278 #endif
279
280 #endif
281
282 /** @} */
283
Imprint / Impressum