Add start of an architecture port to the Atmel USB XMEGA devices.
[pub/USBasp.git] / LUFA / Drivers / USB / Core / StdDescriptors.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 Common standard USB Descriptor definitions for all architectures.
33 * \copydetails Group_StdDescriptors
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_StdDescriptors USB Descriptors
41 * \brief Standard USB Descriptor definitions.
42 *
43 * Standard USB device descriptor defines and retrieval routines, for USB devices. This module contains
44 * structures and macros for the easy creation of standard USB descriptors in USB device projects.
45 *
46 * @{
47 */
48
49 #ifndef __USBDESCRIPTORS_H__
50 #define __USBDESCRIPTORS_H__
51
52 /* Includes: */
53 #include "../../../Common/Common.h"
54 #include "USBMode.h"
55 #include "Events.h"
56
57 /* Enable C linkage for C++ Compilers: */
58 #if defined(__cplusplus)
59 extern "C" {
60 #endif
61
62 /* Preprocessor Checks: */
63 #if !defined(__INCLUDE_FROM_USB_DRIVER)
64 #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
65 #endif
66
67 /* Public Interface - May be used in end-application: */
68 /* Macros: */
69 /** Indicates that a given descriptor does not exist in the device. This can be used inside descriptors
70 * for string descriptor indexes, or may be use as a return value for GetDescriptor when the specified
71 * descriptor does not exist.
72 */
73 #define NO_DESCRIPTOR 0
74
75 /** Macro to calculate the power value for the configuration descriptor, from a given number of milliamperes.
76 *
77 * \param[in] mA Maximum number of milliamps the device consumes when the given configuration is selected.
78 */
79 #define USB_CONFIG_POWER_MA(mA) ((mA) >> 1)
80
81 /** Macro to calculate the Unicode length of a string with a given number of Unicode characters.
82 * Should be used in string descriptor's headers for giving the string descriptor's byte length.
83 *
84 * \param[in] UnicodeChars Number of Unicode characters in the string text.
85 */
86 #define USB_STRING_LEN(UnicodeChars) (sizeof(USB_Descriptor_Header_t) + ((UnicodeChars) << 1))
87
88 /** Macro to encode a given four digit floating point version number (e.g. 01.23) into Binary Coded
89 * Decimal format for descriptor fields requiring BCD encoding, such as the USB version number in the
90 * standard device descriptor.
91 *
92 * \note This value is automatically converted into Little Endian, suitable for direct use inside device
93 * descriptors on all architectures without endianness conversion macros.
94 *
95 * \param[in] x Version number to encode as a 16-bit little-endian number, as a floating point number.
96 */
97 #define VERSION_BCD(x) CPU_TO_LE16((((VERSION_TENS(x) << 4) | VERSION_ONES(x)) << 8) | \
98 ((VERSION_TENTHS(x) << 4) | VERSION_HUNDREDTHS(x)))
99
100 /** String language ID for the English language. Should be used in \ref USB_Descriptor_String_t descriptors
101 * to indicate that the English language is supported by the device in its string descriptors.
102 */
103 #define LANGUAGE_ID_ENG 0x0409
104
105 /** \name Endpoint Address Direction Masks */
106 //@{
107 /** Can be masked with an endpoint address for a \ref USB_Descriptor_Endpoint_t endpoint descriptor's
108 * EndpointAddress value to indicate to the host that the endpoint is of the IN direction (i.e, from
109 * device to host).
110 */
111 #define ENDPOINT_DESCRIPTOR_DIR_IN 0x80
112
113 /** Can be masked with an endpoint address for a \ref USB_Descriptor_Endpoint_t endpoint descriptor's
114 * EndpointAddress value to indicate to the host that the endpoint is of the OUT direction (i.e, from
115 * host to device).
116 */
117 #define ENDPOINT_DESCRIPTOR_DIR_OUT 0x00
118 //@}
119
120 /** \name USB Configuration Descriptor Attribute Masks */
121 //@{
122 /** Can be masked with other configuration descriptor attributes for a \ref USB_Descriptor_Configuration_Header_t
123 * descriptor's ConfigAttributes value to indicate that the specified configuration can draw its power
124 * from the host's VBUS line.
125 */
126 #define USB_CONFIG_ATTR_BUSPOWERED 0x80
127
128 /** Can be masked with other configuration descriptor attributes for a \ref USB_Descriptor_Configuration_Header_t
129 * descriptor's ConfigAttributes value to indicate that the specified configuration can draw its power
130 * from the device's own power source.
131 */
132 #define USB_CONFIG_ATTR_SELFPOWERED 0x40
133
134 /** Can be masked with other configuration descriptor attributes for a \ref USB_Descriptor_Configuration_Header_t
135 * descriptor's ConfigAttributes value to indicate that the specified configuration supports the
136 * remote wakeup feature of the USB standard, allowing a suspended USB device to wake up the host upon
137 * request.
138 */
139 #define USB_CONFIG_ATTR_REMOTEWAKEUP 0x20
140 //@}
141
142 /** \name Endpoint Descriptor Attribute Masks */
143 //@{
144 /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
145 * Attributes value to indicate that the specified endpoint is not synchronized.
146 *
147 * \see The USB specification for more details on the possible Endpoint attributes.
148 */
149 #define ENDPOINT_ATTR_NO_SYNC (0 << 2)
150
151 /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
152 * Attributes value to indicate that the specified endpoint is asynchronous.
153 *
154 * \see The USB specification for more details on the possible Endpoint attributes.
155 */
156 #define ENDPOINT_ATTR_ASYNC (1 << 2)
157
158 /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
159 * Attributes value to indicate that the specified endpoint is adaptive.
160 *
161 * \see The USB specification for more details on the possible Endpoint attributes.
162 */
163 #define ENDPOINT_ATTR_ADAPTIVE (2 << 2)
164
165 /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
166 * Attributes value to indicate that the specified endpoint is synchronized.
167 *
168 * \see The USB specification for more details on the possible Endpoint attributes.
169 */
170 #define ENDPOINT_ATTR_SYNC (3 << 2)
171 //@}
172
173 /** \name Endpoint Descriptor Usage Masks */
174 //@{
175 /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
176 * Attributes value to indicate that the specified endpoint is used for data transfers.
177 *
178 * \see The USB specification for more details on the possible Endpoint usage attributes.
179 */
180 #define ENDPOINT_USAGE_DATA (0 << 4)
181
182 /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
183 * Attributes value to indicate that the specified endpoint is used for feedback.
184 *
185 * \see The USB specification for more details on the possible Endpoint usage attributes.
186 */
187 #define ENDPOINT_USAGE_FEEDBACK (1 << 4)
188
189 /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
190 * Attributes value to indicate that the specified endpoint is used for implicit feedback.
191 *
192 * \see The USB specification for more details on the possible Endpoint usage attributes.
193 */
194 #define ENDPOINT_USAGE_IMPLICIT_FEEDBACK (2 << 4)
195 //@}
196
197 /* Enums: */
198 /** Enum for the possible standard descriptor types, as given in each descriptor's header. */
199 enum USB_DescriptorTypes_t
200 {
201 DTYPE_Device = 0x01, /**< Indicates that the descriptor is a device descriptor. */
202 DTYPE_Configuration = 0x02, /**< Indicates that the descriptor is a configuration descriptor. */
203 DTYPE_String = 0x03, /**< Indicates that the descriptor is a string descriptor. */
204 DTYPE_Interface = 0x04, /**< Indicates that the descriptor is an interface descriptor. */
205 DTYPE_Endpoint = 0x05, /**< Indicates that the descriptor is an endpoint descriptor. */
206 DTYPE_DeviceQualifier = 0x06, /**< Indicates that the descriptor is a device qualifier descriptor. */
207 DTYPE_Other = 0x07, /**< Indicates that the descriptor is of other type. */
208 DTYPE_InterfacePower = 0x08, /**< Indicates that the descriptor is an interface power descriptor. */
209 DTYPE_InterfaceAssociation = 0x0B, /**< Indicates that the descriptor is an interface association descriptor. */
210 DTYPE_CSInterface = 0x24, /**< Indicates that the descriptor is a class specific interface descriptor. */
211 DTYPE_CSEndpoint = 0x25, /**< Indicates that the descriptor is a class specific endpoint descriptor. */
212 };
213
214 /** Enum for possible Class, Subclass and Protocol values of device and interface descriptors. */
215 enum USB_Descriptor_ClassSubclassProtocol_t
216 {
217 USB_CSCP_NoDeviceClass = 0x00, /**< Descriptor Class value indicating that the device does not belong
218 * to a particular class at the device level.
219 */
220 USB_CSCP_NoDeviceSubclass = 0x00, /**< Descriptor Subclass value indicating that the device does not belong
221 * to a particular subclass at the device level.
222 */
223 USB_CSCP_NoDeviceProtocol = 0x00, /**< Descriptor Protocol value indicating that the device does not belong
224 * to a particular protocol at the device level.
225 */
226 USB_CSCP_VendorSpecificClass = 0xFF, /**< Descriptor Class value indicating that the device/interface belongs
227 * to a vendor specific class.
228 */
229 USB_CSCP_VendorSpecificSubclass = 0xFF, /**< Descriptor Subclass value indicating that the device/interface belongs
230 * to a vendor specific subclass.
231 */
232 USB_CSCP_VendorSpecificProtocol = 0xFF, /**< Descriptor Protocol value indicating that the device/interface belongs
233 * to a vendor specific protocol.
234 */
235 USB_CSCP_IADDeviceClass = 0xEF, /**< Descriptor Class value indicating that the device belongs to the
236 * Interface Association Descriptor class.
237 */
238 USB_CSCP_IADDeviceSubclass = 0x02, /**< Descriptor Subclass value indicating that the device belongs to the
239 * Interface Association Descriptor subclass.
240 */
241 USB_CSCP_IADDeviceProtocol = 0x01, /**< Descriptor Protocol value indicating that the device belongs to the
242 * Interface Association Descriptor protocol.
243 */
244 };
245
246 /* Type Defines: */
247 /** \brief Standard USB Descriptor Header (LUFA naming conventions).
248 *
249 * Type define for all descriptors' standard header, indicating the descriptor's length and type. This structure
250 * uses LUFA-specific element names to make each element's purpose clearer.
251 *
252 * \see \ref USB_StdDescriptor_Header_t for the version of this type with standard element names.
253 *
254 * \note Regardless of CPU architecture, these values should be stored as little endian.
255 */
256 typedef struct
257 {
258 uint8_t Size; /**< Size of the descriptor, in bytes. */
259 uint8_t Type; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
260 * given by the specific class.
261 */
262 } ATTR_PACKED USB_Descriptor_Header_t;
263
264 /** \brief Standard USB Descriptor Header (USB-IF naming conventions).
265 *
266 * Type define for all descriptors' standard header, indicating the descriptor's length and type. This structure
267 * uses the relevant standard's given element names to ensure compatibility with the standard.
268 *
269 * \see \ref USB_Descriptor_Header_t for the version of this type with non-standard LUFA specific element names.
270 *
271 * \note Regardless of CPU architecture, these values should be stored as little endian.
272 */
273 typedef struct
274 {
275 uint8_t bLength; /**< Size of the descriptor, in bytes. */
276 uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
277 * given by the specific class.
278 */
279 } ATTR_PACKED USB_StdDescriptor_Header_t;
280
281 /** \brief Standard USB Device Descriptor (LUFA naming conventions).
282 *
283 * Type define for a standard Device Descriptor. This structure uses LUFA-specific element names to make each
284 * element's purpose clearer.
285 *
286 * \see \ref USB_StdDescriptor_Device_t for the version of this type with standard element names.
287 *
288 * \note Regardless of CPU architecture, these values should be stored as little endian.
289 */
290 typedef struct
291 {
292 USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */
293
294 uint16_t USBSpecification; /**< BCD of the supported USB specification. */
295 uint8_t Class; /**< USB device class. */
296 uint8_t SubClass; /**< USB device subclass. */
297 uint8_t Protocol; /**< USB device protocol. */
298
299 uint8_t Endpoint0Size; /**< Size of the control (address 0) endpoint's bank in bytes. */
300
301 uint16_t VendorID; /**< Vendor ID for the USB product. */
302 uint16_t ProductID; /**< Unique product ID for the USB product. */
303 uint16_t ReleaseNumber; /**< Product release (version) number. */
304
305 uint8_t ManufacturerStrIndex; /**< String index for the manufacturer's name. The
306 * host will request this string via a separate
307 * control request for the string descriptor.
308 *
309 * \note If no string supplied, use \ref NO_DESCRIPTOR.
310 */
311 uint8_t ProductStrIndex; /**< String index for the product name/details.
312 *
313 * \see ManufacturerStrIndex structure entry.
314 */
315 uint8_t SerialNumStrIndex; /**< String index for the product's globally unique hexadecimal
316 * serial number, in uppercase Unicode ASCII.
317 *
318 * \note On some microcontroller models, there is an embedded serial number
319 * in the chip which can be used for the device serial number.
320 * To use this serial number, set this to USE_INTERNAL_SERIAL.
321 * On unsupported devices, this will evaluate to 0 and will cause
322 * the host to generate a pseudo-unique value for the device upon
323 * insertion.
324 *
325 * \see ManufacturerStrIndex structure entry.
326 */
327 uint8_t NumberOfConfigurations; /**< Total number of configurations supported by
328 * the device.
329 */
330 } ATTR_PACKED USB_Descriptor_Device_t;
331
332 /** \brief Standard USB Device Descriptor (USB-IF naming conventions).
333 *
334 * Type define for a standard Device Descriptor. This structure uses the relevant standard's given element names
335 * to ensure compatibility with the standard.
336 *
337 * \see \ref USB_Descriptor_Device_t for the version of this type with non-standard LUFA specific element names.
338 *
339 * \note Regardless of CPU architecture, these values should be stored as little endian.
340 */
341 typedef struct
342 {
343 uint8_t bLength; /**< Size of the descriptor, in bytes. */
344 uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
345 * given by the specific class.
346 */
347 uint16_t bcdUSB; /**< BCD of the supported USB specification. */
348 uint8_t bDeviceClass; /**< USB device class. */
349 uint8_t bDeviceSubClass; /**< USB device subclass. */
350 uint8_t bDeviceProtocol; /**< USB device protocol. */
351 uint8_t bMaxPacketSize0; /**< Size of the control (address 0) endpoint's bank in bytes. */
352 uint16_t idVendor; /**< Vendor ID for the USB product. */
353 uint16_t idProduct; /**< Unique product ID for the USB product. */
354 uint16_t bcdDevice; /**< Product release (version) number. */
355 uint8_t iManufacturer; /**< String index for the manufacturer's name. The
356 * host will request this string via a separate
357 * control request for the string descriptor.
358 *
359 * \note If no string supplied, use \ref NO_DESCRIPTOR.
360 */
361 uint8_t iProduct; /**< String index for the product name/details.
362 *
363 * \see ManufacturerStrIndex structure entry.
364 */
365 uint8_t iSerialNumber; /**< String index for the product's globally unique hexadecimal
366 * serial number, in uppercase Unicode ASCII.
367 *
368 * \note On some microcontroller models, there is an embedded serial number
369 * in the chip which can be used for the device serial number.
370 * To use this serial number, set this to USE_INTERNAL_SERIAL.
371 * On unsupported devices, this will evaluate to 0 and will cause
372 * the host to generate a pseudo-unique value for the device upon
373 * insertion.
374 *
375 * \see ManufacturerStrIndex structure entry.
376 */
377 uint8_t bNumConfigurations; /**< Total number of configurations supported by
378 * the device.
379 */
380 } ATTR_PACKED USB_StdDescriptor_Device_t;
381
382 /** \brief Standard USB Configuration Descriptor (LUFA naming conventions).
383 *
384 * Type define for a standard Configuration Descriptor header. This structure uses LUFA-specific element names
385 * to make each element's purpose clearer.
386 *
387 * \see \ref USB_StdDescriptor_Configuration_Header_t for the version of this type with standard element names.
388 *
389 * \note Regardless of CPU architecture, these values should be stored as little endian.
390 */
391 typedef struct
392 {
393 USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */
394
395 uint16_t TotalConfigurationSize; /**< Size of the configuration descriptor header,
396 * and all sub descriptors inside the configuration.
397 */
398 uint8_t TotalInterfaces; /**< Total number of interfaces in the configuration. */
399
400 uint8_t ConfigurationNumber; /**< Configuration index of the current configuration. */
401 uint8_t ConfigurationStrIndex; /**< Index of a string descriptor describing the configuration. */
402
403 uint8_t ConfigAttributes; /**< Configuration attributes, comprised of a mask of zero or
404 * more USB_CONFIG_ATTR_* masks.
405 */
406
407 uint8_t MaxPowerConsumption; /**< Maximum power consumption of the device while in the
408 * current configuration, calculated by the \ref USB_CONFIG_POWER_MA()
409 * macro.
410 */
411 } ATTR_PACKED USB_Descriptor_Configuration_Header_t;
412
413 /** \brief Standard USB Configuration Descriptor (USB-IF naming conventions).
414 *
415 * Type define for a standard Configuration Descriptor header. This structure uses the relevant standard's given element names
416 * to ensure compatibility with the standard.
417 *
418 * \see \ref USB_Descriptor_Device_t for the version of this type with non-standard LUFA specific element names.
419 *
420 * \note Regardless of CPU architecture, these values should be stored as little endian.
421 */
422 typedef struct
423 {
424 uint8_t bLength; /**< Size of the descriptor, in bytes. */
425 uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
426 * given by the specific class.
427 */
428 uint16_t wTotalLength; /**< Size of the configuration descriptor header,
429 * and all sub descriptors inside the configuration.
430 */
431 uint8_t bNumInterfaces; /**< Total number of interfaces in the configuration. */
432 uint8_t bConfigurationValue; /**< Configuration index of the current configuration. */
433 uint8_t iConfiguration; /**< Index of a string descriptor describing the configuration. */
434 uint8_t bmAttributes; /**< Configuration attributes, comprised of a mask of zero or
435 * more USB_CONFIG_ATTR_* masks.
436 */
437 uint8_t bMaxPower; /**< Maximum power consumption of the device while in the
438 * current configuration, calculated by the \ref USB_CONFIG_POWER_MA()
439 * macro.
440 */
441 } ATTR_PACKED USB_StdDescriptor_Configuration_Header_t;
442
443 /** \brief Standard USB Interface Descriptor (LUFA naming conventions).
444 *
445 * Type define for a standard Interface Descriptor. This structure uses LUFA-specific element names
446 * to make each element's purpose clearer.
447 *
448 * \see \ref USB_StdDescriptor_Interface_t for the version of this type with standard element names.
449 *
450 * \note Regardless of CPU architecture, these values should be stored as little endian.
451 */
452 typedef struct
453 {
454 USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */
455
456 uint8_t InterfaceNumber; /**< Index of the interface in the current configuration. */
457 uint8_t AlternateSetting; /**< Alternate setting for the interface number. The same
458 * interface number can have multiple alternate settings
459 * with different endpoint configurations, which can be
460 * selected by the host.
461 */
462 uint8_t TotalEndpoints; /**< Total number of endpoints in the interface. */
463
464 uint8_t Class; /**< Interface class ID. */
465 uint8_t SubClass; /**< Interface subclass ID. */
466 uint8_t Protocol; /**< Interface protocol ID. */
467
468 uint8_t InterfaceStrIndex; /**< Index of the string descriptor describing the interface. */
469 } ATTR_PACKED USB_Descriptor_Interface_t;
470
471 /** \brief Standard USB Interface Descriptor (USB-IF naming conventions).
472 *
473 * Type define for a standard Interface Descriptor. This structure uses the relevant standard's given element names
474 * to ensure compatibility with the standard.
475 *
476 * \see \ref USB_Descriptor_Interface_t for the version of this type with non-standard LUFA specific element names.
477 *
478 * \note Regardless of CPU architecture, these values should be stored as little endian.
479 */
480 typedef struct
481 {
482 uint8_t bLength; /**< Size of the descriptor, in bytes. */
483 uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
484 * given by the specific class.
485 */
486 uint8_t bInterfaceNumber; /**< Index of the interface in the current configuration. */
487 uint8_t bAlternateSetting; /**< Alternate setting for the interface number. The same
488 * interface number can have multiple alternate settings
489 * with different endpoint configurations, which can be
490 * selected by the host.
491 */
492 uint8_t bNumEndpoints; /**< Total number of endpoints in the interface. */
493 uint8_t bInterfaceClass; /**< Interface class ID. */
494 uint8_t bInterfaceSubClass; /**< Interface subclass ID. */
495 uint8_t bInterfaceProtocol; /**< Interface protocol ID. */
496 uint8_t iInterface; /**< Index of the string descriptor describing the
497 * interface.
498 */
499 } ATTR_PACKED USB_StdDescriptor_Interface_t;
500
501 /** \brief Standard USB Interface Association Descriptor (LUFA naming conventions).
502 *
503 * Type define for a standard Interface Association Descriptor. This structure uses LUFA-specific element names
504 * to make each element's purpose clearer.
505 *
506 * This descriptor has been added as a supplement to the USB2.0 standard, in the ECN located at
507 * <a>http://www.usb.org/developers/docs/InterfaceAssociationDescriptor_ecn.pdf</a>. It allows composite
508 * devices with multiple interfaces related to the same function to have the multiple interfaces bound
509 * together at the point of enumeration, loading one generic driver for all the interfaces in the single
510 * function. Read the ECN for more information.
511 *
512 * \see \ref USB_StdDescriptor_Interface_Association_t for the version of this type with standard element names.
513 *
514 * \note Regardless of CPU architecture, these values should be stored as little endian.
515 */
516 typedef struct
517 {
518 USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */
519
520 uint8_t FirstInterfaceIndex; /**< Index of the first associated interface. */
521 uint8_t TotalInterfaces; /**< Total number of associated interfaces. */
522
523 uint8_t Class; /**< Interface class ID. */
524 uint8_t SubClass; /**< Interface subclass ID. */
525 uint8_t Protocol; /**< Interface protocol ID. */
526
527 uint8_t IADStrIndex; /**< Index of the string descriptor describing the
528 * interface association.
529 */
530 } ATTR_PACKED USB_Descriptor_Interface_Association_t;
531
532 /** \brief Standard USB Interface Association Descriptor (USB-IF naming conventions).
533 *
534 * Type define for a standard Interface Association Descriptor. This structure uses the relevant standard's given
535 * element names to ensure compatibility with the standard.
536 *
537 * This descriptor has been added as a supplement to the USB2.0 standard, in the ECN located at
538 * <a>http://www.usb.org/developers/docs/InterfaceAssociationDescriptor_ecn.pdf</a>. It allows composite
539 * devices with multiple interfaces related to the same function to have the multiple interfaces bound
540 * together at the point of enumeration, loading one generic driver for all the interfaces in the single
541 * function. Read the ECN for more information.
542 *
543 * \see \ref USB_Descriptor_Interface_Association_t for the version of this type with non-standard LUFA specific
544 * element names.
545 *
546 * \note Regardless of CPU architecture, these values should be stored as little endian.
547 */
548 typedef struct
549 {
550 uint8_t bLength; /**< Size of the descriptor, in bytes. */
551 uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
552 * given by the specific class.
553 */
554 uint8_t bFirstInterface; /**< Index of the first associated interface. */
555 uint8_t bInterfaceCount; /**< Total number of associated interfaces. */
556 uint8_t bFunctionClass; /**< Interface class ID. */
557 uint8_t bFunctionSubClass; /**< Interface subclass ID. */
558 uint8_t bFunctionProtocol; /**< Interface protocol ID. */
559 uint8_t iFunction; /**< Index of the string descriptor describing the
560 * interface association.
561 */
562 } ATTR_PACKED USB_StdDescriptor_Interface_Association_t;
563
564 /** \brief Standard USB Endpoint Descriptor (LUFA naming conventions).
565 *
566 * Type define for a standard Endpoint Descriptor. This structure uses LUFA-specific element names
567 * to make each element's purpose clearer.
568 *
569 * \see \ref USB_StdDescriptor_Endpoint_t for the version of this type with standard element names.
570 *
571 * \note Regardless of CPU architecture, these values should be stored as little endian.
572 */
573 typedef struct
574 {
575 USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */
576
577 uint8_t EndpointAddress; /**< Logical address of the endpoint within the device for the current
578 * configuration, including direction mask.
579 */
580 uint8_t Attributes; /**< Endpoint attributes, comprised of a mask of the endpoint type (EP_TYPE_*)
581 * and attributes (ENDPOINT_ATTR_*) masks.
582 */
583 uint16_t EndpointSize; /**< Size of the endpoint bank, in bytes. This indicates the maximum packet
584 * size that the endpoint can receive at a time.
585 */
586 uint8_t PollingIntervalMS; /**< Polling interval in milliseconds for the endpoint if it is an INTERRUPT
587 * or ISOCHRONOUS type.
588 */
589 } ATTR_PACKED USB_Descriptor_Endpoint_t;
590
591 /** \brief Standard USB Endpoint Descriptor (USB-IF naming conventions).
592 *
593 * Type define for a standard Endpoint Descriptor. This structure uses the relevant standard's given
594 * element names to ensure compatibility with the standard.
595 *
596 * \see \ref USB_Descriptor_Endpoint_t for the version of this type with non-standard LUFA specific
597 * element names.
598 *
599 * \note Regardless of CPU architecture, these values should be stored as little endian.
600 */
601 typedef struct
602 {
603 uint8_t bLength; /**< Size of the descriptor, in bytes. */
604 uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a
605 * value given by the specific class.
606 */
607 uint8_t bEndpointAddress; /**< Logical address of the endpoint within the device for the current
608 * configuration, including direction mask.
609 */
610 uint8_t bmAttributes; /**< Endpoint attributes, comprised of a mask of the endpoint type (EP_TYPE_*)
611 * and attributes (ENDPOINT_ATTR_*) masks.
612 */
613 uint16_t wMaxPacketSize; /**< Size of the endpoint bank, in bytes. This indicates the maximum packet size
614 * that the endpoint can receive at a time.
615 */
616 uint8_t bInterval; /**< Polling interval in milliseconds for the endpoint if it is an INTERRUPT or
617 * ISOCHRONOUS type.
618 */
619 } ATTR_PACKED USB_StdDescriptor_Endpoint_t;
620
621 /** \brief Standard USB String Descriptor (LUFA naming conventions).
622 *
623 * Type define for a standard string descriptor. Unlike other standard descriptors, the length
624 * of the descriptor for placement in the descriptor header must be determined by the \ref USB_STRING_LEN()
625 * macro rather than by the size of the descriptor structure, as the length is not fixed.
626 *
627 * This structure should also be used for string index 0, which contains the supported language IDs for
628 * the device as an array.
629 *
630 * This structure uses LUFA-specific element names to make each element's purpose clearer.
631 *
632 * \see \ref USB_StdDescriptor_String_t for the version of this type with standard element names.
633 *
634 * \note Regardless of CPU architecture, these values should be stored as little endian.
635 */
636 typedef struct
637 {
638 USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */
639
640 #if ((ARCH == ARCH_AVR8) || (ARCH == ARCH_XMEGA))
641 wchar_t UnicodeString[];
642 #else
643 uint16_t UnicodeString[]; /**< String data, as unicode characters (alternatively,
644 * string language IDs). If normal ASCII characters are
645 * to be used, they must be added as an array of characters
646 * rather than a normal C string so that they are widened to
647 * Unicode size.
648 *
649 * Under GCC, strings prefixed with the "L" character (before
650 * the opening string quotation mark) are considered to be
651 * Unicode strings, and may be used instead of an explicit
652 * array of ASCII characters.
653 */
654 #endif
655 } ATTR_PACKED USB_Descriptor_String_t;
656
657 /** \brief Standard USB String Descriptor (USB-IF naming conventions).
658 *
659 * Type define for a standard string descriptor. Unlike other standard descriptors, the length
660 * of the descriptor for placement in the descriptor header must be determined by the \ref USB_STRING_LEN()
661 * macro rather than by the size of the descriptor structure, as the length is not fixed.
662 *
663 * This structure should also be used for string index 0, which contains the supported language IDs for
664 * the device as an array.
665 *
666 * This structure uses the relevant standard's given element names to ensure compatibility with the standard.
667 *
668 * \see \ref USB_Descriptor_String_t for the version of this type with with non-standard LUFA specific
669 * element names.
670 *
671 * \note Regardless of CPU architecture, these values should be stored as little endian.
672 */
673 typedef struct
674 {
675 uint8_t bLength; /**< Size of the descriptor, in bytes. */
676 uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t
677 * or a value given by the specific class.
678 */
679 uint16_t bString[]; /**< String data, as unicode characters (alternatively, string language IDs).
680 * If normal ASCII characters are to be used, they must be added as an array
681 * of characters rather than a normal C string so that they are widened to
682 * Unicode size.
683 *
684 * Under GCC, strings prefixed with the "L" character (before the opening string
685 * quotation mark) are considered to be Unicode strings, and may be used instead
686 * of an explicit array of ASCII characters.
687 */
688 } ATTR_PACKED USB_StdDescriptor_String_t;
689
690 /* Private Interface - For use in library only: */
691 #if !defined(__DOXYGEN__)
692 /* Macros: */
693 #define VERSION_TENS(x) (int)((x) / 10)
694 #define VERSION_ONES(x) (int)((x) - (10 * VERSION_TENS(x)))
695 #define VERSION_TENTHS(x) (int)(((x) - (int)(x)) * 10)
696 #define VERSION_HUNDREDTHS(x) (int)((((x) - (int)(x)) * 100) - (10 * VERSION_TENTHS(x)))
697 #endif
698
699 /* Disable C linkage for C++ Compilers: */
700 #if defined(__cplusplus)
701 }
702 #endif
703
704 #endif
705
706 /** @} */
707