3 Copyright (C) Dean Camera, 2013.
5 dean [at] fourwalledcubicle [dot] com
10 Copyright 2013 Dean Camera (dean [at] fourwalledcubicle [dot] com)
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.
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
32 * \brief Common standard USB Descriptor definitions for all architectures.
33 * \copydetails Group_StdDescriptors
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.
39 /** \ingroup Group_USB
40 * \defgroup Group_StdDescriptors USB Descriptors
41 * \brief Standard USB Descriptor definitions.
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.
49 #ifndef __USBDESCRIPTORS_H__
50 #define __USBDESCRIPTORS_H__
53 #include "../../../Common/Common.h"
57 /* Enable C linkage for C++ Compilers: */
58 #if defined(__cplusplus)
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.
67 /* Public Interface - May be used in end-application: */
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.
73 #define NO_DESCRIPTOR 0
75 /** Macro to calculate the power value for the configuration descriptor, from a given number of milliamperes.
77 * \param[in] mA Maximum number of milliamps the device consumes when the given configuration is selected.
79 #define USB_CONFIG_POWER_MA(mA) ((mA) >> 1)
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.
84 * \param[in] UnicodeChars Number of Unicode characters in the string text.
86 #define USB_STRING_LEN(UnicodeChars) (sizeof(USB_Descriptor_Header_t) + ((UnicodeChars) << 1))
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.
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.
95 * \param[in] x Version number to encode as a 16-bit little-endian number, as a floating point number.
97 #define VERSION_BCD(x) CPU_TO_LE16((VERSION_TENS(x) << 12) | (VERSION_ONES(x) << 8) | \
98 (VERSION_TENTHS(x) << 4) | (VERSION_HUNDREDTHS(x) << 0) )
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.
103 #define LANGUAGE_ID_ENG 0x0409
105 /** \name USB Configuration Descriptor Attribute Masks */
107 /** Mask for the reserved bit in the Configuration Descriptor's \c ConfigAttributes field, which must be set on all
108 * devices for historical purposes.
110 #define USB_CONFIG_ATTR_RESERVED 0x80
112 /** Can be masked with other configuration descriptor attributes for a \ref USB_Descriptor_Configuration_Header_t
113 * descriptor's \c ConfigAttributes value to indicate that the specified configuration can draw its power
114 * from the device's own power source.
116 #define USB_CONFIG_ATTR_SELFPOWERED 0x40
118 /** Can be masked with other configuration descriptor attributes for a \ref USB_Descriptor_Configuration_Header_t
119 * descriptor's \c ConfigAttributes value to indicate that the specified configuration supports the
120 * remote wakeup feature of the USB standard, allowing a suspended USB device to wake up the host upon
123 #define USB_CONFIG_ATTR_REMOTEWAKEUP 0x20
126 /** \name Endpoint Descriptor Attribute Masks */
128 /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
129 * \c Attributes value to indicate that the specified endpoint is not synchronized.
131 * \see The USB specification for more details on the possible Endpoint attributes.
133 #define ENDPOINT_ATTR_NO_SYNC (0 << 2)
135 /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
136 * \c Attributes value to indicate that the specified endpoint is asynchronous.
138 * \see The USB specification for more details on the possible Endpoint attributes.
140 #define ENDPOINT_ATTR_ASYNC (1 << 2)
142 /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
143 * \c Attributes value to indicate that the specified endpoint is adaptive.
145 * \see The USB specification for more details on the possible Endpoint attributes.
147 #define ENDPOINT_ATTR_ADAPTIVE (2 << 2)
149 /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
150 * \c Attributes value to indicate that the specified endpoint is synchronized.
152 * \see The USB specification for more details on the possible Endpoint attributes.
154 #define ENDPOINT_ATTR_SYNC (3 << 2)
157 /** \name Endpoint Descriptor Usage Masks */
159 /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
160 * \c Attributes value to indicate that the specified endpoint is used for data transfers.
162 * \see The USB specification for more details on the possible Endpoint usage attributes.
164 #define ENDPOINT_USAGE_DATA (0 << 4)
166 /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
167 * \c Attributes value to indicate that the specified endpoint is used for feedback.
169 * \see The USB specification for more details on the possible Endpoint usage attributes.
171 #define ENDPOINT_USAGE_FEEDBACK (1 << 4)
173 /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
174 * \c Attributes value to indicate that the specified endpoint is used for implicit feedback.
176 * \see The USB specification for more details on the possible Endpoint usage attributes.
178 #define ENDPOINT_USAGE_IMPLICIT_FEEDBACK (2 << 4)
182 /** Enum for the possible standard descriptor types, as given in each descriptor's header. */
183 enum USB_DescriptorTypes_t
185 DTYPE_Device
= 0x01, /**< Indicates that the descriptor is a device descriptor. */
186 DTYPE_Configuration
= 0x02, /**< Indicates that the descriptor is a configuration descriptor. */
187 DTYPE_String
= 0x03, /**< Indicates that the descriptor is a string descriptor. */
188 DTYPE_Interface
= 0x04, /**< Indicates that the descriptor is an interface descriptor. */
189 DTYPE_Endpoint
= 0x05, /**< Indicates that the descriptor is an endpoint descriptor. */
190 DTYPE_DeviceQualifier
= 0x06, /**< Indicates that the descriptor is a device qualifier descriptor. */
191 DTYPE_Other
= 0x07, /**< Indicates that the descriptor is of other type. */
192 DTYPE_InterfacePower
= 0x08, /**< Indicates that the descriptor is an interface power descriptor. */
193 DTYPE_InterfaceAssociation
= 0x0B, /**< Indicates that the descriptor is an interface association descriptor. */
194 DTYPE_CSInterface
= 0x24, /**< Indicates that the descriptor is a class specific interface descriptor. */
195 DTYPE_CSEndpoint
= 0x25, /**< Indicates that the descriptor is a class specific endpoint descriptor. */
198 /** Enum for possible Class, Subclass and Protocol values of device and interface descriptors. */
199 enum USB_Descriptor_ClassSubclassProtocol_t
201 USB_CSCP_NoDeviceClass
= 0x00, /**< Descriptor Class value indicating that the device does not belong
202 * to a particular class at the device level.
204 USB_CSCP_NoDeviceSubclass
= 0x00, /**< Descriptor Subclass value indicating that the device does not belong
205 * to a particular subclass at the device level.
207 USB_CSCP_NoDeviceProtocol
= 0x00, /**< Descriptor Protocol value indicating that the device does not belong
208 * to a particular protocol at the device level.
210 USB_CSCP_VendorSpecificClass
= 0xFF, /**< Descriptor Class value indicating that the device/interface belongs
211 * to a vendor specific class.
213 USB_CSCP_VendorSpecificSubclass
= 0xFF, /**< Descriptor Subclass value indicating that the device/interface belongs
214 * to a vendor specific subclass.
216 USB_CSCP_VendorSpecificProtocol
= 0xFF, /**< Descriptor Protocol value indicating that the device/interface belongs
217 * to a vendor specific protocol.
219 USB_CSCP_IADDeviceClass
= 0xEF, /**< Descriptor Class value indicating that the device belongs to the
220 * Interface Association Descriptor class.
222 USB_CSCP_IADDeviceSubclass
= 0x02, /**< Descriptor Subclass value indicating that the device belongs to the
223 * Interface Association Descriptor subclass.
225 USB_CSCP_IADDeviceProtocol
= 0x01, /**< Descriptor Protocol value indicating that the device belongs to the
226 * Interface Association Descriptor protocol.
231 /** \brief Standard USB Descriptor Header (LUFA naming conventions).
233 * Type define for all descriptors' standard header, indicating the descriptor's length and type. This structure
234 * uses LUFA-specific element names to make each element's purpose clearer.
236 * \see \ref USB_StdDescriptor_Header_t for the version of this type with standard element names.
238 * \note Regardless of CPU architecture, these values should be stored as little endian.
242 uint8_t Size
; /**< Size of the descriptor, in bytes. */
243 uint8_t Type
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
244 * given by the specific class.
246 } ATTR_PACKED USB_Descriptor_Header_t
;
248 /** \brief Standard USB Descriptor Header (USB-IF naming conventions).
250 * Type define for all descriptors' standard header, indicating the descriptor's length and type. This structure
251 * uses the relevant standard's given element names to ensure compatibility with the standard.
253 * \see \ref USB_Descriptor_Header_t for the version of this type with non-standard LUFA specific element names.
255 * \note Regardless of CPU architecture, these values should be stored as little endian.
259 uint8_t bLength
; /**< Size of the descriptor, in bytes. */
260 uint8_t bDescriptorType
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
261 * given by the specific class.
263 } ATTR_PACKED USB_StdDescriptor_Header_t
;
265 /** \brief Standard USB Device Descriptor (LUFA naming conventions).
267 * Type define for a standard Device Descriptor. This structure uses LUFA-specific element names to make each
268 * element's purpose clearer.
270 * \see \ref USB_StdDescriptor_Device_t for the version of this type with standard element names.
272 * \note Regardless of CPU architecture, these values should be stored as little endian.
276 USB_Descriptor_Header_t Header
; /**< Descriptor header, including type and size. */
278 uint16_t USBSpecification
; /**< BCD of the supported USB specification.
280 * \see \ref VERSION_BCD() utility macro.
282 uint8_t Class
; /**< USB device class. */
283 uint8_t SubClass
; /**< USB device subclass. */
284 uint8_t Protocol
; /**< USB device protocol. */
286 uint8_t Endpoint0Size
; /**< Size of the control (address 0) endpoint's bank in bytes. */
288 uint16_t VendorID
; /**< Vendor ID for the USB product. */
289 uint16_t ProductID
; /**< Unique product ID for the USB product. */
290 uint16_t ReleaseNumber
; /**< Product release (version) number.
292 * \see \ref VERSION_BCD() utility macro.
294 uint8_t ManufacturerStrIndex
; /**< String index for the manufacturer's name. The
295 * host will request this string via a separate
296 * control request for the string descriptor.
298 * \note If no string supplied, use \ref NO_DESCRIPTOR.
300 uint8_t ProductStrIndex
; /**< String index for the product name/details.
302 * \see ManufacturerStrIndex structure entry.
304 uint8_t SerialNumStrIndex
; /**< String index for the product's globally unique hexadecimal
305 * serial number, in uppercase Unicode ASCII.
307 * \note On some microcontroller models, there is an embedded serial number
308 * in the chip which can be used for the device serial number.
309 * To use this serial number, set this to \c USE_INTERNAL_SERIAL.
310 * On unsupported devices, this will evaluate to \ref NO_DESCRIPTOR
311 * and will cause the host to generate a pseudo-unique value for the
312 * device upon insertion.
314 * \see \c ManufacturerStrIndex structure entry.
316 uint8_t NumberOfConfigurations
; /**< Total number of configurations supported by
319 } ATTR_PACKED USB_Descriptor_Device_t
;
321 /** \brief Standard USB Device Descriptor (USB-IF naming conventions).
323 * Type define for a standard Device Descriptor. This structure uses the relevant standard's given element names
324 * to ensure compatibility with the standard.
326 * \see \ref USB_Descriptor_Device_t for the version of this type with non-standard LUFA specific element names.
328 * \note Regardless of CPU architecture, these values should be stored as little endian.
332 uint8_t bLength
; /**< Size of the descriptor, in bytes. */
333 uint8_t bDescriptorType
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
334 * given by the specific class.
336 uint16_t bcdUSB
; /**< BCD of the supported USB specification.
338 * \see \ref VERSION_BCD() utility macro.
340 uint8_t bDeviceClass
; /**< USB device class. */
341 uint8_t bDeviceSubClass
; /**< USB device subclass. */
342 uint8_t bDeviceProtocol
; /**< USB device protocol. */
343 uint8_t bMaxPacketSize0
; /**< Size of the control (address 0) endpoint's bank in bytes. */
344 uint16_t idVendor
; /**< Vendor ID for the USB product. */
345 uint16_t idProduct
; /**< Unique product ID for the USB product. */
346 uint16_t bcdDevice
; /**< Product release (version) number.
348 * \see \ref VERSION_BCD() utility macro.
350 uint8_t iManufacturer
; /**< String index for the manufacturer's name. The
351 * host will request this string via a separate
352 * control request for the string descriptor.
354 * \note If no string supplied, use \ref NO_DESCRIPTOR.
356 uint8_t iProduct
; /**< String index for the product name/details.
358 * \see ManufacturerStrIndex structure entry.
360 uint8_t iSerialNumber
; /**< String index for the product's globally unique hexadecimal
361 * serial number, in uppercase Unicode ASCII.
363 * \note On some microcontroller models, there is an embedded serial number
364 * in the chip which can be used for the device serial number.
365 * To use this serial number, set this to \c USE_INTERNAL_SERIAL.
366 * On unsupported devices, this will evaluate to \ref NO_DESCRIPTOR
367 * and will cause the host to generate a pseudo-unique value for the
368 * device upon insertion.
370 * \see \c ManufacturerStrIndex structure entry.
372 uint8_t bNumConfigurations
; /**< Total number of configurations supported by
375 } ATTR_PACKED USB_StdDescriptor_Device_t
;
377 /** \brief Standard USB Device Qualifier Descriptor (LUFA naming conventions).
379 * Type define for a standard Device Qualifier Descriptor. This structure uses LUFA-specific element names
380 * to make each element's purpose clearer.
382 * \see \ref USB_StdDescriptor_DeviceQualifier_t for the version of this type with standard element names.
386 USB_Descriptor_Header_t Header
; /**< Descriptor header, including type and size. */
388 uint16_t USBSpecification
; /**< BCD of the supported USB specification.
390 * \see \ref VERSION_BCD() utility macro.
392 uint8_t Class
; /**< USB device class. */
393 uint8_t SubClass
; /**< USB device subclass. */
394 uint8_t Protocol
; /**< USB device protocol. */
396 uint8_t Endpoint0Size
; /**< Size of the control (address 0) endpoint's bank in bytes. */
397 uint8_t NumberOfConfigurations
; /**< Total number of configurations supported by
400 uint8_t Reserved
; /**< Reserved for future use, must be 0. */
401 } ATTR_PACKED USB_Descriptor_DeviceQualifier_t
;
403 /** \brief Standard USB Device Qualifier Descriptor (USB-IF naming conventions).
405 * Type define for a standard Device Qualifier Descriptor. This structure uses the relevant standard's given element names
406 * to ensure compatibility with the standard.
408 * \see \ref USB_Descriptor_DeviceQualifier_t for the version of this type with non-standard LUFA specific element names.
412 uint8_t bLength
; /**< Size of the descriptor, in bytes. */
413 uint8_t bDescriptorType
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
414 * given by the specific class.
416 uint16_t bcdUSB
; /**< BCD of the supported USB specification.
418 * \see \ref VERSION_BCD() utility macro.
420 uint8_t bDeviceClass
; /**< USB device class. */
421 uint8_t bDeviceSubClass
; /**< USB device subclass. */
422 uint8_t bDeviceProtocol
; /**< USB device protocol. */
423 uint8_t bMaxPacketSize0
; /**< Size of the control (address 0) endpoint's bank in bytes. */
424 uint8_t bNumConfigurations
; /**< Total number of configurations supported by
427 uint8_t bReserved
; /**< Reserved for future use, must be 0. */
428 } ATTR_PACKED USB_StdDescriptor_DeviceQualifier_t
;
430 /** \brief Standard USB Configuration Descriptor (LUFA naming conventions).
432 * Type define for a standard Configuration Descriptor header. This structure uses LUFA-specific element names
433 * to make each element's purpose clearer.
435 * \see \ref USB_StdDescriptor_Configuration_Header_t for the version of this type with standard element names.
437 * \note Regardless of CPU architecture, these values should be stored as little endian.
441 USB_Descriptor_Header_t Header
; /**< Descriptor header, including type and size. */
443 uint16_t TotalConfigurationSize
; /**< Size of the configuration descriptor header,
444 * and all sub descriptors inside the configuration.
446 uint8_t TotalInterfaces
; /**< Total number of interfaces in the configuration. */
448 uint8_t ConfigurationNumber
; /**< Configuration index of the current configuration. */
449 uint8_t ConfigurationStrIndex
; /**< Index of a string descriptor describing the configuration. */
451 uint8_t ConfigAttributes
; /**< Configuration attributes, comprised of a mask of \c USB_CONFIG_ATTR_* masks.
452 * On all devices, this should include USB_CONFIG_ATTR_RESERVED at a minimum.
455 uint8_t MaxPowerConsumption
; /**< Maximum power consumption of the device while in the
456 * current configuration, calculated by the \ref USB_CONFIG_POWER_MA()
459 } ATTR_PACKED USB_Descriptor_Configuration_Header_t
;
461 /** \brief Standard USB Configuration Descriptor (USB-IF naming conventions).
463 * Type define for a standard Configuration Descriptor header. This structure uses the relevant standard's given element names
464 * to ensure compatibility with the standard.
466 * \see \ref USB_Descriptor_Device_t for the version of this type with non-standard LUFA specific element names.
468 * \note Regardless of CPU architecture, these values should be stored as little endian.
472 uint8_t bLength
; /**< Size of the descriptor, in bytes. */
473 uint8_t bDescriptorType
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
474 * given by the specific class.
476 uint16_t wTotalLength
; /**< Size of the configuration descriptor header,
477 * and all sub descriptors inside the configuration.
479 uint8_t bNumInterfaces
; /**< Total number of interfaces in the configuration. */
480 uint8_t bConfigurationValue
; /**< Configuration index of the current configuration. */
481 uint8_t iConfiguration
; /**< Index of a string descriptor describing the configuration. */
482 uint8_t bmAttributes
; /**< Configuration attributes, comprised of a mask of \c USB_CONFIG_ATTR_* masks.
483 * On all devices, this should include USB_CONFIG_ATTR_RESERVED at a minimum.
485 uint8_t bMaxPower
; /**< Maximum power consumption of the device while in the
486 * current configuration, calculated by the \ref USB_CONFIG_POWER_MA()
489 } ATTR_PACKED USB_StdDescriptor_Configuration_Header_t
;
491 /** \brief Standard USB Interface Descriptor (LUFA naming conventions).
493 * Type define for a standard Interface Descriptor. This structure uses LUFA-specific element names
494 * to make each element's purpose clearer.
496 * \see \ref USB_StdDescriptor_Interface_t for the version of this type with standard element names.
498 * \note Regardless of CPU architecture, these values should be stored as little endian.
502 USB_Descriptor_Header_t Header
; /**< Descriptor header, including type and size. */
504 uint8_t InterfaceNumber
; /**< Index of the interface in the current configuration. */
505 uint8_t AlternateSetting
; /**< Alternate setting for the interface number. The same
506 * interface number can have multiple alternate settings
507 * with different endpoint configurations, which can be
508 * selected by the host.
510 uint8_t TotalEndpoints
; /**< Total number of endpoints in the interface. */
512 uint8_t Class
; /**< Interface class ID. */
513 uint8_t SubClass
; /**< Interface subclass ID. */
514 uint8_t Protocol
; /**< Interface protocol ID. */
516 uint8_t InterfaceStrIndex
; /**< Index of the string descriptor describing the interface. */
517 } ATTR_PACKED USB_Descriptor_Interface_t
;
519 /** \brief Standard USB Interface Descriptor (USB-IF naming conventions).
521 * Type define for a standard Interface Descriptor. This structure uses the relevant standard's given element names
522 * to ensure compatibility with the standard.
524 * \see \ref USB_Descriptor_Interface_t for the version of this type with non-standard LUFA specific element names.
526 * \note Regardless of CPU architecture, these values should be stored as little endian.
530 uint8_t bLength
; /**< Size of the descriptor, in bytes. */
531 uint8_t bDescriptorType
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
532 * given by the specific class.
534 uint8_t bInterfaceNumber
; /**< Index of the interface in the current configuration. */
535 uint8_t bAlternateSetting
; /**< Alternate setting for the interface number. The same
536 * interface number can have multiple alternate settings
537 * with different endpoint configurations, which can be
538 * selected by the host.
540 uint8_t bNumEndpoints
; /**< Total number of endpoints in the interface. */
541 uint8_t bInterfaceClass
; /**< Interface class ID. */
542 uint8_t bInterfaceSubClass
; /**< Interface subclass ID. */
543 uint8_t bInterfaceProtocol
; /**< Interface protocol ID. */
544 uint8_t iInterface
; /**< Index of the string descriptor describing the
547 } ATTR_PACKED USB_StdDescriptor_Interface_t
;
549 /** \brief Standard USB Interface Association Descriptor (LUFA naming conventions).
551 * Type define for a standard Interface Association Descriptor. This structure uses LUFA-specific element names
552 * to make each element's purpose clearer.
554 * This descriptor has been added as a supplement to the USB2.0 standard, in the ECN located at
555 * <a>http://www.usb.org/developers/docs/InterfaceAssociationDescriptor_ecn.pdf</a>. It allows composite
556 * devices with multiple interfaces related to the same function to have the multiple interfaces bound
557 * together at the point of enumeration, loading one generic driver for all the interfaces in the single
558 * function. Read the ECN for more information.
560 * \see \ref USB_StdDescriptor_Interface_Association_t for the version of this type with standard element names.
562 * \note Regardless of CPU architecture, these values should be stored as little endian.
566 USB_Descriptor_Header_t Header
; /**< Descriptor header, including type and size. */
568 uint8_t FirstInterfaceIndex
; /**< Index of the first associated interface. */
569 uint8_t TotalInterfaces
; /**< Total number of associated interfaces. */
571 uint8_t Class
; /**< Interface class ID. */
572 uint8_t SubClass
; /**< Interface subclass ID. */
573 uint8_t Protocol
; /**< Interface protocol ID. */
575 uint8_t IADStrIndex
; /**< Index of the string descriptor describing the
576 * interface association.
578 } ATTR_PACKED USB_Descriptor_Interface_Association_t
;
580 /** \brief Standard USB Interface Association Descriptor (USB-IF naming conventions).
582 * Type define for a standard Interface Association Descriptor. This structure uses the relevant standard's given
583 * element names to ensure compatibility with the standard.
585 * This descriptor has been added as a supplement to the USB2.0 standard, in the ECN located at
586 * <a>http://www.usb.org/developers/docs/InterfaceAssociationDescriptor_ecn.pdf</a>. It allows composite
587 * devices with multiple interfaces related to the same function to have the multiple interfaces bound
588 * together at the point of enumeration, loading one generic driver for all the interfaces in the single
589 * function. Read the ECN for more information.
591 * \see \ref USB_Descriptor_Interface_Association_t for the version of this type with non-standard LUFA specific
594 * \note Regardless of CPU architecture, these values should be stored as little endian.
598 uint8_t bLength
; /**< Size of the descriptor, in bytes. */
599 uint8_t bDescriptorType
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
600 * given by the specific class.
602 uint8_t bFirstInterface
; /**< Index of the first associated interface. */
603 uint8_t bInterfaceCount
; /**< Total number of associated interfaces. */
604 uint8_t bFunctionClass
; /**< Interface class ID. */
605 uint8_t bFunctionSubClass
; /**< Interface subclass ID. */
606 uint8_t bFunctionProtocol
; /**< Interface protocol ID. */
607 uint8_t iFunction
; /**< Index of the string descriptor describing the
608 * interface association.
610 } ATTR_PACKED USB_StdDescriptor_Interface_Association_t
;
612 /** \brief Standard USB Endpoint Descriptor (LUFA naming conventions).
614 * Type define for a standard Endpoint Descriptor. This structure uses LUFA-specific element names
615 * to make each element's purpose clearer.
617 * \see \ref USB_StdDescriptor_Endpoint_t for the version of this type with standard element names.
619 * \note Regardless of CPU architecture, these values should be stored as little endian.
623 USB_Descriptor_Header_t Header
; /**< Descriptor header, including type and size. */
625 uint8_t EndpointAddress
; /**< Logical address of the endpoint within the device for the current
626 * configuration, including direction mask.
628 uint8_t Attributes
; /**< Endpoint attributes, comprised of a mask of the endpoint type (EP_TYPE_*)
629 * and attributes (ENDPOINT_ATTR_*) masks.
631 uint16_t EndpointSize
; /**< Size of the endpoint bank, in bytes. This indicates the maximum packet
632 * size that the endpoint can receive at a time.
634 uint8_t PollingIntervalMS
; /**< Polling interval in milliseconds for the endpoint if it is an INTERRUPT
635 * or ISOCHRONOUS type.
637 } ATTR_PACKED USB_Descriptor_Endpoint_t
;
639 /** \brief Standard USB Endpoint Descriptor (USB-IF naming conventions).
641 * Type define for a standard Endpoint Descriptor. This structure uses the relevant standard's given
642 * element names to ensure compatibility with the standard.
644 * \see \ref USB_Descriptor_Endpoint_t for the version of this type with non-standard LUFA specific
647 * \note Regardless of CPU architecture, these values should be stored as little endian.
651 uint8_t bLength
; /**< Size of the descriptor, in bytes. */
652 uint8_t bDescriptorType
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a
653 * value given by the specific class.
655 uint8_t bEndpointAddress
; /**< Logical address of the endpoint within the device for the current
656 * configuration, including direction mask.
658 uint8_t bmAttributes
; /**< Endpoint attributes, comprised of a mask of the endpoint type (EP_TYPE_*)
659 * and attributes (ENDPOINT_ATTR_*) masks.
661 uint16_t wMaxPacketSize
; /**< Size of the endpoint bank, in bytes. This indicates the maximum packet size
662 * that the endpoint can receive at a time.
664 uint8_t bInterval
; /**< Polling interval in milliseconds for the endpoint if it is an INTERRUPT or
667 } ATTR_PACKED USB_StdDescriptor_Endpoint_t
;
669 /** \brief Standard USB String Descriptor (LUFA naming conventions).
671 * Type define for a standard string descriptor. Unlike other standard descriptors, the length
672 * of the descriptor for placement in the descriptor header must be determined by the \ref USB_STRING_LEN()
673 * macro rather than by the size of the descriptor structure, as the length is not fixed.
675 * This structure should also be used for string index 0, which contains the supported language IDs for
676 * the device as an array.
678 * This structure uses LUFA-specific element names to make each element's purpose clearer.
680 * \see \ref USB_StdDescriptor_String_t for the version of this type with standard element names.
682 * \note Regardless of CPU architecture, these values should be stored as little endian.
686 USB_Descriptor_Header_t Header
; /**< Descriptor header, including type and size. */
688 #if (((ARCH == ARCH_AVR8) || (ARCH == ARCH_XMEGA)) && !defined(__DOXYGEN__))
689 wchar_t UnicodeString
[];
691 uint16_t UnicodeString
[]; /**< String data, as unicode characters (alternatively,
692 * string language IDs). If normal ASCII characters are
693 * to be used, they must be added as an array of characters
694 * rather than a normal C string so that they are widened to
697 * Under GCC, strings prefixed with the "L" character (before
698 * the opening string quotation mark) are considered to be
699 * Unicode strings, and may be used instead of an explicit
700 * array of ASCII characters on little endian devices with
701 * UTF-16-LE \c wchar_t encoding.
704 } ATTR_PACKED USB_Descriptor_String_t
;
706 /** \brief Standard USB String Descriptor (USB-IF naming conventions).
708 * Type define for a standard string descriptor. Unlike other standard descriptors, the length
709 * of the descriptor for placement in the descriptor header must be determined by the \ref USB_STRING_LEN()
710 * macro rather than by the size of the descriptor structure, as the length is not fixed.
712 * This structure should also be used for string index 0, which contains the supported language IDs for
713 * the device as an array.
715 * This structure uses the relevant standard's given element names to ensure compatibility with the standard.
717 * \see \ref USB_Descriptor_String_t for the version of this type with with non-standard LUFA specific
720 * \note Regardless of CPU architecture, these values should be stored as little endian.
724 uint8_t bLength
; /**< Size of the descriptor, in bytes. */
725 uint8_t bDescriptorType
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t
726 * or a value given by the specific class.
728 uint16_t bString
[]; /**< String data, as unicode characters (alternatively, string language IDs).
729 * If normal ASCII characters are to be used, they must be added as an array
730 * of characters rather than a normal C string so that they are widened to
733 * Under GCC, strings prefixed with the "L" character (before the opening string
734 * quotation mark) are considered to be Unicode strings, and may be used instead
735 * of an explicit array of ASCII characters.
737 } ATTR_PACKED USB_StdDescriptor_String_t
;
739 /* Private Interface - For use in library only: */
740 #if !defined(__DOXYGEN__)
742 #define VERSION_TENS(x) (int)((int)(x) / 10)
743 #define VERSION_ONES(x) (int)((int)(x) % 10)
744 #define VERSION_TENTHS(x) (int)((x - (int)x) * 10)
745 #define VERSION_HUNDREDTHS(x) (int)((x * 100) - ((int)(x * 10) * 10))
748 /* Disable C linkage for C++ Compilers: */
749 #if defined(__cplusplus)