3 Copyright (C) Dean Camera, 2011.
5 dean [at] fourwalledcubicle [dot] com
10 Copyright 2011 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 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
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) << 4) | VERSION_ONES(x)) << 8) | \
98 ((VERSION_TENTHS(x) << 4) | VERSION_HUNDREDTHS(x)))
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 /** Can be masked with other configuration descriptor attributes for a \ref USB_Descriptor_Configuration_Header_t
108 * descriptor's ConfigAttributes value to indicate that the specified configuration can draw its power
109 * from the host's VBUS line.
111 #define USB_CONFIG_ATTR_BUSPOWERED 0x80
113 /** Can be masked with other configuration descriptor attributes for a \ref USB_Descriptor_Configuration_Header_t
114 * descriptor's ConfigAttributes value to indicate that the specified configuration can draw its power
115 * from the device's own power source.
117 #define USB_CONFIG_ATTR_SELFPOWERED 0x40
119 /** Can be masked with other configuration descriptor attributes for a \ref USB_Descriptor_Configuration_Header_t
120 * descriptor's ConfigAttributes value to indicate that the specified configuration supports the
121 * remote wakeup feature of the USB standard, allowing a suspended USB device to wake up the host upon
124 #define USB_CONFIG_ATTR_REMOTEWAKEUP 0x20
127 /** \name Endpoint Descriptor Attribute Masks */
129 /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
130 * Attributes value to indicate that the specified endpoint is not synchronized.
132 * \see The USB specification for more details on the possible Endpoint attributes.
134 #define ENDPOINT_ATTR_NO_SYNC (0 << 2)
136 /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
137 * Attributes value to indicate that the specified endpoint is asynchronous.
139 * \see The USB specification for more details on the possible Endpoint attributes.
141 #define ENDPOINT_ATTR_ASYNC (1 << 2)
143 /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
144 * Attributes value to indicate that the specified endpoint is adaptive.
146 * \see The USB specification for more details on the possible Endpoint attributes.
148 #define ENDPOINT_ATTR_ADAPTIVE (2 << 2)
150 /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
151 * Attributes value to indicate that the specified endpoint is synchronized.
153 * \see The USB specification for more details on the possible Endpoint attributes.
155 #define ENDPOINT_ATTR_SYNC (3 << 2)
158 /** \name Endpoint Descriptor Usage Masks */
160 /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
161 * Attributes value to indicate that the specified endpoint is used for data transfers.
163 * \see The USB specification for more details on the possible Endpoint usage attributes.
165 #define ENDPOINT_USAGE_DATA (0 << 4)
167 /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
168 * Attributes value to indicate that the specified endpoint is used for feedback.
170 * \see The USB specification for more details on the possible Endpoint usage attributes.
172 #define ENDPOINT_USAGE_FEEDBACK (1 << 4)
174 /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
175 * Attributes value to indicate that the specified endpoint is used for implicit feedback.
177 * \see The USB specification for more details on the possible Endpoint usage attributes.
179 #define ENDPOINT_USAGE_IMPLICIT_FEEDBACK (2 << 4)
183 /** Enum for the possible standard descriptor types, as given in each descriptor's header. */
184 enum USB_DescriptorTypes_t
186 DTYPE_Device
= 0x01, /**< Indicates that the descriptor is a device descriptor. */
187 DTYPE_Configuration
= 0x02, /**< Indicates that the descriptor is a configuration descriptor. */
188 DTYPE_String
= 0x03, /**< Indicates that the descriptor is a string descriptor. */
189 DTYPE_Interface
= 0x04, /**< Indicates that the descriptor is an interface descriptor. */
190 DTYPE_Endpoint
= 0x05, /**< Indicates that the descriptor is an endpoint descriptor. */
191 DTYPE_DeviceQualifier
= 0x06, /**< Indicates that the descriptor is a device qualifier descriptor. */
192 DTYPE_Other
= 0x07, /**< Indicates that the descriptor is of other type. */
193 DTYPE_InterfacePower
= 0x08, /**< Indicates that the descriptor is an interface power descriptor. */
194 DTYPE_InterfaceAssociation
= 0x0B, /**< Indicates that the descriptor is an interface association descriptor. */
195 DTYPE_CSInterface
= 0x24, /**< Indicates that the descriptor is a class specific interface descriptor. */
196 DTYPE_CSEndpoint
= 0x25, /**< Indicates that the descriptor is a class specific endpoint descriptor. */
199 /** Enum for possible Class, Subclass and Protocol values of device and interface descriptors. */
200 enum USB_Descriptor_ClassSubclassProtocol_t
202 USB_CSCP_NoDeviceClass
= 0x00, /**< Descriptor Class value indicating that the device does not belong
203 * to a particular class at the device level.
205 USB_CSCP_NoDeviceSubclass
= 0x00, /**< Descriptor Subclass value indicating that the device does not belong
206 * to a particular subclass at the device level.
208 USB_CSCP_NoDeviceProtocol
= 0x00, /**< Descriptor Protocol value indicating that the device does not belong
209 * to a particular protocol at the device level.
211 USB_CSCP_VendorSpecificClass
= 0xFF, /**< Descriptor Class value indicating that the device/interface belongs
212 * to a vendor specific class.
214 USB_CSCP_VendorSpecificSubclass
= 0xFF, /**< Descriptor Subclass value indicating that the device/interface belongs
215 * to a vendor specific subclass.
217 USB_CSCP_VendorSpecificProtocol
= 0xFF, /**< Descriptor Protocol value indicating that the device/interface belongs
218 * to a vendor specific protocol.
220 USB_CSCP_IADDeviceClass
= 0xEF, /**< Descriptor Class value indicating that the device belongs to the
221 * Interface Association Descriptor class.
223 USB_CSCP_IADDeviceSubclass
= 0x02, /**< Descriptor Subclass value indicating that the device belongs to the
224 * Interface Association Descriptor subclass.
226 USB_CSCP_IADDeviceProtocol
= 0x01, /**< Descriptor Protocol value indicating that the device belongs to the
227 * Interface Association Descriptor protocol.
232 /** \brief Standard USB Descriptor Header (LUFA naming conventions).
234 * Type define for all descriptors' standard header, indicating the descriptor's length and type. This structure
235 * uses LUFA-specific element names to make each element's purpose clearer.
237 * \see \ref USB_StdDescriptor_Header_t for the version of this type with standard element names.
239 * \note Regardless of CPU architecture, these values should be stored as little endian.
243 uint8_t Size
; /**< Size of the descriptor, in bytes. */
244 uint8_t Type
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
245 * given by the specific class.
247 } ATTR_PACKED USB_Descriptor_Header_t
;
249 /** \brief Standard USB Descriptor Header (USB-IF naming conventions).
251 * Type define for all descriptors' standard header, indicating the descriptor's length and type. This structure
252 * uses the relevant standard's given element names to ensure compatibility with the standard.
254 * \see \ref USB_Descriptor_Header_t for the version of this type with non-standard LUFA specific element names.
256 * \note Regardless of CPU architecture, these values should be stored as little endian.
260 uint8_t bLength
; /**< Size of the descriptor, in bytes. */
261 uint8_t bDescriptorType
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
262 * given by the specific class.
264 } ATTR_PACKED USB_StdDescriptor_Header_t
;
266 /** \brief Standard USB Device Descriptor (LUFA naming conventions).
268 * Type define for a standard Device Descriptor. This structure uses LUFA-specific element names to make each
269 * element's purpose clearer.
271 * \see \ref USB_StdDescriptor_Device_t for the version of this type with standard element names.
273 * \note Regardless of CPU architecture, these values should be stored as little endian.
277 USB_Descriptor_Header_t Header
; /**< Descriptor header, including type and size. */
279 uint16_t USBSpecification
; /**< BCD of the supported USB specification. */
280 uint8_t Class
; /**< USB device class. */
281 uint8_t SubClass
; /**< USB device subclass. */
282 uint8_t Protocol
; /**< USB device protocol. */
284 uint8_t Endpoint0Size
; /**< Size of the control (address 0) endpoint's bank in bytes. */
286 uint16_t VendorID
; /**< Vendor ID for the USB product. */
287 uint16_t ProductID
; /**< Unique product ID for the USB product. */
288 uint16_t ReleaseNumber
; /**< Product release (version) number. */
290 uint8_t ManufacturerStrIndex
; /**< String index for the manufacturer's name. The
291 * host will request this string via a separate
292 * control request for the string descriptor.
294 * \note If no string supplied, use \ref NO_DESCRIPTOR.
296 uint8_t ProductStrIndex
; /**< String index for the product name/details.
298 * \see ManufacturerStrIndex structure entry.
300 uint8_t SerialNumStrIndex
; /**< String index for the product's globally unique hexadecimal
301 * serial number, in uppercase Unicode ASCII.
303 * \note On some microcontroller models, there is an embedded serial number
304 * in the chip which can be used for the device serial number.
305 * To use this serial number, set this to USE_INTERNAL_SERIAL.
306 * On unsupported devices, this will evaluate to 0 and will cause
307 * the host to generate a pseudo-unique value for the device upon
310 * \see ManufacturerStrIndex structure entry.
312 uint8_t NumberOfConfigurations
; /**< Total number of configurations supported by
315 } ATTR_PACKED USB_Descriptor_Device_t
;
317 /** \brief Standard USB Device Descriptor (USB-IF naming conventions).
319 * Type define for a standard Device Descriptor. This structure uses the relevant standard's given element names
320 * to ensure compatibility with the standard.
322 * \see \ref USB_Descriptor_Device_t for the version of this type with non-standard LUFA specific element names.
324 * \note Regardless of CPU architecture, these values should be stored as little endian.
328 uint8_t bLength
; /**< Size of the descriptor, in bytes. */
329 uint8_t bDescriptorType
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
330 * given by the specific class.
332 uint16_t bcdUSB
; /**< BCD of the supported USB specification. */
333 uint8_t bDeviceClass
; /**< USB device class. */
334 uint8_t bDeviceSubClass
; /**< USB device subclass. */
335 uint8_t bDeviceProtocol
; /**< USB device protocol. */
336 uint8_t bMaxPacketSize0
; /**< Size of the control (address 0) endpoint's bank in bytes. */
337 uint16_t idVendor
; /**< Vendor ID for the USB product. */
338 uint16_t idProduct
; /**< Unique product ID for the USB product. */
339 uint16_t bcdDevice
; /**< Product release (version) number. */
340 uint8_t iManufacturer
; /**< String index for the manufacturer's name. The
341 * host will request this string via a separate
342 * control request for the string descriptor.
344 * \note If no string supplied, use \ref NO_DESCRIPTOR.
346 uint8_t iProduct
; /**< String index for the product name/details.
348 * \see ManufacturerStrIndex structure entry.
350 uint8_t iSerialNumber
; /**< String index for the product's globally unique hexadecimal
351 * serial number, in uppercase Unicode ASCII.
353 * \note On some microcontroller models, there is an embedded serial number
354 * in the chip which can be used for the device serial number.
355 * To use this serial number, set this to USE_INTERNAL_SERIAL.
356 * On unsupported devices, this will evaluate to 0 and will cause
357 * the host to generate a pseudo-unique value for the device upon
360 * \see ManufacturerStrIndex structure entry.
362 uint8_t bNumConfigurations
; /**< Total number of configurations supported by
365 } ATTR_PACKED USB_StdDescriptor_Device_t
;
367 /** \brief Standard USB Device Qualifier Descriptor (LUFA naming conventions).
369 * Type define for a standard Device Qualifier Descriptor. This structure uses LUFA-specific element names
370 * to make each element's purpose clearer.
372 * \see \ref USB_StdDescriptor_DeviceQualifier_t for the version of this type with standard element names.
376 USB_Descriptor_Header_t Header
; /**< Descriptor header, including type and size. */
378 uint16_t USBSpecification
; /**< BCD of the supported USB specification. */
379 uint8_t Class
; /**< USB device class. */
380 uint8_t SubClass
; /**< USB device subclass. */
381 uint8_t Protocol
; /**< USB device protocol. */
383 uint8_t Endpoint0Size
; /**< Size of the control (address 0) endpoint's bank in bytes. */
384 uint8_t NumberOfConfigurations
; /**< Total number of configurations supported by
387 uint8_t Reserved
; /**< Reserved for future use, must be 0. */
388 } ATTR_PACKED USB_Descriptor_DeviceQualifier_t
;
390 /** \brief Standard USB Device Qualifier Descriptor (USB-IF naming conventions).
392 * Type define for a standard Device Qualifier Descriptor. This structure uses the relevant standard's given element names
393 * to ensure compatibility with the standard.
395 * \see \ref USB_Descriptor_DeviceQualifier_t for the version of this type with non-standard LUFA specific element names.
399 uint8_t bLength
; /**< Size of the descriptor, in bytes. */
400 uint8_t bDescriptorType
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
401 * given by the specific class.
403 uint16_t bcdUSB
; /**< BCD of the supported USB specification. */
404 uint8_t bDeviceClass
; /**< USB device class. */
405 uint8_t bDeviceSubClass
; /**< USB device subclass. */
406 uint8_t bDeviceProtocol
; /**< USB device protocol. */
407 uint8_t bMaxPacketSize0
; /**< Size of the control (address 0) endpoint's bank in bytes. */
408 uint8_t bNumConfigurations
; /**< Total number of configurations supported by
411 uint8_t bReserved
; /**< Reserved for future use, must be 0. */
412 } ATTR_PACKED USB_StdDescriptor_DeviceQualifier_t
;
414 /** \brief Standard USB Configuration Descriptor (LUFA naming conventions).
416 * Type define for a standard Configuration Descriptor header. This structure uses LUFA-specific element names
417 * to make each element's purpose clearer.
419 * \see \ref USB_StdDescriptor_Configuration_Header_t for the version of this type with standard element names.
421 * \note Regardless of CPU architecture, these values should be stored as little endian.
425 USB_Descriptor_Header_t Header
; /**< Descriptor header, including type and size. */
427 uint16_t TotalConfigurationSize
; /**< Size of the configuration descriptor header,
428 * and all sub descriptors inside the configuration.
430 uint8_t TotalInterfaces
; /**< Total number of interfaces in the configuration. */
432 uint8_t ConfigurationNumber
; /**< Configuration index of the current configuration. */
433 uint8_t ConfigurationStrIndex
; /**< Index of a string descriptor describing the configuration. */
435 uint8_t ConfigAttributes
; /**< Configuration attributes, comprised of a mask of zero or
436 * more USB_CONFIG_ATTR_* masks.
439 uint8_t MaxPowerConsumption
; /**< Maximum power consumption of the device while in the
440 * current configuration, calculated by the \ref USB_CONFIG_POWER_MA()
443 } ATTR_PACKED USB_Descriptor_Configuration_Header_t
;
445 /** \brief Standard USB Configuration Descriptor (USB-IF naming conventions).
447 * Type define for a standard Configuration Descriptor header. This structure uses the relevant standard's given element names
448 * to ensure compatibility with the standard.
450 * \see \ref USB_Descriptor_Device_t for the version of this type with non-standard LUFA specific element names.
452 * \note Regardless of CPU architecture, these values should be stored as little endian.
456 uint8_t bLength
; /**< Size of the descriptor, in bytes. */
457 uint8_t bDescriptorType
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
458 * given by the specific class.
460 uint16_t wTotalLength
; /**< Size of the configuration descriptor header,
461 * and all sub descriptors inside the configuration.
463 uint8_t bNumInterfaces
; /**< Total number of interfaces in the configuration. */
464 uint8_t bConfigurationValue
; /**< Configuration index of the current configuration. */
465 uint8_t iConfiguration
; /**< Index of a string descriptor describing the configuration. */
466 uint8_t bmAttributes
; /**< Configuration attributes, comprised of a mask of zero or
467 * more USB_CONFIG_ATTR_* masks.
469 uint8_t bMaxPower
; /**< Maximum power consumption of the device while in the
470 * current configuration, calculated by the \ref USB_CONFIG_POWER_MA()
473 } ATTR_PACKED USB_StdDescriptor_Configuration_Header_t
;
475 /** \brief Standard USB Interface Descriptor (LUFA naming conventions).
477 * Type define for a standard Interface Descriptor. This structure uses LUFA-specific element names
478 * to make each element's purpose clearer.
480 * \see \ref USB_StdDescriptor_Interface_t for the version of this type with standard element names.
482 * \note Regardless of CPU architecture, these values should be stored as little endian.
486 USB_Descriptor_Header_t Header
; /**< Descriptor header, including type and size. */
488 uint8_t InterfaceNumber
; /**< Index of the interface in the current configuration. */
489 uint8_t AlternateSetting
; /**< Alternate setting for the interface number. The same
490 * interface number can have multiple alternate settings
491 * with different endpoint configurations, which can be
492 * selected by the host.
494 uint8_t TotalEndpoints
; /**< Total number of endpoints in the interface. */
496 uint8_t Class
; /**< Interface class ID. */
497 uint8_t SubClass
; /**< Interface subclass ID. */
498 uint8_t Protocol
; /**< Interface protocol ID. */
500 uint8_t InterfaceStrIndex
; /**< Index of the string descriptor describing the interface. */
501 } ATTR_PACKED USB_Descriptor_Interface_t
;
503 /** \brief Standard USB Interface Descriptor (USB-IF naming conventions).
505 * Type define for a standard Interface Descriptor. This structure uses the relevant standard's given element names
506 * to ensure compatibility with the standard.
508 * \see \ref USB_Descriptor_Interface_t for the version of this type with non-standard LUFA specific element names.
510 * \note Regardless of CPU architecture, these values should be stored as little endian.
514 uint8_t bLength
; /**< Size of the descriptor, in bytes. */
515 uint8_t bDescriptorType
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
516 * given by the specific class.
518 uint8_t bInterfaceNumber
; /**< Index of the interface in the current configuration. */
519 uint8_t bAlternateSetting
; /**< Alternate setting for the interface number. The same
520 * interface number can have multiple alternate settings
521 * with different endpoint configurations, which can be
522 * selected by the host.
524 uint8_t bNumEndpoints
; /**< Total number of endpoints in the interface. */
525 uint8_t bInterfaceClass
; /**< Interface class ID. */
526 uint8_t bInterfaceSubClass
; /**< Interface subclass ID. */
527 uint8_t bInterfaceProtocol
; /**< Interface protocol ID. */
528 uint8_t iInterface
; /**< Index of the string descriptor describing the
531 } ATTR_PACKED USB_StdDescriptor_Interface_t
;
533 /** \brief Standard USB Interface Association Descriptor (LUFA naming conventions).
535 * Type define for a standard Interface Association Descriptor. This structure uses LUFA-specific element names
536 * to make each element's purpose clearer.
538 * This descriptor has been added as a supplement to the USB2.0 standard, in the ECN located at
539 * <a>http://www.usb.org/developers/docs/InterfaceAssociationDescriptor_ecn.pdf</a>. It allows composite
540 * devices with multiple interfaces related to the same function to have the multiple interfaces bound
541 * together at the point of enumeration, loading one generic driver for all the interfaces in the single
542 * function. Read the ECN for more information.
544 * \see \ref USB_StdDescriptor_Interface_Association_t for the version of this type with standard element names.
546 * \note Regardless of CPU architecture, these values should be stored as little endian.
550 USB_Descriptor_Header_t Header
; /**< Descriptor header, including type and size. */
552 uint8_t FirstInterfaceIndex
; /**< Index of the first associated interface. */
553 uint8_t TotalInterfaces
; /**< Total number of associated interfaces. */
555 uint8_t Class
; /**< Interface class ID. */
556 uint8_t SubClass
; /**< Interface subclass ID. */
557 uint8_t Protocol
; /**< Interface protocol ID. */
559 uint8_t IADStrIndex
; /**< Index of the string descriptor describing the
560 * interface association.
562 } ATTR_PACKED USB_Descriptor_Interface_Association_t
;
564 /** \brief Standard USB Interface Association Descriptor (USB-IF naming conventions).
566 * Type define for a standard Interface Association Descriptor. This structure uses the relevant standard's given
567 * element names to ensure compatibility with the standard.
569 * This descriptor has been added as a supplement to the USB2.0 standard, in the ECN located at
570 * <a>http://www.usb.org/developers/docs/InterfaceAssociationDescriptor_ecn.pdf</a>. It allows composite
571 * devices with multiple interfaces related to the same function to have the multiple interfaces bound
572 * together at the point of enumeration, loading one generic driver for all the interfaces in the single
573 * function. Read the ECN for more information.
575 * \see \ref USB_Descriptor_Interface_Association_t for the version of this type with non-standard LUFA specific
578 * \note Regardless of CPU architecture, these values should be stored as little endian.
582 uint8_t bLength
; /**< Size of the descriptor, in bytes. */
583 uint8_t bDescriptorType
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
584 * given by the specific class.
586 uint8_t bFirstInterface
; /**< Index of the first associated interface. */
587 uint8_t bInterfaceCount
; /**< Total number of associated interfaces. */
588 uint8_t bFunctionClass
; /**< Interface class ID. */
589 uint8_t bFunctionSubClass
; /**< Interface subclass ID. */
590 uint8_t bFunctionProtocol
; /**< Interface protocol ID. */
591 uint8_t iFunction
; /**< Index of the string descriptor describing the
592 * interface association.
594 } ATTR_PACKED USB_StdDescriptor_Interface_Association_t
;
596 /** \brief Standard USB Endpoint Descriptor (LUFA naming conventions).
598 * Type define for a standard Endpoint Descriptor. This structure uses LUFA-specific element names
599 * to make each element's purpose clearer.
601 * \see \ref USB_StdDescriptor_Endpoint_t for the version of this type with standard element names.
603 * \note Regardless of CPU architecture, these values should be stored as little endian.
607 USB_Descriptor_Header_t Header
; /**< Descriptor header, including type and size. */
609 uint8_t EndpointAddress
; /**< Logical address of the endpoint within the device for the current
610 * configuration, including direction mask.
612 uint8_t Attributes
; /**< Endpoint attributes, comprised of a mask of the endpoint type (EP_TYPE_*)
613 * and attributes (ENDPOINT_ATTR_*) masks.
615 uint16_t EndpointSize
; /**< Size of the endpoint bank, in bytes. This indicates the maximum packet
616 * size that the endpoint can receive at a time.
618 uint8_t PollingIntervalMS
; /**< Polling interval in milliseconds for the endpoint if it is an INTERRUPT
619 * or ISOCHRONOUS type.
621 } ATTR_PACKED USB_Descriptor_Endpoint_t
;
623 /** \brief Standard USB Endpoint Descriptor (USB-IF naming conventions).
625 * Type define for a standard Endpoint Descriptor. This structure uses the relevant standard's given
626 * element names to ensure compatibility with the standard.
628 * \see \ref USB_Descriptor_Endpoint_t for the version of this type with non-standard LUFA specific
631 * \note Regardless of CPU architecture, these values should be stored as little endian.
635 uint8_t bLength
; /**< Size of the descriptor, in bytes. */
636 uint8_t bDescriptorType
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a
637 * value given by the specific class.
639 uint8_t bEndpointAddress
; /**< Logical address of the endpoint within the device for the current
640 * configuration, including direction mask.
642 uint8_t bmAttributes
; /**< Endpoint attributes, comprised of a mask of the endpoint type (EP_TYPE_*)
643 * and attributes (ENDPOINT_ATTR_*) masks.
645 uint16_t wMaxPacketSize
; /**< Size of the endpoint bank, in bytes. This indicates the maximum packet size
646 * that the endpoint can receive at a time.
648 uint8_t bInterval
; /**< Polling interval in milliseconds for the endpoint if it is an INTERRUPT or
651 } ATTR_PACKED USB_StdDescriptor_Endpoint_t
;
653 /** \brief Standard USB String Descriptor (LUFA naming conventions).
655 * Type define for a standard string descriptor. Unlike other standard descriptors, the length
656 * of the descriptor for placement in the descriptor header must be determined by the \ref USB_STRING_LEN()
657 * macro rather than by the size of the descriptor structure, as the length is not fixed.
659 * This structure should also be used for string index 0, which contains the supported language IDs for
660 * the device as an array.
662 * This structure uses LUFA-specific element names to make each element's purpose clearer.
664 * \see \ref USB_StdDescriptor_String_t for the version of this type with standard element names.
666 * \note Regardless of CPU architecture, these values should be stored as little endian.
670 USB_Descriptor_Header_t Header
; /**< Descriptor header, including type and size. */
672 #if ((ARCH == ARCH_AVR8) || (ARCH == ARCH_XMEGA))
673 wchar_t UnicodeString
[];
675 uint16_t UnicodeString
[]; /**< String data, as unicode characters (alternatively,
676 * string language IDs). If normal ASCII characters are
677 * to be used, they must be added as an array of characters
678 * rather than a normal C string so that they are widened to
681 * Under GCC, strings prefixed with the "L" character (before
682 * the opening string quotation mark) are considered to be
683 * Unicode strings, and may be used instead of an explicit
684 * array of ASCII characters on little endian devices with
685 * UTF-16-LE \c wchar_t encoding.
688 } ATTR_PACKED USB_Descriptor_String_t
;
690 /** \brief Standard USB String Descriptor (USB-IF naming conventions).
692 * Type define for a standard string descriptor. Unlike other standard descriptors, the length
693 * of the descriptor for placement in the descriptor header must be determined by the \ref USB_STRING_LEN()
694 * macro rather than by the size of the descriptor structure, as the length is not fixed.
696 * This structure should also be used for string index 0, which contains the supported language IDs for
697 * the device as an array.
699 * This structure uses the relevant standard's given element names to ensure compatibility with the standard.
701 * \see \ref USB_Descriptor_String_t for the version of this type with with non-standard LUFA specific
704 * \note Regardless of CPU architecture, these values should be stored as little endian.
708 uint8_t bLength
; /**< Size of the descriptor, in bytes. */
709 uint8_t bDescriptorType
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t
710 * or a value given by the specific class.
712 uint16_t bString
[]; /**< String data, as unicode characters (alternatively, string language IDs).
713 * If normal ASCII characters are to be used, they must be added as an array
714 * of characters rather than a normal C string so that they are widened to
717 * Under GCC, strings prefixed with the "L" character (before the opening string
718 * quotation mark) are considered to be Unicode strings, and may be used instead
719 * of an explicit array of ASCII characters.
721 } ATTR_PACKED USB_StdDescriptor_String_t
;
723 /* Private Interface - For use in library only: */
724 #if !defined(__DOXYGEN__)
726 #define VERSION_TENS(x) (int)((x) / 10)
727 #define VERSION_ONES(x) (int)((x) - (10 * VERSION_TENS(x)))
728 #define VERSION_TENTHS(x) (int)(((x) - (int)(x)) * 10)
729 #define VERSION_HUNDREDTHS(x) (int)((((x) - (int)(x)) * 100) - (10 * VERSION_TENTHS(x)))
732 /* Disable C linkage for C++ Compilers: */
733 #if defined(__cplusplus)