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 major/minor/revision version number into Binary Coded Decimal format for descriptor
89 * fields requiring BCD encoding, such as the USB version number in the standard device descriptor.
91 * \note This value is automatically converted into Little Endian, suitable for direct use inside device
92 * descriptors on all architectures without endianness conversion macros.
94 * \param[in] Major Major version number to encode.
95 * \param[in] Minor Minor version number to encode.
96 * \param[in] Revision Revision version number to encode.
98 #define VERSION_BCD(Major, Minor, Revision) \
99 CPU_TO_LE16( ((Major & 0xFF) << 8) | \
100 ((Minor & 0x0F) << 4) | \
103 /** String language ID for the English language. Should be used in \ref USB_Descriptor_String_t descriptors
104 * to indicate that the English language is supported by the device in its string descriptors.
106 #define LANGUAGE_ID_ENG 0x0409
108 /** \name USB Configuration Descriptor Attribute Masks */
110 /** Mask for the reserved bit in the Configuration Descriptor's \c ConfigAttributes field, which must be set on all
111 * devices for historical purposes.
113 #define USB_CONFIG_ATTR_RESERVED 0x80
115 /** Can be masked with other configuration descriptor attributes for a \ref USB_Descriptor_Configuration_Header_t
116 * descriptor's \c ConfigAttributes value to indicate that the specified configuration can draw its power
117 * from the device's own power source.
119 #define USB_CONFIG_ATTR_SELFPOWERED 0x40
121 /** Can be masked with other configuration descriptor attributes for a \ref USB_Descriptor_Configuration_Header_t
122 * descriptor's \c ConfigAttributes value to indicate that the specified configuration supports the
123 * remote wakeup feature of the USB standard, allowing a suspended USB device to wake up the host upon
126 #define USB_CONFIG_ATTR_REMOTEWAKEUP 0x20
129 /** \name Endpoint Descriptor Attribute Masks */
131 /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
132 * \c Attributes value to indicate that the specified endpoint is not synchronized.
134 * \see The USB specification for more details on the possible Endpoint attributes.
136 #define ENDPOINT_ATTR_NO_SYNC (0 << 2)
138 /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
139 * \c Attributes value to indicate that the specified endpoint is asynchronous.
141 * \see The USB specification for more details on the possible Endpoint attributes.
143 #define ENDPOINT_ATTR_ASYNC (1 << 2)
145 /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
146 * \c Attributes value to indicate that the specified endpoint is adaptive.
148 * \see The USB specification for more details on the possible Endpoint attributes.
150 #define ENDPOINT_ATTR_ADAPTIVE (2 << 2)
152 /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
153 * \c Attributes value to indicate that the specified endpoint is synchronized.
155 * \see The USB specification for more details on the possible Endpoint attributes.
157 #define ENDPOINT_ATTR_SYNC (3 << 2)
160 /** \name Endpoint Descriptor Usage Masks */
162 /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
163 * \c Attributes value to indicate that the specified endpoint is used for data transfers.
165 * \see The USB specification for more details on the possible Endpoint usage attributes.
167 #define ENDPOINT_USAGE_DATA (0 << 4)
169 /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
170 * \c Attributes value to indicate that the specified endpoint is used for feedback.
172 * \see The USB specification for more details on the possible Endpoint usage attributes.
174 #define ENDPOINT_USAGE_FEEDBACK (1 << 4)
176 /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
177 * \c Attributes value to indicate that the specified endpoint is used for implicit feedback.
179 * \see The USB specification for more details on the possible Endpoint usage attributes.
181 #define ENDPOINT_USAGE_IMPLICIT_FEEDBACK (2 << 4)
185 /** Enum for the possible standard descriptor types, as given in each descriptor's header. */
186 enum USB_DescriptorTypes_t
188 DTYPE_Device
= 0x01, /**< Indicates that the descriptor is a device descriptor. */
189 DTYPE_Configuration
= 0x02, /**< Indicates that the descriptor is a configuration descriptor. */
190 DTYPE_String
= 0x03, /**< Indicates that the descriptor is a string descriptor. */
191 DTYPE_Interface
= 0x04, /**< Indicates that the descriptor is an interface descriptor. */
192 DTYPE_Endpoint
= 0x05, /**< Indicates that the descriptor is an endpoint descriptor. */
193 DTYPE_DeviceQualifier
= 0x06, /**< Indicates that the descriptor is a device qualifier descriptor. */
194 DTYPE_Other
= 0x07, /**< Indicates that the descriptor is of other type. */
195 DTYPE_InterfacePower
= 0x08, /**< Indicates that the descriptor is an interface power descriptor. */
196 DTYPE_InterfaceAssociation
= 0x0B, /**< Indicates that the descriptor is an interface association descriptor. */
197 DTYPE_CSInterface
= 0x24, /**< Indicates that the descriptor is a class specific interface descriptor. */
198 DTYPE_CSEndpoint
= 0x25, /**< Indicates that the descriptor is a class specific endpoint descriptor. */
201 /** Enum for possible Class, Subclass and Protocol values of device and interface descriptors. */
202 enum USB_Descriptor_ClassSubclassProtocol_t
204 USB_CSCP_NoDeviceClass
= 0x00, /**< Descriptor Class value indicating that the device does not belong
205 * to a particular class at the device level.
207 USB_CSCP_NoDeviceSubclass
= 0x00, /**< Descriptor Subclass value indicating that the device does not belong
208 * to a particular subclass at the device level.
210 USB_CSCP_NoDeviceProtocol
= 0x00, /**< Descriptor Protocol value indicating that the device does not belong
211 * to a particular protocol at the device level.
213 USB_CSCP_VendorSpecificClass
= 0xFF, /**< Descriptor Class value indicating that the device/interface belongs
214 * to a vendor specific class.
216 USB_CSCP_VendorSpecificSubclass
= 0xFF, /**< Descriptor Subclass value indicating that the device/interface belongs
217 * to a vendor specific subclass.
219 USB_CSCP_VendorSpecificProtocol
= 0xFF, /**< Descriptor Protocol value indicating that the device/interface belongs
220 * to a vendor specific protocol.
222 USB_CSCP_IADDeviceClass
= 0xEF, /**< Descriptor Class value indicating that the device belongs to the
223 * Interface Association Descriptor class.
225 USB_CSCP_IADDeviceSubclass
= 0x02, /**< Descriptor Subclass value indicating that the device belongs to the
226 * Interface Association Descriptor subclass.
228 USB_CSCP_IADDeviceProtocol
= 0x01, /**< Descriptor Protocol value indicating that the device belongs to the
229 * Interface Association Descriptor protocol.
234 /** \brief Standard USB Descriptor Header (LUFA naming conventions).
236 * Type define for all descriptors' standard header, indicating the descriptor's length and type. This structure
237 * uses LUFA-specific element names to make each element's purpose clearer.
239 * \see \ref USB_StdDescriptor_Header_t for the version of this type with standard element names.
241 * \note Regardless of CPU architecture, these values should be stored as little endian.
245 uint8_t Size
; /**< Size of the descriptor, in bytes. */
246 uint8_t Type
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
247 * given by the specific class.
249 } ATTR_PACKED USB_Descriptor_Header_t
;
251 /** \brief Standard USB Descriptor Header (USB-IF naming conventions).
253 * Type define for all descriptors' standard header, indicating the descriptor's length and type. This structure
254 * uses the relevant standard's given element names to ensure compatibility with the standard.
256 * \see \ref USB_Descriptor_Header_t for the version of this type with non-standard LUFA specific element names.
258 * \note Regardless of CPU architecture, these values should be stored as little endian.
262 uint8_t bLength
; /**< Size of the descriptor, in bytes. */
263 uint8_t bDescriptorType
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
264 * given by the specific class.
266 } ATTR_PACKED USB_StdDescriptor_Header_t
;
268 /** \brief Standard USB Device Descriptor (LUFA naming conventions).
270 * Type define for a standard Device Descriptor. This structure uses LUFA-specific element names to make each
271 * element's purpose clearer.
273 * \see \ref USB_StdDescriptor_Device_t for the version of this type with standard element names.
275 * \note Regardless of CPU architecture, these values should be stored as little endian.
279 USB_Descriptor_Header_t Header
; /**< Descriptor header, including type and size. */
281 uint16_t USBSpecification
; /**< BCD of the supported USB specification.
283 * \see \ref VERSION_BCD() utility macro.
285 uint8_t Class
; /**< USB device class. */
286 uint8_t SubClass
; /**< USB device subclass. */
287 uint8_t Protocol
; /**< USB device protocol. */
289 uint8_t Endpoint0Size
; /**< Size of the control (address 0) endpoint's bank in bytes. */
291 uint16_t VendorID
; /**< Vendor ID for the USB product. */
292 uint16_t ProductID
; /**< Unique product ID for the USB product. */
293 uint16_t ReleaseNumber
; /**< Product release (version) number.
295 * \see \ref VERSION_BCD() utility macro.
297 uint8_t ManufacturerStrIndex
; /**< String index for the manufacturer's name. The
298 * host will request this string via a separate
299 * control request for the string descriptor.
301 * \note If no string supplied, use \ref NO_DESCRIPTOR.
303 uint8_t ProductStrIndex
; /**< String index for the product name/details.
305 * \see ManufacturerStrIndex structure entry.
307 uint8_t SerialNumStrIndex
; /**< String index for the product's globally unique hexadecimal
308 * serial number, in uppercase Unicode ASCII.
310 * \note On some microcontroller models, there is an embedded serial number
311 * in the chip which can be used for the device serial number.
312 * To use this serial number, set this to \c USE_INTERNAL_SERIAL.
313 * On unsupported devices, this will evaluate to \ref NO_DESCRIPTOR
314 * and will cause the host to generate a pseudo-unique value for the
315 * device upon insertion.
317 * \see \c ManufacturerStrIndex structure entry.
319 uint8_t NumberOfConfigurations
; /**< Total number of configurations supported by
322 } ATTR_PACKED USB_Descriptor_Device_t
;
324 /** \brief Standard USB Device Descriptor (USB-IF naming conventions).
326 * Type define for a standard Device Descriptor. This structure uses the relevant standard's given element names
327 * to ensure compatibility with the standard.
329 * \see \ref USB_Descriptor_Device_t for the version of this type with non-standard LUFA specific element names.
331 * \note Regardless of CPU architecture, these values should be stored as little endian.
335 uint8_t bLength
; /**< Size of the descriptor, in bytes. */
336 uint8_t bDescriptorType
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
337 * given by the specific class.
339 uint16_t bcdUSB
; /**< BCD of the supported USB specification.
341 * \see \ref VERSION_BCD() utility macro.
343 uint8_t bDeviceClass
; /**< USB device class. */
344 uint8_t bDeviceSubClass
; /**< USB device subclass. */
345 uint8_t bDeviceProtocol
; /**< USB device protocol. */
346 uint8_t bMaxPacketSize0
; /**< Size of the control (address 0) endpoint's bank in bytes. */
347 uint16_t idVendor
; /**< Vendor ID for the USB product. */
348 uint16_t idProduct
; /**< Unique product ID for the USB product. */
349 uint16_t bcdDevice
; /**< Product release (version) number.
351 * \see \ref VERSION_BCD() utility macro.
353 uint8_t iManufacturer
; /**< String index for the manufacturer's name. The
354 * host will request this string via a separate
355 * control request for the string descriptor.
357 * \note If no string supplied, use \ref NO_DESCRIPTOR.
359 uint8_t iProduct
; /**< String index for the product name/details.
361 * \see ManufacturerStrIndex structure entry.
363 uint8_t iSerialNumber
; /**< String index for the product's globally unique hexadecimal
364 * serial number, in uppercase Unicode ASCII.
366 * \note On some microcontroller models, there is an embedded serial number
367 * in the chip which can be used for the device serial number.
368 * To use this serial number, set this to \c USE_INTERNAL_SERIAL.
369 * On unsupported devices, this will evaluate to \ref NO_DESCRIPTOR
370 * and will cause the host to generate a pseudo-unique value for the
371 * device upon insertion.
373 * \see \c ManufacturerStrIndex structure entry.
375 uint8_t bNumConfigurations
; /**< Total number of configurations supported by
378 } ATTR_PACKED USB_StdDescriptor_Device_t
;
380 /** \brief Standard USB Device Qualifier Descriptor (LUFA naming conventions).
382 * Type define for a standard Device Qualifier Descriptor. This structure uses LUFA-specific element names
383 * to make each element's purpose clearer.
385 * \see \ref USB_StdDescriptor_DeviceQualifier_t for the version of this type with standard element names.
389 USB_Descriptor_Header_t Header
; /**< Descriptor header, including type and size. */
391 uint16_t USBSpecification
; /**< BCD of the supported USB specification.
393 * \see \ref VERSION_BCD() utility macro.
395 uint8_t Class
; /**< USB device class. */
396 uint8_t SubClass
; /**< USB device subclass. */
397 uint8_t Protocol
; /**< USB device protocol. */
399 uint8_t Endpoint0Size
; /**< Size of the control (address 0) endpoint's bank in bytes. */
400 uint8_t NumberOfConfigurations
; /**< Total number of configurations supported by
403 uint8_t Reserved
; /**< Reserved for future use, must be 0. */
404 } ATTR_PACKED USB_Descriptor_DeviceQualifier_t
;
406 /** \brief Standard USB Device Qualifier Descriptor (USB-IF naming conventions).
408 * Type define for a standard Device Qualifier Descriptor. This structure uses the relevant standard's given element names
409 * to ensure compatibility with the standard.
411 * \see \ref USB_Descriptor_DeviceQualifier_t for the version of this type with non-standard LUFA specific element names.
415 uint8_t bLength
; /**< Size of the descriptor, in bytes. */
416 uint8_t bDescriptorType
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
417 * given by the specific class.
419 uint16_t bcdUSB
; /**< BCD of the supported USB specification.
421 * \see \ref VERSION_BCD() utility macro.
423 uint8_t bDeviceClass
; /**< USB device class. */
424 uint8_t bDeviceSubClass
; /**< USB device subclass. */
425 uint8_t bDeviceProtocol
; /**< USB device protocol. */
426 uint8_t bMaxPacketSize0
; /**< Size of the control (address 0) endpoint's bank in bytes. */
427 uint8_t bNumConfigurations
; /**< Total number of configurations supported by
430 uint8_t bReserved
; /**< Reserved for future use, must be 0. */
431 } ATTR_PACKED USB_StdDescriptor_DeviceQualifier_t
;
433 /** \brief Standard USB Configuration Descriptor (LUFA naming conventions).
435 * Type define for a standard Configuration Descriptor header. This structure uses LUFA-specific element names
436 * to make each element's purpose clearer.
438 * \see \ref USB_StdDescriptor_Configuration_Header_t for the version of this type with standard element names.
440 * \note Regardless of CPU architecture, these values should be stored as little endian.
444 USB_Descriptor_Header_t Header
; /**< Descriptor header, including type and size. */
446 uint16_t TotalConfigurationSize
; /**< Size of the configuration descriptor header,
447 * and all sub descriptors inside the configuration.
449 uint8_t TotalInterfaces
; /**< Total number of interfaces in the configuration. */
451 uint8_t ConfigurationNumber
; /**< Configuration index of the current configuration. */
452 uint8_t ConfigurationStrIndex
; /**< Index of a string descriptor describing the configuration. */
454 uint8_t ConfigAttributes
; /**< Configuration attributes, comprised of a mask of \c USB_CONFIG_ATTR_* masks.
455 * On all devices, this should include USB_CONFIG_ATTR_RESERVED at a minimum.
458 uint8_t MaxPowerConsumption
; /**< Maximum power consumption of the device while in the
459 * current configuration, calculated by the \ref USB_CONFIG_POWER_MA()
462 } ATTR_PACKED USB_Descriptor_Configuration_Header_t
;
464 /** \brief Standard USB Configuration Descriptor (USB-IF naming conventions).
466 * Type define for a standard Configuration Descriptor header. This structure uses the relevant standard's given element names
467 * to ensure compatibility with the standard.
469 * \see \ref USB_Descriptor_Device_t for the version of this type with non-standard LUFA specific element names.
471 * \note Regardless of CPU architecture, these values should be stored as little endian.
475 uint8_t bLength
; /**< Size of the descriptor, in bytes. */
476 uint8_t bDescriptorType
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
477 * given by the specific class.
479 uint16_t wTotalLength
; /**< Size of the configuration descriptor header,
480 * and all sub descriptors inside the configuration.
482 uint8_t bNumInterfaces
; /**< Total number of interfaces in the configuration. */
483 uint8_t bConfigurationValue
; /**< Configuration index of the current configuration. */
484 uint8_t iConfiguration
; /**< Index of a string descriptor describing the configuration. */
485 uint8_t bmAttributes
; /**< Configuration attributes, comprised of a mask of \c USB_CONFIG_ATTR_* masks.
486 * On all devices, this should include USB_CONFIG_ATTR_RESERVED at a minimum.
488 uint8_t bMaxPower
; /**< Maximum power consumption of the device while in the
489 * current configuration, calculated by the \ref USB_CONFIG_POWER_MA()
492 } ATTR_PACKED USB_StdDescriptor_Configuration_Header_t
;
494 /** \brief Standard USB Interface Descriptor (LUFA naming conventions).
496 * Type define for a standard Interface Descriptor. This structure uses LUFA-specific element names
497 * to make each element's purpose clearer.
499 * \see \ref USB_StdDescriptor_Interface_t for the version of this type with standard element names.
501 * \note Regardless of CPU architecture, these values should be stored as little endian.
505 USB_Descriptor_Header_t Header
; /**< Descriptor header, including type and size. */
507 uint8_t InterfaceNumber
; /**< Index of the interface in the current configuration. */
508 uint8_t AlternateSetting
; /**< Alternate setting for the interface number. The same
509 * interface number can have multiple alternate settings
510 * with different endpoint configurations, which can be
511 * selected by the host.
513 uint8_t TotalEndpoints
; /**< Total number of endpoints in the interface. */
515 uint8_t Class
; /**< Interface class ID. */
516 uint8_t SubClass
; /**< Interface subclass ID. */
517 uint8_t Protocol
; /**< Interface protocol ID. */
519 uint8_t InterfaceStrIndex
; /**< Index of the string descriptor describing the interface. */
520 } ATTR_PACKED USB_Descriptor_Interface_t
;
522 /** \brief Standard USB Interface Descriptor (USB-IF naming conventions).
524 * Type define for a standard Interface Descriptor. This structure uses the relevant standard's given element names
525 * to ensure compatibility with the standard.
527 * \see \ref USB_Descriptor_Interface_t for the version of this type with non-standard LUFA specific element names.
529 * \note Regardless of CPU architecture, these values should be stored as little endian.
533 uint8_t bLength
; /**< Size of the descriptor, in bytes. */
534 uint8_t bDescriptorType
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
535 * given by the specific class.
537 uint8_t bInterfaceNumber
; /**< Index of the interface in the current configuration. */
538 uint8_t bAlternateSetting
; /**< Alternate setting for the interface number. The same
539 * interface number can have multiple alternate settings
540 * with different endpoint configurations, which can be
541 * selected by the host.
543 uint8_t bNumEndpoints
; /**< Total number of endpoints in the interface. */
544 uint8_t bInterfaceClass
; /**< Interface class ID. */
545 uint8_t bInterfaceSubClass
; /**< Interface subclass ID. */
546 uint8_t bInterfaceProtocol
; /**< Interface protocol ID. */
547 uint8_t iInterface
; /**< Index of the string descriptor describing the
550 } ATTR_PACKED USB_StdDescriptor_Interface_t
;
552 /** \brief Standard USB Interface Association Descriptor (LUFA naming conventions).
554 * Type define for a standard Interface Association Descriptor. This structure uses LUFA-specific element names
555 * to make each element's purpose clearer.
557 * This descriptor has been added as a supplement to the USB2.0 standard, in the ECN located at
558 * <a>http://www.usb.org/developers/docs/InterfaceAssociationDescriptor_ecn.pdf</a>. It allows composite
559 * devices with multiple interfaces related to the same function to have the multiple interfaces bound
560 * together at the point of enumeration, loading one generic driver for all the interfaces in the single
561 * function. Read the ECN for more information.
563 * \see \ref USB_StdDescriptor_Interface_Association_t for the version of this type with standard element names.
565 * \note Regardless of CPU architecture, these values should be stored as little endian.
569 USB_Descriptor_Header_t Header
; /**< Descriptor header, including type and size. */
571 uint8_t FirstInterfaceIndex
; /**< Index of the first associated interface. */
572 uint8_t TotalInterfaces
; /**< Total number of associated interfaces. */
574 uint8_t Class
; /**< Interface class ID. */
575 uint8_t SubClass
; /**< Interface subclass ID. */
576 uint8_t Protocol
; /**< Interface protocol ID. */
578 uint8_t IADStrIndex
; /**< Index of the string descriptor describing the
579 * interface association.
581 } ATTR_PACKED USB_Descriptor_Interface_Association_t
;
583 /** \brief Standard USB Interface Association Descriptor (USB-IF naming conventions).
585 * Type define for a standard Interface Association Descriptor. This structure uses the relevant standard's given
586 * element names to ensure compatibility with the standard.
588 * This descriptor has been added as a supplement to the USB2.0 standard, in the ECN located at
589 * <a>http://www.usb.org/developers/docs/InterfaceAssociationDescriptor_ecn.pdf</a>. It allows composite
590 * devices with multiple interfaces related to the same function to have the multiple interfaces bound
591 * together at the point of enumeration, loading one generic driver for all the interfaces in the single
592 * function. Read the ECN for more information.
594 * \see \ref USB_Descriptor_Interface_Association_t for the version of this type with non-standard LUFA specific
597 * \note Regardless of CPU architecture, these values should be stored as little endian.
601 uint8_t bLength
; /**< Size of the descriptor, in bytes. */
602 uint8_t bDescriptorType
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
603 * given by the specific class.
605 uint8_t bFirstInterface
; /**< Index of the first associated interface. */
606 uint8_t bInterfaceCount
; /**< Total number of associated interfaces. */
607 uint8_t bFunctionClass
; /**< Interface class ID. */
608 uint8_t bFunctionSubClass
; /**< Interface subclass ID. */
609 uint8_t bFunctionProtocol
; /**< Interface protocol ID. */
610 uint8_t iFunction
; /**< Index of the string descriptor describing the
611 * interface association.
613 } ATTR_PACKED USB_StdDescriptor_Interface_Association_t
;
615 /** \brief Standard USB Endpoint Descriptor (LUFA naming conventions).
617 * Type define for a standard Endpoint Descriptor. This structure uses LUFA-specific element names
618 * to make each element's purpose clearer.
620 * \see \ref USB_StdDescriptor_Endpoint_t for the version of this type with standard element names.
622 * \note Regardless of CPU architecture, these values should be stored as little endian.
626 USB_Descriptor_Header_t Header
; /**< Descriptor header, including type and size. */
628 uint8_t EndpointAddress
; /**< Logical address of the endpoint within the device for the current
629 * configuration, including direction mask.
631 uint8_t Attributes
; /**< Endpoint attributes, comprised of a mask of the endpoint type (EP_TYPE_*)
632 * and attributes (ENDPOINT_ATTR_*) masks.
634 uint16_t EndpointSize
; /**< Size of the endpoint bank, in bytes. This indicates the maximum packet
635 * size that the endpoint can receive at a time.
637 uint8_t PollingIntervalMS
; /**< Polling interval in milliseconds for the endpoint if it is an INTERRUPT
638 * or ISOCHRONOUS type.
640 } ATTR_PACKED USB_Descriptor_Endpoint_t
;
642 /** \brief Standard USB Endpoint Descriptor (USB-IF naming conventions).
644 * Type define for a standard Endpoint Descriptor. This structure uses the relevant standard's given
645 * element names to ensure compatibility with the standard.
647 * \see \ref USB_Descriptor_Endpoint_t for the version of this type with non-standard LUFA specific
650 * \note Regardless of CPU architecture, these values should be stored as little endian.
654 uint8_t bLength
; /**< Size of the descriptor, in bytes. */
655 uint8_t bDescriptorType
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a
656 * value given by the specific class.
658 uint8_t bEndpointAddress
; /**< Logical address of the endpoint within the device for the current
659 * configuration, including direction mask.
661 uint8_t bmAttributes
; /**< Endpoint attributes, comprised of a mask of the endpoint type (EP_TYPE_*)
662 * and attributes (ENDPOINT_ATTR_*) masks.
664 uint16_t wMaxPacketSize
; /**< Size of the endpoint bank, in bytes. This indicates the maximum packet size
665 * that the endpoint can receive at a time.
667 uint8_t bInterval
; /**< Polling interval in milliseconds for the endpoint if it is an INTERRUPT or
670 } ATTR_PACKED USB_StdDescriptor_Endpoint_t
;
672 /** \brief Standard USB String Descriptor (LUFA naming conventions).
674 * Type define for a standard string descriptor. Unlike other standard descriptors, the length
675 * of the descriptor for placement in the descriptor header must be determined by the \ref USB_STRING_LEN()
676 * macro rather than by the size of the descriptor structure, as the length is not fixed.
678 * This structure should also be used for string index 0, which contains the supported language IDs for
679 * the device as an array.
681 * This structure uses LUFA-specific element names to make each element's purpose clearer.
683 * \see \ref USB_StdDescriptor_String_t for the version of this type with standard element names.
685 * \note Regardless of CPU architecture, these values should be stored as little endian.
689 USB_Descriptor_Header_t Header
; /**< Descriptor header, including type and size. */
691 #if (((ARCH == ARCH_AVR8) || (ARCH == ARCH_XMEGA)) && !defined(__DOXYGEN__))
692 wchar_t UnicodeString
[];
694 uint16_t UnicodeString
[]; /**< String data, as unicode characters (alternatively,
695 * string language IDs). If normal ASCII characters are
696 * to be used, they must be added as an array of characters
697 * rather than a normal C string so that they are widened to
700 * Under GCC, strings prefixed with the "L" character (before
701 * the opening string quotation mark) are considered to be
702 * Unicode strings, and may be used instead of an explicit
703 * array of ASCII characters on little endian devices with
704 * UTF-16-LE \c wchar_t encoding.
707 } ATTR_PACKED USB_Descriptor_String_t
;
709 /** \brief Standard USB String Descriptor (USB-IF naming conventions).
711 * Type define for a standard string descriptor. Unlike other standard descriptors, the length
712 * of the descriptor for placement in the descriptor header must be determined by the \ref USB_STRING_LEN()
713 * macro rather than by the size of the descriptor structure, as the length is not fixed.
715 * This structure should also be used for string index 0, which contains the supported language IDs for
716 * the device as an array.
718 * This structure uses the relevant standard's given element names to ensure compatibility with the standard.
720 * \see \ref USB_Descriptor_String_t for the version of this type with with non-standard LUFA specific
723 * \note Regardless of CPU architecture, these values should be stored as little endian.
727 uint8_t bLength
; /**< Size of the descriptor, in bytes. */
728 uint8_t bDescriptorType
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t
729 * or a value given by the specific class.
731 uint16_t bString
[]; /**< String data, as unicode characters (alternatively, string language IDs).
732 * If normal ASCII characters are to be used, they must be added as an array
733 * of characters rather than a normal C string so that they are widened to
736 * Under GCC, strings prefixed with the "L" character (before the opening string
737 * quotation mark) are considered to be Unicode strings, and may be used instead
738 * of an explicit array of ASCII characters.
740 } ATTR_PACKED USB_StdDescriptor_String_t
;
743 /* Disable C linkage for C++ Compilers: */
744 #if defined(__cplusplus)