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 Endpoint Address Direction Masks */
107 /** Can be masked with an endpoint address for a \ref USB_Descriptor_Endpoint_t endpoint descriptor's
108 * EndpointAddress value to indicate to the host that the endpoint is of the IN direction (i.e, from
111 #define ENDPOINT_DESCRIPTOR_DIR_IN 0x80
113 /** Can be masked with an endpoint address for a \ref USB_Descriptor_Endpoint_t endpoint descriptor's
114 * EndpointAddress value to indicate to the host that the endpoint is of the OUT direction (i.e, from
117 #define ENDPOINT_DESCRIPTOR_DIR_OUT 0x00
120 /** \name USB Configuration Descriptor Attribute Masks */
122 /** Can be masked with other configuration descriptor attributes for a \ref USB_Descriptor_Configuration_Header_t
123 * descriptor's ConfigAttributes value to indicate that the specified configuration can draw its power
124 * from the host's VBUS line.
126 #define USB_CONFIG_ATTR_BUSPOWERED 0x80
128 /** Can be masked with other configuration descriptor attributes for a \ref USB_Descriptor_Configuration_Header_t
129 * descriptor's ConfigAttributes value to indicate that the specified configuration can draw its power
130 * from the device's own power source.
132 #define USB_CONFIG_ATTR_SELFPOWERED 0x40
134 /** Can be masked with other configuration descriptor attributes for a \ref USB_Descriptor_Configuration_Header_t
135 * descriptor's ConfigAttributes value to indicate that the specified configuration supports the
136 * remote wakeup feature of the USB standard, allowing a suspended USB device to wake up the host upon
139 #define USB_CONFIG_ATTR_REMOTEWAKEUP 0x20
142 /** \name Endpoint Descriptor Attribute Masks */
144 /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
145 * Attributes value to indicate that the specified endpoint is not synchronized.
147 * \see The USB specification for more details on the possible Endpoint attributes.
149 #define ENDPOINT_ATTR_NO_SYNC (0 << 2)
151 /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
152 * Attributes value to indicate that the specified endpoint is asynchronous.
154 * \see The USB specification for more details on the possible Endpoint attributes.
156 #define ENDPOINT_ATTR_ASYNC (1 << 2)
158 /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
159 * Attributes value to indicate that the specified endpoint is adaptive.
161 * \see The USB specification for more details on the possible Endpoint attributes.
163 #define ENDPOINT_ATTR_ADAPTIVE (2 << 2)
165 /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
166 * Attributes value to indicate that the specified endpoint is synchronized.
168 * \see The USB specification for more details on the possible Endpoint attributes.
170 #define ENDPOINT_ATTR_SYNC (3 << 2)
173 /** \name Endpoint Descriptor Usage Masks */
175 /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
176 * Attributes value to indicate that the specified endpoint is used for data transfers.
178 * \see The USB specification for more details on the possible Endpoint usage attributes.
180 #define ENDPOINT_USAGE_DATA (0 << 4)
182 /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
183 * Attributes value to indicate that the specified endpoint is used for feedback.
185 * \see The USB specification for more details on the possible Endpoint usage attributes.
187 #define ENDPOINT_USAGE_FEEDBACK (1 << 4)
189 /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
190 * Attributes value to indicate that the specified endpoint is used for implicit feedback.
192 * \see The USB specification for more details on the possible Endpoint usage attributes.
194 #define ENDPOINT_USAGE_IMPLICIT_FEEDBACK (2 << 4)
198 /** Enum for the possible standard descriptor types, as given in each descriptor's header. */
199 enum USB_DescriptorTypes_t
201 DTYPE_Device
= 0x01, /**< Indicates that the descriptor is a device descriptor. */
202 DTYPE_Configuration
= 0x02, /**< Indicates that the descriptor is a configuration descriptor. */
203 DTYPE_String
= 0x03, /**< Indicates that the descriptor is a string descriptor. */
204 DTYPE_Interface
= 0x04, /**< Indicates that the descriptor is an interface descriptor. */
205 DTYPE_Endpoint
= 0x05, /**< Indicates that the descriptor is an endpoint descriptor. */
206 DTYPE_DeviceQualifier
= 0x06, /**< Indicates that the descriptor is a device qualifier descriptor. */
207 DTYPE_Other
= 0x07, /**< Indicates that the descriptor is of other type. */
208 DTYPE_InterfacePower
= 0x08, /**< Indicates that the descriptor is an interface power descriptor. */
209 DTYPE_InterfaceAssociation
= 0x0B, /**< Indicates that the descriptor is an interface association descriptor. */
210 DTYPE_CSInterface
= 0x24, /**< Indicates that the descriptor is a class specific interface descriptor. */
211 DTYPE_CSEndpoint
= 0x25, /**< Indicates that the descriptor is a class specific endpoint descriptor. */
214 /** Enum for possible Class, Subclass and Protocol values of device and interface descriptors. */
215 enum USB_Descriptor_ClassSubclassProtocol_t
217 USB_CSCP_NoDeviceClass
= 0x00, /**< Descriptor Class value indicating that the device does not belong
218 * to a particular class at the device level.
220 USB_CSCP_NoDeviceSubclass
= 0x00, /**< Descriptor Subclass value indicating that the device does not belong
221 * to a particular subclass at the device level.
223 USB_CSCP_NoDeviceProtocol
= 0x00, /**< Descriptor Protocol value indicating that the device does not belong
224 * to a particular protocol at the device level.
226 USB_CSCP_VendorSpecificClass
= 0xFF, /**< Descriptor Class value indicating that the device/interface belongs
227 * to a vendor specific class.
229 USB_CSCP_VendorSpecificSubclass
= 0xFF, /**< Descriptor Subclass value indicating that the device/interface belongs
230 * to a vendor specific subclass.
232 USB_CSCP_VendorSpecificProtocol
= 0xFF, /**< Descriptor Protocol value indicating that the device/interface belongs
233 * to a vendor specific protocol.
235 USB_CSCP_IADDeviceClass
= 0xEF, /**< Descriptor Class value indicating that the device belongs to the
236 * Interface Association Descriptor class.
238 USB_CSCP_IADDeviceSubclass
= 0x02, /**< Descriptor Subclass value indicating that the device belongs to the
239 * Interface Association Descriptor subclass.
241 USB_CSCP_IADDeviceProtocol
= 0x01, /**< Descriptor Protocol value indicating that the device belongs to the
242 * Interface Association Descriptor protocol.
247 /** \brief Standard USB Descriptor Header (LUFA naming conventions).
249 * Type define for all descriptors' standard header, indicating the descriptor's length and type. This structure
250 * uses LUFA-specific element names to make each element's purpose clearer.
252 * \see \ref USB_StdDescriptor_Header_t for the version of this type with standard element names.
254 * \note Regardless of CPU architecture, these values should be stored as little endian.
258 uint8_t Size
; /**< Size of the descriptor, in bytes. */
259 uint8_t Type
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
260 * given by the specific class.
262 } ATTR_PACKED USB_Descriptor_Header_t
;
264 /** \brief Standard USB Descriptor Header (USB-IF naming conventions).
266 * Type define for all descriptors' standard header, indicating the descriptor's length and type. This structure
267 * uses the relevant standard's given element names to ensure compatibility with the standard.
269 * \see \ref USB_Descriptor_Header_t for the version of this type with non-standard LUFA specific element names.
271 * \note Regardless of CPU architecture, these values should be stored as little endian.
275 uint8_t bLength
; /**< Size of the descriptor, in bytes. */
276 uint8_t bDescriptorType
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
277 * given by the specific class.
279 } ATTR_PACKED USB_StdDescriptor_Header_t
;
281 /** \brief Standard USB Device Descriptor (LUFA naming conventions).
283 * Type define for a standard Device Descriptor. This structure uses LUFA-specific element names to make each
284 * element's purpose clearer.
286 * \see \ref USB_StdDescriptor_Device_t for the version of this type with standard element names.
288 * \note Regardless of CPU architecture, these values should be stored as little endian.
292 USB_Descriptor_Header_t Header
; /**< Descriptor header, including type and size. */
294 uint16_t USBSpecification
; /**< BCD of the supported USB specification. */
295 uint8_t Class
; /**< USB device class. */
296 uint8_t SubClass
; /**< USB device subclass. */
297 uint8_t Protocol
; /**< USB device protocol. */
299 uint8_t Endpoint0Size
; /**< Size of the control (address 0) endpoint's bank in bytes. */
301 uint16_t VendorID
; /**< Vendor ID for the USB product. */
302 uint16_t ProductID
; /**< Unique product ID for the USB product. */
303 uint16_t ReleaseNumber
; /**< Product release (version) number. */
305 uint8_t ManufacturerStrIndex
; /**< String index for the manufacturer's name. The
306 * host will request this string via a separate
307 * control request for the string descriptor.
309 * \note If no string supplied, use \ref NO_DESCRIPTOR.
311 uint8_t ProductStrIndex
; /**< String index for the product name/details.
313 * \see ManufacturerStrIndex structure entry.
315 uint8_t SerialNumStrIndex
; /**< String index for the product's globally unique hexadecimal
316 * serial number, in uppercase Unicode ASCII.
318 * \note On some microcontroller models, there is an embedded serial number
319 * in the chip which can be used for the device serial number.
320 * To use this serial number, set this to USE_INTERNAL_SERIAL.
321 * On unsupported devices, this will evaluate to 0 and will cause
322 * the host to generate a pseudo-unique value for the device upon
325 * \see ManufacturerStrIndex structure entry.
327 uint8_t NumberOfConfigurations
; /**< Total number of configurations supported by
330 } ATTR_PACKED USB_Descriptor_Device_t
;
332 /** \brief Standard USB Device Descriptor (USB-IF naming conventions).
334 * Type define for a standard Device Descriptor. This structure uses the relevant standard's given element names
335 * to ensure compatibility with the standard.
337 * \see \ref USB_Descriptor_Device_t for the version of this type with non-standard LUFA specific element names.
339 * \note Regardless of CPU architecture, these values should be stored as little endian.
343 uint8_t bLength
; /**< Size of the descriptor, in bytes. */
344 uint8_t bDescriptorType
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
345 * given by the specific class.
347 uint16_t bcdUSB
; /**< BCD of the supported USB specification. */
348 uint8_t bDeviceClass
; /**< USB device class. */
349 uint8_t bDeviceSubClass
; /**< USB device subclass. */
350 uint8_t bDeviceProtocol
; /**< USB device protocol. */
351 uint8_t bMaxPacketSize0
; /**< Size of the control (address 0) endpoint's bank in bytes. */
352 uint16_t idVendor
; /**< Vendor ID for the USB product. */
353 uint16_t idProduct
; /**< Unique product ID for the USB product. */
354 uint16_t bcdDevice
; /**< Product release (version) number. */
355 uint8_t iManufacturer
; /**< String index for the manufacturer's name. The
356 * host will request this string via a separate
357 * control request for the string descriptor.
359 * \note If no string supplied, use \ref NO_DESCRIPTOR.
361 uint8_t iProduct
; /**< String index for the product name/details.
363 * \see ManufacturerStrIndex structure entry.
365 uint8_t iSerialNumber
; /**< String index for the product's globally unique hexadecimal
366 * serial number, in uppercase Unicode ASCII.
368 * \note On some microcontroller models, there is an embedded serial number
369 * in the chip which can be used for the device serial number.
370 * To use this serial number, set this to USE_INTERNAL_SERIAL.
371 * On unsupported devices, this will evaluate to 0 and will cause
372 * the host to generate a pseudo-unique value for the device upon
375 * \see ManufacturerStrIndex structure entry.
377 uint8_t bNumConfigurations
; /**< Total number of configurations supported by
380 } ATTR_PACKED USB_StdDescriptor_Device_t
;
382 /** \brief Standard USB Device Qualifier Descriptor (LUFA naming conventions).
384 * Type define for a standard Device Qualifier Descriptor. This structure uses LUFA-specific element names
385 * to make each element's purpose clearer.
387 * \see \ref USB_StdDescriptor_DeviceQualifier_t for the version of this type with standard element names.
391 USB_Descriptor_Header_t Header
; /**< Descriptor header, including type and size. */
393 uint16_t USBSpecification
; /**< BCD of the supported USB specification. */
394 uint8_t Class
; /**< USB device class. */
395 uint8_t SubClass
; /**< USB device subclass. */
396 uint8_t Protocol
; /**< USB device protocol. */
398 uint8_t Endpoint0Size
; /**< Size of the control (address 0) endpoint's bank in bytes. */
399 uint8_t NumberOfConfigurations
; /**< Total number of configurations supported by
402 uint8_t Reserved
; /**< Reserved for future use, must be 0. */
403 } ATTR_PACKED USB_Descriptor_DeviceQualifier_t
;
405 /** \brief Standard USB Device Qualifier Descriptor (USB-IF naming conventions).
407 * Type define for a standard Device Qualifier Descriptor. This structure uses the relevant standard's given element names
408 * to ensure compatibility with the standard.
410 * \see \ref USB_Descriptor_DeviceQualifier_t for the version of this type with non-standard LUFA specific element names.
414 uint8_t bLength
; /**< Size of the descriptor, in bytes. */
415 uint8_t bDescriptorType
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
416 * given by the specific class.
418 uint16_t bcdUSB
; /**< BCD of the supported USB specification. */
419 uint8_t bDeviceClass
; /**< USB device class. */
420 uint8_t bDeviceSubClass
; /**< USB device subclass. */
421 uint8_t bDeviceProtocol
; /**< USB device protocol. */
422 uint8_t bMaxPacketSize0
; /**< Size of the control (address 0) endpoint's bank in bytes. */
423 uint8_t bNumConfigurations
; /**< Total number of configurations supported by
426 uint8_t bReserved
; /**< Reserved for future use, must be 0. */
427 } ATTR_PACKED USB_StdDescriptor_DeviceQualifier_t
;
429 /** \brief Standard USB Configuration Descriptor (LUFA naming conventions).
431 * Type define for a standard Configuration Descriptor header. This structure uses LUFA-specific element names
432 * to make each element's purpose clearer.
434 * \see \ref USB_StdDescriptor_Configuration_Header_t for the version of this type with standard element names.
436 * \note Regardless of CPU architecture, these values should be stored as little endian.
440 USB_Descriptor_Header_t Header
; /**< Descriptor header, including type and size. */
442 uint16_t TotalConfigurationSize
; /**< Size of the configuration descriptor header,
443 * and all sub descriptors inside the configuration.
445 uint8_t TotalInterfaces
; /**< Total number of interfaces in the configuration. */
447 uint8_t ConfigurationNumber
; /**< Configuration index of the current configuration. */
448 uint8_t ConfigurationStrIndex
; /**< Index of a string descriptor describing the configuration. */
450 uint8_t ConfigAttributes
; /**< Configuration attributes, comprised of a mask of zero or
451 * more USB_CONFIG_ATTR_* masks.
454 uint8_t MaxPowerConsumption
; /**< Maximum power consumption of the device while in the
455 * current configuration, calculated by the \ref USB_CONFIG_POWER_MA()
458 } ATTR_PACKED USB_Descriptor_Configuration_Header_t
;
460 /** \brief Standard USB Configuration Descriptor (USB-IF naming conventions).
462 * Type define for a standard Configuration Descriptor header. This structure uses the relevant standard's given element names
463 * to ensure compatibility with the standard.
465 * \see \ref USB_Descriptor_Device_t for the version of this type with non-standard LUFA specific element names.
467 * \note Regardless of CPU architecture, these values should be stored as little endian.
471 uint8_t bLength
; /**< Size of the descriptor, in bytes. */
472 uint8_t bDescriptorType
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
473 * given by the specific class.
475 uint16_t wTotalLength
; /**< Size of the configuration descriptor header,
476 * and all sub descriptors inside the configuration.
478 uint8_t bNumInterfaces
; /**< Total number of interfaces in the configuration. */
479 uint8_t bConfigurationValue
; /**< Configuration index of the current configuration. */
480 uint8_t iConfiguration
; /**< Index of a string descriptor describing the configuration. */
481 uint8_t bmAttributes
; /**< Configuration attributes, comprised of a mask of zero or
482 * more USB_CONFIG_ATTR_* masks.
484 uint8_t bMaxPower
; /**< Maximum power consumption of the device while in the
485 * current configuration, calculated by the \ref USB_CONFIG_POWER_MA()
488 } ATTR_PACKED USB_StdDescriptor_Configuration_Header_t
;
490 /** \brief Standard USB Interface Descriptor (LUFA naming conventions).
492 * Type define for a standard Interface Descriptor. This structure uses LUFA-specific element names
493 * to make each element's purpose clearer.
495 * \see \ref USB_StdDescriptor_Interface_t for the version of this type with standard element names.
497 * \note Regardless of CPU architecture, these values should be stored as little endian.
501 USB_Descriptor_Header_t Header
; /**< Descriptor header, including type and size. */
503 uint8_t InterfaceNumber
; /**< Index of the interface in the current configuration. */
504 uint8_t AlternateSetting
; /**< Alternate setting for the interface number. The same
505 * interface number can have multiple alternate settings
506 * with different endpoint configurations, which can be
507 * selected by the host.
509 uint8_t TotalEndpoints
; /**< Total number of endpoints in the interface. */
511 uint8_t Class
; /**< Interface class ID. */
512 uint8_t SubClass
; /**< Interface subclass ID. */
513 uint8_t Protocol
; /**< Interface protocol ID. */
515 uint8_t InterfaceStrIndex
; /**< Index of the string descriptor describing the interface. */
516 } ATTR_PACKED USB_Descriptor_Interface_t
;
518 /** \brief Standard USB Interface Descriptor (USB-IF naming conventions).
520 * Type define for a standard Interface Descriptor. This structure uses the relevant standard's given element names
521 * to ensure compatibility with the standard.
523 * \see \ref USB_Descriptor_Interface_t for the version of this type with non-standard LUFA specific element names.
525 * \note Regardless of CPU architecture, these values should be stored as little endian.
529 uint8_t bLength
; /**< Size of the descriptor, in bytes. */
530 uint8_t bDescriptorType
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
531 * given by the specific class.
533 uint8_t bInterfaceNumber
; /**< Index of the interface in the current configuration. */
534 uint8_t bAlternateSetting
; /**< Alternate setting for the interface number. The same
535 * interface number can have multiple alternate settings
536 * with different endpoint configurations, which can be
537 * selected by the host.
539 uint8_t bNumEndpoints
; /**< Total number of endpoints in the interface. */
540 uint8_t bInterfaceClass
; /**< Interface class ID. */
541 uint8_t bInterfaceSubClass
; /**< Interface subclass ID. */
542 uint8_t bInterfaceProtocol
; /**< Interface protocol ID. */
543 uint8_t iInterface
; /**< Index of the string descriptor describing the
546 } ATTR_PACKED USB_StdDescriptor_Interface_t
;
548 /** \brief Standard USB Interface Association Descriptor (LUFA naming conventions).
550 * Type define for a standard Interface Association Descriptor. This structure uses LUFA-specific element names
551 * to make each element's purpose clearer.
553 * This descriptor has been added as a supplement to the USB2.0 standard, in the ECN located at
554 * <a>http://www.usb.org/developers/docs/InterfaceAssociationDescriptor_ecn.pdf</a>. It allows composite
555 * devices with multiple interfaces related to the same function to have the multiple interfaces bound
556 * together at the point of enumeration, loading one generic driver for all the interfaces in the single
557 * function. Read the ECN for more information.
559 * \see \ref USB_StdDescriptor_Interface_Association_t for the version of this type with standard element names.
561 * \note Regardless of CPU architecture, these values should be stored as little endian.
565 USB_Descriptor_Header_t Header
; /**< Descriptor header, including type and size. */
567 uint8_t FirstInterfaceIndex
; /**< Index of the first associated interface. */
568 uint8_t TotalInterfaces
; /**< Total number of associated interfaces. */
570 uint8_t Class
; /**< Interface class ID. */
571 uint8_t SubClass
; /**< Interface subclass ID. */
572 uint8_t Protocol
; /**< Interface protocol ID. */
574 uint8_t IADStrIndex
; /**< Index of the string descriptor describing the
575 * interface association.
577 } ATTR_PACKED USB_Descriptor_Interface_Association_t
;
579 /** \brief Standard USB Interface Association Descriptor (USB-IF naming conventions).
581 * Type define for a standard Interface Association Descriptor. This structure uses the relevant standard's given
582 * element names to ensure compatibility with the standard.
584 * This descriptor has been added as a supplement to the USB2.0 standard, in the ECN located at
585 * <a>http://www.usb.org/developers/docs/InterfaceAssociationDescriptor_ecn.pdf</a>. It allows composite
586 * devices with multiple interfaces related to the same function to have the multiple interfaces bound
587 * together at the point of enumeration, loading one generic driver for all the interfaces in the single
588 * function. Read the ECN for more information.
590 * \see \ref USB_Descriptor_Interface_Association_t for the version of this type with non-standard LUFA specific
593 * \note Regardless of CPU architecture, these values should be stored as little endian.
597 uint8_t bLength
; /**< Size of the descriptor, in bytes. */
598 uint8_t bDescriptorType
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
599 * given by the specific class.
601 uint8_t bFirstInterface
; /**< Index of the first associated interface. */
602 uint8_t bInterfaceCount
; /**< Total number of associated interfaces. */
603 uint8_t bFunctionClass
; /**< Interface class ID. */
604 uint8_t bFunctionSubClass
; /**< Interface subclass ID. */
605 uint8_t bFunctionProtocol
; /**< Interface protocol ID. */
606 uint8_t iFunction
; /**< Index of the string descriptor describing the
607 * interface association.
609 } ATTR_PACKED USB_StdDescriptor_Interface_Association_t
;
611 /** \brief Standard USB Endpoint Descriptor (LUFA naming conventions).
613 * Type define for a standard Endpoint Descriptor. This structure uses LUFA-specific element names
614 * to make each element's purpose clearer.
616 * \see \ref USB_StdDescriptor_Endpoint_t for the version of this type with standard element names.
618 * \note Regardless of CPU architecture, these values should be stored as little endian.
622 USB_Descriptor_Header_t Header
; /**< Descriptor header, including type and size. */
624 uint8_t EndpointAddress
; /**< Logical address of the endpoint within the device for the current
625 * configuration, including direction mask.
627 uint8_t Attributes
; /**< Endpoint attributes, comprised of a mask of the endpoint type (EP_TYPE_*)
628 * and attributes (ENDPOINT_ATTR_*) masks.
630 uint16_t EndpointSize
; /**< Size of the endpoint bank, in bytes. This indicates the maximum packet
631 * size that the endpoint can receive at a time.
633 uint8_t PollingIntervalMS
; /**< Polling interval in milliseconds for the endpoint if it is an INTERRUPT
634 * or ISOCHRONOUS type.
636 } ATTR_PACKED USB_Descriptor_Endpoint_t
;
638 /** \brief Standard USB Endpoint Descriptor (USB-IF naming conventions).
640 * Type define for a standard Endpoint Descriptor. This structure uses the relevant standard's given
641 * element names to ensure compatibility with the standard.
643 * \see \ref USB_Descriptor_Endpoint_t for the version of this type with non-standard LUFA specific
646 * \note Regardless of CPU architecture, these values should be stored as little endian.
650 uint8_t bLength
; /**< Size of the descriptor, in bytes. */
651 uint8_t bDescriptorType
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a
652 * value given by the specific class.
654 uint8_t bEndpointAddress
; /**< Logical address of the endpoint within the device for the current
655 * configuration, including direction mask.
657 uint8_t bmAttributes
; /**< Endpoint attributes, comprised of a mask of the endpoint type (EP_TYPE_*)
658 * and attributes (ENDPOINT_ATTR_*) masks.
660 uint16_t wMaxPacketSize
; /**< Size of the endpoint bank, in bytes. This indicates the maximum packet size
661 * that the endpoint can receive at a time.
663 uint8_t bInterval
; /**< Polling interval in milliseconds for the endpoint if it is an INTERRUPT or
666 } ATTR_PACKED USB_StdDescriptor_Endpoint_t
;
668 /** \brief Standard USB String Descriptor (LUFA naming conventions).
670 * Type define for a standard string descriptor. Unlike other standard descriptors, the length
671 * of the descriptor for placement in the descriptor header must be determined by the \ref USB_STRING_LEN()
672 * macro rather than by the size of the descriptor structure, as the length is not fixed.
674 * This structure should also be used for string index 0, which contains the supported language IDs for
675 * the device as an array.
677 * This structure uses LUFA-specific element names to make each element's purpose clearer.
679 * \see \ref USB_StdDescriptor_String_t for the version of this type with standard element names.
681 * \note Regardless of CPU architecture, these values should be stored as little endian.
685 USB_Descriptor_Header_t Header
; /**< Descriptor header, including type and size. */
687 #if ((ARCH == ARCH_AVR8) || (ARCH == ARCH_XMEGA))
688 wchar_t UnicodeString
[];
690 uint16_t UnicodeString
[]; /**< String data, as unicode characters (alternatively,
691 * string language IDs). If normal ASCII characters are
692 * to be used, they must be added as an array of characters
693 * rather than a normal C string so that they are widened to
696 * Under GCC, strings prefixed with the "L" character (before
697 * the opening string quotation mark) are considered to be
698 * Unicode strings, and may be used instead of an explicit
699 * array of ASCII characters.
702 } ATTR_PACKED USB_Descriptor_String_t
;
704 /** \brief Standard USB String Descriptor (USB-IF naming conventions).
706 * Type define for a standard string descriptor. Unlike other standard descriptors, the length
707 * of the descriptor for placement in the descriptor header must be determined by the \ref USB_STRING_LEN()
708 * macro rather than by the size of the descriptor structure, as the length is not fixed.
710 * This structure should also be used for string index 0, which contains the supported language IDs for
711 * the device as an array.
713 * This structure uses the relevant standard's given element names to ensure compatibility with the standard.
715 * \see \ref USB_Descriptor_String_t for the version of this type with with non-standard LUFA specific
718 * \note Regardless of CPU architecture, these values should be stored as little endian.
722 uint8_t bLength
; /**< Size of the descriptor, in bytes. */
723 uint8_t bDescriptorType
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t
724 * or a value given by the specific class.
726 uint16_t bString
[]; /**< String data, as unicode characters (alternatively, string language IDs).
727 * If normal ASCII characters are to be used, they must be added as an array
728 * of characters rather than a normal C string so that they are widened to
731 * Under GCC, strings prefixed with the "L" character (before the opening string
732 * quotation mark) are considered to be Unicode strings, and may be used instead
733 * of an explicit array of ASCII characters.
735 } ATTR_PACKED USB_StdDescriptor_String_t
;
737 /* Private Interface - For use in library only: */
738 #if !defined(__DOXYGEN__)
740 #define VERSION_TENS(x) (int)((x) / 10)
741 #define VERSION_ONES(x) (int)((x) - (10 * VERSION_TENS(x)))
742 #define VERSION_TENTHS(x) (int)(((x) - (int)(x)) * 10)
743 #define VERSION_HUNDREDTHS(x) (int)((((x) - (int)(x)) * 100) - (10 * VERSION_TENTHS(x)))
746 /* Disable C linkage for C++ Compilers: */
747 #if defined(__cplusplus)