3 Copyright (C) Dean Camera, 2012.
\r
5 dean [at] fourwalledcubicle [dot] com
\r
10 Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)
\r
12 Permission to use, copy, modify, distribute, and sell this
\r
13 software and its documentation for any purpose is hereby granted
\r
14 without fee, provided that the above copyright notice appear in
\r
15 all copies and that both that the copyright notice and this
\r
16 permission notice and warranty disclaimer appear in supporting
\r
17 documentation, and that the name of the author not be used in
\r
18 advertising or publicity pertaining to distribution of the
\r
19 software without specific, written prior permission.
\r
21 The author disclaim all warranties with regard to this
\r
22 software, including all implied warranties of merchantability
\r
23 and fitness. In no event shall the author be liable for any
\r
24 special, indirect or consequential damages or any damages
\r
25 whatsoever resulting from loss of use, data or profits, whether
\r
26 in an action of contract, negligence or other tortious action,
\r
27 arising out of or in connection with the use or performance of
\r
32 * \brief Common standard USB Descriptor definitions for all architectures.
\r
33 * \copydetails Group_StdDescriptors
\r
35 * \note This file should not be included directly. It is automatically included as needed by the USB driver
\r
36 * dispatch header located in LUFA/Drivers/USB/USB.h.
\r
39 /** \ingroup Group_USB
\r
40 * \defgroup Group_StdDescriptors USB Descriptors
\r
41 * \brief Standard USB Descriptor definitions.
\r
43 * Standard USB device descriptor defines and retrieval routines, for USB devices. This module contains
\r
44 * structures and macros for the easy creation of standard USB descriptors in USB device projects.
\r
49 #ifndef __USBDESCRIPTORS_H__
\r
50 #define __USBDESCRIPTORS_H__
\r
53 #include "../../../Common/Common.h"
\r
54 #include "USBMode.h"
\r
57 /* Enable C linkage for C++ Compilers: */
\r
58 #if defined(__cplusplus)
\r
62 /* Preprocessor Checks: */
\r
63 #if !defined(__INCLUDE_FROM_USB_DRIVER)
\r
64 #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
\r
67 /* Public Interface - May be used in end-application: */
\r
69 /** Indicates that a given descriptor does not exist in the device. This can be used inside descriptors
\r
70 * for string descriptor indexes, or may be use as a return value for GetDescriptor when the specified
\r
71 * descriptor does not exist.
\r
73 #define NO_DESCRIPTOR 0
\r
75 /** Macro to calculate the power value for the configuration descriptor, from a given number of milliamperes.
\r
77 * \param[in] mA Maximum number of milliamps the device consumes when the given configuration is selected.
\r
79 #define USB_CONFIG_POWER_MA(mA) ((mA) >> 1)
\r
81 /** Macro to calculate the Unicode length of a string with a given number of Unicode characters.
\r
82 * Should be used in string descriptor's headers for giving the string descriptor's byte length.
\r
84 * \param[in] UnicodeChars Number of Unicode characters in the string text.
\r
86 #define USB_STRING_LEN(UnicodeChars) (sizeof(USB_Descriptor_Header_t) + ((UnicodeChars) << 1))
\r
88 /** Macro to encode a given four digit floating point version number (e.g. 01.23) into Binary Coded
\r
89 * Decimal format for descriptor fields requiring BCD encoding, such as the USB version number in the
\r
90 * standard device descriptor.
\r
92 * \note This value is automatically converted into Little Endian, suitable for direct use inside device
\r
93 * descriptors on all architectures without endianness conversion macros.
\r
95 * \param[in] x Version number to encode as a 16-bit little-endian number, as a floating point number.
\r
97 #define VERSION_BCD(x) CPU_TO_LE16((VERSION_TENS(x) << 12) | (VERSION_ONES(x) << 8) | \
\r
98 (VERSION_TENTHS(x) << 4) | (VERSION_HUNDREDTHS(x) << 0) )
\r
100 /** String language ID for the English language. Should be used in \ref USB_Descriptor_String_t descriptors
\r
101 * to indicate that the English language is supported by the device in its string descriptors.
\r
103 #define LANGUAGE_ID_ENG 0x0409
\r
105 /** \name USB Configuration Descriptor Attribute Masks */
\r
107 /** Mask for the reserved bit in the Configuration Descriptor's \c ConfigAttributes field, which must be set on all
\r
108 * devices for historical purposes.
\r
110 #define USB_CONFIG_ATTR_RESERVED 0x80
\r
112 /** Can be masked with other configuration descriptor attributes for a \ref USB_Descriptor_Configuration_Header_t
\r
113 * descriptor's \c ConfigAttributes value to indicate that the specified configuration can draw its power
\r
114 * from the device's own power source.
\r
116 #define USB_CONFIG_ATTR_SELFPOWERED 0x40
\r
118 /** Can be masked with other configuration descriptor attributes for a \ref USB_Descriptor_Configuration_Header_t
\r
119 * descriptor's \c ConfigAttributes value to indicate that the specified configuration supports the
\r
120 * remote wakeup feature of the USB standard, allowing a suspended USB device to wake up the host upon
\r
123 #define USB_CONFIG_ATTR_REMOTEWAKEUP 0x20
\r
126 /** \name Endpoint Descriptor Attribute Masks */
\r
128 /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
\r
129 * \c Attributes value to indicate that the specified endpoint is not synchronized.
\r
131 * \see The USB specification for more details on the possible Endpoint attributes.
\r
133 #define ENDPOINT_ATTR_NO_SYNC (0 << 2)
\r
135 /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
\r
136 * \c Attributes value to indicate that the specified endpoint is asynchronous.
\r
138 * \see The USB specification for more details on the possible Endpoint attributes.
\r
140 #define ENDPOINT_ATTR_ASYNC (1 << 2)
\r
142 /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
\r
143 * \c Attributes value to indicate that the specified endpoint is adaptive.
\r
145 * \see The USB specification for more details on the possible Endpoint attributes.
\r
147 #define ENDPOINT_ATTR_ADAPTIVE (2 << 2)
\r
149 /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
\r
150 * \c Attributes value to indicate that the specified endpoint is synchronized.
\r
152 * \see The USB specification for more details on the possible Endpoint attributes.
\r
154 #define ENDPOINT_ATTR_SYNC (3 << 2)
\r
157 /** \name Endpoint Descriptor Usage Masks */
\r
159 /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
\r
160 * \c Attributes value to indicate that the specified endpoint is used for data transfers.
\r
162 * \see The USB specification for more details on the possible Endpoint usage attributes.
\r
164 #define ENDPOINT_USAGE_DATA (0 << 4)
\r
166 /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
\r
167 * \c Attributes value to indicate that the specified endpoint is used for feedback.
\r
169 * \see The USB specification for more details on the possible Endpoint usage attributes.
\r
171 #define ENDPOINT_USAGE_FEEDBACK (1 << 4)
\r
173 /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
\r
174 * \c Attributes value to indicate that the specified endpoint is used for implicit feedback.
\r
176 * \see The USB specification for more details on the possible Endpoint usage attributes.
\r
178 #define ENDPOINT_USAGE_IMPLICIT_FEEDBACK (2 << 4)
\r
182 /** Enum for the possible standard descriptor types, as given in each descriptor's header. */
\r
183 enum USB_DescriptorTypes_t
\r
185 DTYPE_Device = 0x01, /**< Indicates that the descriptor is a device descriptor. */
\r
186 DTYPE_Configuration = 0x02, /**< Indicates that the descriptor is a configuration descriptor. */
\r
187 DTYPE_String = 0x03, /**< Indicates that the descriptor is a string descriptor. */
\r
188 DTYPE_Interface = 0x04, /**< Indicates that the descriptor is an interface descriptor. */
\r
189 DTYPE_Endpoint = 0x05, /**< Indicates that the descriptor is an endpoint descriptor. */
\r
190 DTYPE_DeviceQualifier = 0x06, /**< Indicates that the descriptor is a device qualifier descriptor. */
\r
191 DTYPE_Other = 0x07, /**< Indicates that the descriptor is of other type. */
\r
192 DTYPE_InterfacePower = 0x08, /**< Indicates that the descriptor is an interface power descriptor. */
\r
193 DTYPE_InterfaceAssociation = 0x0B, /**< Indicates that the descriptor is an interface association descriptor. */
\r
194 DTYPE_CSInterface = 0x24, /**< Indicates that the descriptor is a class specific interface descriptor. */
\r
195 DTYPE_CSEndpoint = 0x25, /**< Indicates that the descriptor is a class specific endpoint descriptor. */
\r
198 /** Enum for possible Class, Subclass and Protocol values of device and interface descriptors. */
\r
199 enum USB_Descriptor_ClassSubclassProtocol_t
\r
201 USB_CSCP_NoDeviceClass = 0x00, /**< Descriptor Class value indicating that the device does not belong
\r
202 * to a particular class at the device level.
\r
204 USB_CSCP_NoDeviceSubclass = 0x00, /**< Descriptor Subclass value indicating that the device does not belong
\r
205 * to a particular subclass at the device level.
\r
207 USB_CSCP_NoDeviceProtocol = 0x00, /**< Descriptor Protocol value indicating that the device does not belong
\r
208 * to a particular protocol at the device level.
\r
210 USB_CSCP_VendorSpecificClass = 0xFF, /**< Descriptor Class value indicating that the device/interface belongs
\r
211 * to a vendor specific class.
\r
213 USB_CSCP_VendorSpecificSubclass = 0xFF, /**< Descriptor Subclass value indicating that the device/interface belongs
\r
214 * to a vendor specific subclass.
\r
216 USB_CSCP_VendorSpecificProtocol = 0xFF, /**< Descriptor Protocol value indicating that the device/interface belongs
\r
217 * to a vendor specific protocol.
\r
219 USB_CSCP_IADDeviceClass = 0xEF, /**< Descriptor Class value indicating that the device belongs to the
\r
220 * Interface Association Descriptor class.
\r
222 USB_CSCP_IADDeviceSubclass = 0x02, /**< Descriptor Subclass value indicating that the device belongs to the
\r
223 * Interface Association Descriptor subclass.
\r
225 USB_CSCP_IADDeviceProtocol = 0x01, /**< Descriptor Protocol value indicating that the device belongs to the
\r
226 * Interface Association Descriptor protocol.
\r
230 /* Type Defines: */
\r
231 /** \brief Standard USB Descriptor Header (LUFA naming conventions).
\r
233 * Type define for all descriptors' standard header, indicating the descriptor's length and type. This structure
\r
234 * uses LUFA-specific element names to make each element's purpose clearer.
\r
236 * \see \ref USB_StdDescriptor_Header_t for the version of this type with standard element names.
\r
238 * \note Regardless of CPU architecture, these values should be stored as little endian.
\r
242 uint8_t Size; /**< Size of the descriptor, in bytes. */
\r
243 uint8_t Type; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
\r
244 * given by the specific class.
\r
246 } ATTR_PACKED USB_Descriptor_Header_t;
\r
248 /** \brief Standard USB Descriptor Header (USB-IF naming conventions).
\r
250 * Type define for all descriptors' standard header, indicating the descriptor's length and type. This structure
\r
251 * uses the relevant standard's given element names to ensure compatibility with the standard.
\r
253 * \see \ref USB_Descriptor_Header_t for the version of this type with non-standard LUFA specific element names.
\r
255 * \note Regardless of CPU architecture, these values should be stored as little endian.
\r
259 uint8_t bLength; /**< Size of the descriptor, in bytes. */
\r
260 uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
\r
261 * given by the specific class.
\r
263 } ATTR_PACKED USB_StdDescriptor_Header_t;
\r
265 /** \brief Standard USB Device Descriptor (LUFA naming conventions).
\r
267 * Type define for a standard Device Descriptor. This structure uses LUFA-specific element names to make each
\r
268 * element's purpose clearer.
\r
270 * \see \ref USB_StdDescriptor_Device_t for the version of this type with standard element names.
\r
272 * \note Regardless of CPU architecture, these values should be stored as little endian.
\r
276 USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */
\r
278 uint16_t USBSpecification; /**< BCD of the supported USB specification. */
\r
279 uint8_t Class; /**< USB device class. */
\r
280 uint8_t SubClass; /**< USB device subclass. */
\r
281 uint8_t Protocol; /**< USB device protocol. */
\r
283 uint8_t Endpoint0Size; /**< Size of the control (address 0) endpoint's bank in bytes. */
\r
285 uint16_t VendorID; /**< Vendor ID for the USB product. */
\r
286 uint16_t ProductID; /**< Unique product ID for the USB product. */
\r
287 uint16_t ReleaseNumber; /**< Product release (version) number. */
\r
289 uint8_t ManufacturerStrIndex; /**< String index for the manufacturer's name. The
\r
290 * host will request this string via a separate
\r
291 * control request for the string descriptor.
\r
293 * \note If no string supplied, use \ref NO_DESCRIPTOR.
\r
295 uint8_t ProductStrIndex; /**< String index for the product name/details.
\r
297 * \see ManufacturerStrIndex structure entry.
\r
299 uint8_t SerialNumStrIndex; /**< String index for the product's globally unique hexadecimal
\r
300 * serial number, in uppercase Unicode ASCII.
\r
302 * \note On some microcontroller models, there is an embedded serial number
\r
303 * in the chip which can be used for the device serial number.
\r
304 * To use this serial number, set this to USE_INTERNAL_SERIAL.
\r
305 * On unsupported devices, this will evaluate to 0 and will cause
\r
306 * the host to generate a pseudo-unique value for the device upon
\r
309 * \see ManufacturerStrIndex structure entry.
\r
311 uint8_t NumberOfConfigurations; /**< Total number of configurations supported by
\r
314 } ATTR_PACKED USB_Descriptor_Device_t;
\r
316 /** \brief Standard USB Device Descriptor (USB-IF naming conventions).
\r
318 * Type define for a standard Device Descriptor. This structure uses the relevant standard's given element names
\r
319 * to ensure compatibility with the standard.
\r
321 * \see \ref USB_Descriptor_Device_t for the version of this type with non-standard LUFA specific element names.
\r
323 * \note Regardless of CPU architecture, these values should be stored as little endian.
\r
327 uint8_t bLength; /**< Size of the descriptor, in bytes. */
\r
328 uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
\r
329 * given by the specific class.
\r
331 uint16_t bcdUSB; /**< BCD of the supported USB specification. */
\r
332 uint8_t bDeviceClass; /**< USB device class. */
\r
333 uint8_t bDeviceSubClass; /**< USB device subclass. */
\r
334 uint8_t bDeviceProtocol; /**< USB device protocol. */
\r
335 uint8_t bMaxPacketSize0; /**< Size of the control (address 0) endpoint's bank in bytes. */
\r
336 uint16_t idVendor; /**< Vendor ID for the USB product. */
\r
337 uint16_t idProduct; /**< Unique product ID for the USB product. */
\r
338 uint16_t bcdDevice; /**< Product release (version) number. */
\r
339 uint8_t iManufacturer; /**< String index for the manufacturer's name. The
\r
340 * host will request this string via a separate
\r
341 * control request for the string descriptor.
\r
343 * \note If no string supplied, use \ref NO_DESCRIPTOR.
\r
345 uint8_t iProduct; /**< String index for the product name/details.
\r
347 * \see ManufacturerStrIndex structure entry.
\r
349 uint8_t iSerialNumber; /**< String index for the product's globally unique hexadecimal
\r
350 * serial number, in uppercase Unicode ASCII.
\r
352 * \note On some microcontroller models, there is an embedded serial number
\r
353 * in the chip which can be used for the device serial number.
\r
354 * To use this serial number, set this to USE_INTERNAL_SERIAL.
\r
355 * On unsupported devices, this will evaluate to 0 and will cause
\r
356 * the host to generate a pseudo-unique value for the device upon
\r
359 * \see ManufacturerStrIndex structure entry.
\r
361 uint8_t bNumConfigurations; /**< Total number of configurations supported by
\r
364 } ATTR_PACKED USB_StdDescriptor_Device_t;
\r
366 /** \brief Standard USB Device Qualifier Descriptor (LUFA naming conventions).
\r
368 * Type define for a standard Device Qualifier Descriptor. This structure uses LUFA-specific element names
\r
369 * to make each element's purpose clearer.
\r
371 * \see \ref USB_StdDescriptor_DeviceQualifier_t for the version of this type with standard element names.
\r
375 USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */
\r
377 uint16_t USBSpecification; /**< BCD of the supported USB specification. */
\r
378 uint8_t Class; /**< USB device class. */
\r
379 uint8_t SubClass; /**< USB device subclass. */
\r
380 uint8_t Protocol; /**< USB device protocol. */
\r
382 uint8_t Endpoint0Size; /**< Size of the control (address 0) endpoint's bank in bytes. */
\r
383 uint8_t NumberOfConfigurations; /**< Total number of configurations supported by
\r
386 uint8_t Reserved; /**< Reserved for future use, must be 0. */
\r
387 } ATTR_PACKED USB_Descriptor_DeviceQualifier_t;
\r
389 /** \brief Standard USB Device Qualifier Descriptor (USB-IF naming conventions).
\r
391 * Type define for a standard Device Qualifier Descriptor. This structure uses the relevant standard's given element names
\r
392 * to ensure compatibility with the standard.
\r
394 * \see \ref USB_Descriptor_DeviceQualifier_t for the version of this type with non-standard LUFA specific element names.
\r
398 uint8_t bLength; /**< Size of the descriptor, in bytes. */
\r
399 uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
\r
400 * given by the specific class.
\r
402 uint16_t bcdUSB; /**< BCD of the supported USB specification. */
\r
403 uint8_t bDeviceClass; /**< USB device class. */
\r
404 uint8_t bDeviceSubClass; /**< USB device subclass. */
\r
405 uint8_t bDeviceProtocol; /**< USB device protocol. */
\r
406 uint8_t bMaxPacketSize0; /**< Size of the control (address 0) endpoint's bank in bytes. */
\r
407 uint8_t bNumConfigurations; /**< Total number of configurations supported by
\r
410 uint8_t bReserved; /**< Reserved for future use, must be 0. */
\r
411 } ATTR_PACKED USB_StdDescriptor_DeviceQualifier_t;
\r
413 /** \brief Standard USB Configuration Descriptor (LUFA naming conventions).
\r
415 * Type define for a standard Configuration Descriptor header. This structure uses LUFA-specific element names
\r
416 * to make each element's purpose clearer.
\r
418 * \see \ref USB_StdDescriptor_Configuration_Header_t for the version of this type with standard element names.
\r
420 * \note Regardless of CPU architecture, these values should be stored as little endian.
\r
424 USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */
\r
426 uint16_t TotalConfigurationSize; /**< Size of the configuration descriptor header,
\r
427 * and all sub descriptors inside the configuration.
\r
429 uint8_t TotalInterfaces; /**< Total number of interfaces in the configuration. */
\r
431 uint8_t ConfigurationNumber; /**< Configuration index of the current configuration. */
\r
432 uint8_t ConfigurationStrIndex; /**< Index of a string descriptor describing the configuration. */
\r
434 uint8_t ConfigAttributes; /**< Configuration attributes, comprised of a mask of \c USB_CONFIG_ATTR_* masks.
\r
435 * On all devices, this should include USB_CONFIG_ATTR_RESERVED at a minimum.
\r
438 uint8_t MaxPowerConsumption; /**< Maximum power consumption of the device while in the
\r
439 * current configuration, calculated by the \ref USB_CONFIG_POWER_MA()
\r
442 } ATTR_PACKED USB_Descriptor_Configuration_Header_t;
\r
444 /** \brief Standard USB Configuration Descriptor (USB-IF naming conventions).
\r
446 * Type define for a standard Configuration Descriptor header. This structure uses the relevant standard's given element names
\r
447 * to ensure compatibility with the standard.
\r
449 * \see \ref USB_Descriptor_Device_t for the version of this type with non-standard LUFA specific element names.
\r
451 * \note Regardless of CPU architecture, these values should be stored as little endian.
\r
455 uint8_t bLength; /**< Size of the descriptor, in bytes. */
\r
456 uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
\r
457 * given by the specific class.
\r
459 uint16_t wTotalLength; /**< Size of the configuration descriptor header,
\r
460 * and all sub descriptors inside the configuration.
\r
462 uint8_t bNumInterfaces; /**< Total number of interfaces in the configuration. */
\r
463 uint8_t bConfigurationValue; /**< Configuration index of the current configuration. */
\r
464 uint8_t iConfiguration; /**< Index of a string descriptor describing the configuration. */
\r
465 uint8_t bmAttributes; /**< Configuration attributes, comprised of a mask of \c USB_CONFIG_ATTR_* masks.
\r
466 * On all devices, this should include USB_CONFIG_ATTR_RESERVED at a minimum.
\r
468 uint8_t bMaxPower; /**< Maximum power consumption of the device while in the
\r
469 * current configuration, calculated by the \ref USB_CONFIG_POWER_MA()
\r
472 } ATTR_PACKED USB_StdDescriptor_Configuration_Header_t;
\r
474 /** \brief Standard USB Interface Descriptor (LUFA naming conventions).
\r
476 * Type define for a standard Interface Descriptor. This structure uses LUFA-specific element names
\r
477 * to make each element's purpose clearer.
\r
479 * \see \ref USB_StdDescriptor_Interface_t for the version of this type with standard element names.
\r
481 * \note Regardless of CPU architecture, these values should be stored as little endian.
\r
485 USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */
\r
487 uint8_t InterfaceNumber; /**< Index of the interface in the current configuration. */
\r
488 uint8_t AlternateSetting; /**< Alternate setting for the interface number. The same
\r
489 * interface number can have multiple alternate settings
\r
490 * with different endpoint configurations, which can be
\r
491 * selected by the host.
\r
493 uint8_t TotalEndpoints; /**< Total number of endpoints in the interface. */
\r
495 uint8_t Class; /**< Interface class ID. */
\r
496 uint8_t SubClass; /**< Interface subclass ID. */
\r
497 uint8_t Protocol; /**< Interface protocol ID. */
\r
499 uint8_t InterfaceStrIndex; /**< Index of the string descriptor describing the interface. */
\r
500 } ATTR_PACKED USB_Descriptor_Interface_t;
\r
502 /** \brief Standard USB Interface Descriptor (USB-IF naming conventions).
\r
504 * Type define for a standard Interface Descriptor. This structure uses the relevant standard's given element names
\r
505 * to ensure compatibility with the standard.
\r
507 * \see \ref USB_Descriptor_Interface_t for the version of this type with non-standard LUFA specific element names.
\r
509 * \note Regardless of CPU architecture, these values should be stored as little endian.
\r
513 uint8_t bLength; /**< Size of the descriptor, in bytes. */
\r
514 uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
\r
515 * given by the specific class.
\r
517 uint8_t bInterfaceNumber; /**< Index of the interface in the current configuration. */
\r
518 uint8_t bAlternateSetting; /**< Alternate setting for the interface number. The same
\r
519 * interface number can have multiple alternate settings
\r
520 * with different endpoint configurations, which can be
\r
521 * selected by the host.
\r
523 uint8_t bNumEndpoints; /**< Total number of endpoints in the interface. */
\r
524 uint8_t bInterfaceClass; /**< Interface class ID. */
\r
525 uint8_t bInterfaceSubClass; /**< Interface subclass ID. */
\r
526 uint8_t bInterfaceProtocol; /**< Interface protocol ID. */
\r
527 uint8_t iInterface; /**< Index of the string descriptor describing the
\r
530 } ATTR_PACKED USB_StdDescriptor_Interface_t;
\r
532 /** \brief Standard USB Interface Association Descriptor (LUFA naming conventions).
\r
534 * Type define for a standard Interface Association Descriptor. This structure uses LUFA-specific element names
\r
535 * to make each element's purpose clearer.
\r
537 * This descriptor has been added as a supplement to the USB2.0 standard, in the ECN located at
\r
538 * <a>http://www.usb.org/developers/docs/InterfaceAssociationDescriptor_ecn.pdf</a>. It allows composite
\r
539 * devices with multiple interfaces related to the same function to have the multiple interfaces bound
\r
540 * together at the point of enumeration, loading one generic driver for all the interfaces in the single
\r
541 * function. Read the ECN for more information.
\r
543 * \see \ref USB_StdDescriptor_Interface_Association_t for the version of this type with standard element names.
\r
545 * \note Regardless of CPU architecture, these values should be stored as little endian.
\r
549 USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */
\r
551 uint8_t FirstInterfaceIndex; /**< Index of the first associated interface. */
\r
552 uint8_t TotalInterfaces; /**< Total number of associated interfaces. */
\r
554 uint8_t Class; /**< Interface class ID. */
\r
555 uint8_t SubClass; /**< Interface subclass ID. */
\r
556 uint8_t Protocol; /**< Interface protocol ID. */
\r
558 uint8_t IADStrIndex; /**< Index of the string descriptor describing the
\r
559 * interface association.
\r
561 } ATTR_PACKED USB_Descriptor_Interface_Association_t;
\r
563 /** \brief Standard USB Interface Association Descriptor (USB-IF naming conventions).
\r
565 * Type define for a standard Interface Association Descriptor. This structure uses the relevant standard's given
\r
566 * element names to ensure compatibility with the standard.
\r
568 * This descriptor has been added as a supplement to the USB2.0 standard, in the ECN located at
\r
569 * <a>http://www.usb.org/developers/docs/InterfaceAssociationDescriptor_ecn.pdf</a>. It allows composite
\r
570 * devices with multiple interfaces related to the same function to have the multiple interfaces bound
\r
571 * together at the point of enumeration, loading one generic driver for all the interfaces in the single
\r
572 * function. Read the ECN for more information.
\r
574 * \see \ref USB_Descriptor_Interface_Association_t for the version of this type with non-standard LUFA specific
\r
577 * \note Regardless of CPU architecture, these values should be stored as little endian.
\r
581 uint8_t bLength; /**< Size of the descriptor, in bytes. */
\r
582 uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
\r
583 * given by the specific class.
\r
585 uint8_t bFirstInterface; /**< Index of the first associated interface. */
\r
586 uint8_t bInterfaceCount; /**< Total number of associated interfaces. */
\r
587 uint8_t bFunctionClass; /**< Interface class ID. */
\r
588 uint8_t bFunctionSubClass; /**< Interface subclass ID. */
\r
589 uint8_t bFunctionProtocol; /**< Interface protocol ID. */
\r
590 uint8_t iFunction; /**< Index of the string descriptor describing the
\r
591 * interface association.
\r
593 } ATTR_PACKED USB_StdDescriptor_Interface_Association_t;
\r
595 /** \brief Standard USB Endpoint Descriptor (LUFA naming conventions).
\r
597 * Type define for a standard Endpoint Descriptor. This structure uses LUFA-specific element names
\r
598 * to make each element's purpose clearer.
\r
600 * \see \ref USB_StdDescriptor_Endpoint_t for the version of this type with standard element names.
\r
602 * \note Regardless of CPU architecture, these values should be stored as little endian.
\r
606 USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */
\r
608 uint8_t EndpointAddress; /**< Logical address of the endpoint within the device for the current
\r
609 * configuration, including direction mask.
\r
611 uint8_t Attributes; /**< Endpoint attributes, comprised of a mask of the endpoint type (EP_TYPE_*)
\r
612 * and attributes (ENDPOINT_ATTR_*) masks.
\r
614 uint16_t EndpointSize; /**< Size of the endpoint bank, in bytes. This indicates the maximum packet
\r
615 * size that the endpoint can receive at a time.
\r
617 uint8_t PollingIntervalMS; /**< Polling interval in milliseconds for the endpoint if it is an INTERRUPT
\r
618 * or ISOCHRONOUS type.
\r
620 } ATTR_PACKED USB_Descriptor_Endpoint_t;
\r
622 /** \brief Standard USB Endpoint Descriptor (USB-IF naming conventions).
\r
624 * Type define for a standard Endpoint Descriptor. This structure uses the relevant standard's given
\r
625 * element names to ensure compatibility with the standard.
\r
627 * \see \ref USB_Descriptor_Endpoint_t for the version of this type with non-standard LUFA specific
\r
630 * \note Regardless of CPU architecture, these values should be stored as little endian.
\r
634 uint8_t bLength; /**< Size of the descriptor, in bytes. */
\r
635 uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a
\r
636 * value given by the specific class.
\r
638 uint8_t bEndpointAddress; /**< Logical address of the endpoint within the device for the current
\r
639 * configuration, including direction mask.
\r
641 uint8_t bmAttributes; /**< Endpoint attributes, comprised of a mask of the endpoint type (EP_TYPE_*)
\r
642 * and attributes (ENDPOINT_ATTR_*) masks.
\r
644 uint16_t wMaxPacketSize; /**< Size of the endpoint bank, in bytes. This indicates the maximum packet size
\r
645 * that the endpoint can receive at a time.
\r
647 uint8_t bInterval; /**< Polling interval in milliseconds for the endpoint if it is an INTERRUPT or
\r
648 * ISOCHRONOUS type.
\r
650 } ATTR_PACKED USB_StdDescriptor_Endpoint_t;
\r
652 /** \brief Standard USB String Descriptor (LUFA naming conventions).
\r
654 * Type define for a standard string descriptor. Unlike other standard descriptors, the length
\r
655 * of the descriptor for placement in the descriptor header must be determined by the \ref USB_STRING_LEN()
\r
656 * macro rather than by the size of the descriptor structure, as the length is not fixed.
\r
658 * This structure should also be used for string index 0, which contains the supported language IDs for
\r
659 * the device as an array.
\r
661 * This structure uses LUFA-specific element names to make each element's purpose clearer.
\r
663 * \see \ref USB_StdDescriptor_String_t for the version of this type with standard element names.
\r
665 * \note Regardless of CPU architecture, these values should be stored as little endian.
\r
669 USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */
\r
671 #if (((ARCH == ARCH_AVR8) || (ARCH == ARCH_XMEGA)) && !defined(__DOXYGEN__))
\r
672 wchar_t UnicodeString[];
\r
674 uint16_t UnicodeString[]; /**< String data, as unicode characters (alternatively,
\r
675 * string language IDs). If normal ASCII characters are
\r
676 * to be used, they must be added as an array of characters
\r
677 * rather than a normal C string so that they are widened to
\r
680 * Under GCC, strings prefixed with the "L" character (before
\r
681 * the opening string quotation mark) are considered to be
\r
682 * Unicode strings, and may be used instead of an explicit
\r
683 * array of ASCII characters on little endian devices with
\r
684 * UTF-16-LE \c wchar_t encoding.
\r
687 } ATTR_PACKED USB_Descriptor_String_t;
\r
689 /** \brief Standard USB String Descriptor (USB-IF naming conventions).
\r
691 * Type define for a standard string descriptor. Unlike other standard descriptors, the length
\r
692 * of the descriptor for placement in the descriptor header must be determined by the \ref USB_STRING_LEN()
\r
693 * macro rather than by the size of the descriptor structure, as the length is not fixed.
\r
695 * This structure should also be used for string index 0, which contains the supported language IDs for
\r
696 * the device as an array.
\r
698 * This structure uses the relevant standard's given element names to ensure compatibility with the standard.
\r
700 * \see \ref USB_Descriptor_String_t for the version of this type with with non-standard LUFA specific
\r
703 * \note Regardless of CPU architecture, these values should be stored as little endian.
\r
707 uint8_t bLength; /**< Size of the descriptor, in bytes. */
\r
708 uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t
\r
709 * or a value given by the specific class.
\r
711 uint16_t bString[]; /**< String data, as unicode characters (alternatively, string language IDs).
\r
712 * If normal ASCII characters are to be used, they must be added as an array
\r
713 * of characters rather than a normal C string so that they are widened to
\r
716 * Under GCC, strings prefixed with the "L" character (before the opening string
\r
717 * quotation mark) are considered to be Unicode strings, and may be used instead
\r
718 * of an explicit array of ASCII characters.
\r
720 } ATTR_PACKED USB_StdDescriptor_String_t;
\r
722 /* Private Interface - For use in library only: */
\r
723 #if !defined(__DOXYGEN__)
\r
725 #define VERSION_TENS(x) (int)((int)(x) / 10)
\r
726 #define VERSION_ONES(x) (int)((int)(x) % 10)
\r
727 #define VERSION_TENTHS(x) (int)(((x * 1) - ((int)(x * 1))) * 10)
\r
728 #define VERSION_HUNDREDTHS(x) (int)(((x * 10) - ((int)(x * 10))) * 10)
\r
731 /* Disable C linkage for C++ Compilers: */
\r
732 #if defined(__cplusplus)
\r