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 #if defined(USB_CAN_BE_DEVICE)
61 /* Enable C linkage for C++ Compilers: */
62 #if defined(__cplusplus)
66 /* Preprocessor Checks: */
67 #if !defined(__INCLUDE_FROM_USB_DRIVER)
68 #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
71 /* Public Interface - May be used in end-application: */
73 /** Indicates that a given descriptor does not exist in the device. This can be used inside descriptors
74 * for string descriptor indexes, or may be use as a return value for GetDescriptor when the specified
75 * descriptor does not exist.
77 #define NO_DESCRIPTOR 0
79 /** Macro to calculate the power value for the configuration descriptor, from a given number of milliamperes.
81 * \param[in] mA Maximum number of milliamps the device consumes when the given configuration is selected.
83 #define USB_CONFIG_POWER_MA(mA) ((mA) >> 1)
85 /** Macro to calculate the Unicode length of a string with a given number of Unicode characters.
86 * Should be used in string descriptor's headers for giving the string descriptor's byte length.
88 * \param[in] UnicodeChars Number of Unicode characters in the string text.
90 #define USB_STRING_LEN(UnicodeChars) (sizeof(USB_Descriptor_Header_t) + ((UnicodeChars) << 1))
92 /** Macro to encode a given four digit floating point version number (e.g. 01.23) into Binary Coded
93 * Decimal format for descriptor fields requiring BCD encoding, such as the USB version number in the
94 * standard device descriptor.
96 * \note This value is automatically converted into Little Endian, suitable for direct use inside device
97 * descriptors on all architectures without endianness conversion macros.
99 * \param[in] x Version number to encode as a 16-bit little-endian number, as a floating point number.
101 #define VERSION_BCD(x) CPU_TO_LE16((((VERSION_TENS(x) << 4) | VERSION_ONES(x)) << 8) | \
102 ((VERSION_TENTHS(x) << 4) | VERSION_HUNDREDTHS(x)))
104 /** String language ID for the English language. Should be used in \ref USB_Descriptor_String_t descriptors
105 * to indicate that the English language is supported by the device in its string descriptors.
107 #define LANGUAGE_ID_ENG 0x0409
109 /** \name Endpoint Address Direction Masks */
111 /** Can be masked with an endpoint address for a \ref USB_Descriptor_Endpoint_t endpoint descriptor's
112 * EndpointAddress value to indicate to the host that the endpoint is of the IN direction (i.e, from
115 #define ENDPOINT_DESCRIPTOR_DIR_IN 0x80
117 /** Can be masked with an endpoint address for a \ref USB_Descriptor_Endpoint_t endpoint descriptor's
118 * EndpointAddress value to indicate to the host that the endpoint is of the OUT direction (i.e, from
121 #define ENDPOINT_DESCRIPTOR_DIR_OUT 0x00
124 /** \name USB Configuration Descriptor Attribute Masks */
126 /** Can be masked with other configuration descriptor attributes for a \ref USB_Descriptor_Configuration_Header_t
127 * descriptor's ConfigAttributes value to indicate that the specified configuration can draw its power
128 * from the host's VBUS line.
130 #define USB_CONFIG_ATTR_BUSPOWERED 0x80
132 /** Can be masked with other configuration descriptor attributes for a \ref USB_Descriptor_Configuration_Header_t
133 * descriptor's ConfigAttributes value to indicate that the specified configuration can draw its power
134 * from the device's own power source.
136 #define USB_CONFIG_ATTR_SELFPOWERED 0x40
138 /** Can be masked with other configuration descriptor attributes for a \ref USB_Descriptor_Configuration_Header_t
139 * descriptor's ConfigAttributes value to indicate that the specified configuration supports the
140 * remote wakeup feature of the USB standard, allowing a suspended USB device to wake up the host upon
143 #define USB_CONFIG_ATTR_REMOTEWAKEUP 0x20
146 /** \name Endpoint Descriptor Attribute Masks */
148 /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
149 * Attributes value to indicate that the specified endpoint is not synchronized.
151 * \see The USB specification for more details on the possible Endpoint attributes.
153 #define ENDPOINT_ATTR_NO_SYNC (0 << 2)
155 /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
156 * Attributes value to indicate that the specified endpoint is asynchronous.
158 * \see The USB specification for more details on the possible Endpoint attributes.
160 #define ENDPOINT_ATTR_ASYNC (1 << 2)
162 /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
163 * Attributes value to indicate that the specified endpoint is adaptive.
165 * \see The USB specification for more details on the possible Endpoint attributes.
167 #define ENDPOINT_ATTR_ADAPTIVE (2 << 2)
169 /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
170 * Attributes value to indicate that the specified endpoint is synchronized.
172 * \see The USB specification for more details on the possible Endpoint attributes.
174 #define ENDPOINT_ATTR_SYNC (3 << 2)
177 /** \name Endpoint Descriptor Usage Masks */
179 /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
180 * Attributes value to indicate that the specified endpoint is used for data transfers.
182 * \see The USB specification for more details on the possible Endpoint usage attributes.
184 #define ENDPOINT_USAGE_DATA (0 << 4)
186 /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
187 * Attributes value to indicate that the specified endpoint is used for feedback.
189 * \see The USB specification for more details on the possible Endpoint usage attributes.
191 #define ENDPOINT_USAGE_FEEDBACK (1 << 4)
193 /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
194 * Attributes value to indicate that the specified endpoint is used for implicit feedback.
196 * \see The USB specification for more details on the possible Endpoint usage attributes.
198 #define ENDPOINT_USAGE_IMPLICIT_FEEDBACK (2 << 4)
202 /** Enum for the possible standard descriptor types, as given in each descriptor's header. */
203 enum USB_DescriptorTypes_t
205 DTYPE_Device
= 0x01, /**< Indicates that the descriptor is a device descriptor. */
206 DTYPE_Configuration
= 0x02, /**< Indicates that the descriptor is a configuration descriptor. */
207 DTYPE_String
= 0x03, /**< Indicates that the descriptor is a string descriptor. */
208 DTYPE_Interface
= 0x04, /**< Indicates that the descriptor is an interface descriptor. */
209 DTYPE_Endpoint
= 0x05, /**< Indicates that the descriptor is an endpoint descriptor. */
210 DTYPE_DeviceQualifier
= 0x06, /**< Indicates that the descriptor is a device qualifier descriptor. */
211 DTYPE_Other
= 0x07, /**< Indicates that the descriptor is of other type. */
212 DTYPE_InterfacePower
= 0x08, /**< Indicates that the descriptor is an interface power descriptor. */
213 DTYPE_InterfaceAssociation
= 0x0B, /**< Indicates that the descriptor is an interface association descriptor. */
214 DTYPE_CSInterface
= 0x24, /**< Indicates that the descriptor is a class specific interface descriptor. */
215 DTYPE_CSEndpoint
= 0x25, /**< Indicates that the descriptor is a class specific endpoint descriptor. */
218 /** Enum for possible Class, Subclass and Protocol values of device and interface descriptors. */
219 enum USB_Descriptor_ClassSubclassProtocol_t
221 USB_CSCP_NoDeviceClass
= 0x00, /**< Descriptor Class value indicating that the device does not belong
222 * to a particular class at the device level.
224 USB_CSCP_NoDeviceSubclass
= 0x00, /**< Descriptor Subclass value indicating that the device does not belong
225 * to a particular subclass at the device level.
227 USB_CSCP_NoDeviceProtocol
= 0x00, /**< Descriptor Protocol value indicating that the device does not belong
228 * to a particular protocol at the device level.
230 USB_CSCP_VendorSpecificClass
= 0xFF, /**< Descriptor Class value indicating that the device/interface belongs
231 * to a vendor specific class.
233 USB_CSCP_VendorSpecificSubclass
= 0xFF, /**< Descriptor Subclass value indicating that the device/interface belongs
234 * to a vendor specific subclass.
236 USB_CSCP_VendorSpecificProtocol
= 0xFF, /**< Descriptor Protocol value indicating that the device/interface belongs
237 * to a vendor specific protocol.
239 USB_CSCP_IADDeviceClass
= 0xEF, /**< Descriptor Class value indicating that the device belongs to the
240 * Interface Association Descriptor class.
242 USB_CSCP_IADDeviceSubclass
= 0x02, /**< Descriptor Subclass value indicating that the device belongs to the
243 * Interface Association Descriptor subclass.
245 USB_CSCP_IADDeviceProtocol
= 0x01, /**< Descriptor Protocol value indicating that the device belongs to the
246 * Interface Association Descriptor protocol.
251 /** \brief Standard USB Descriptor Header (LUFA naming conventions).
253 * Type define for all descriptors' standard header, indicating the descriptor's length and type. This structure
254 * uses LUFA-specific element names to make each element's purpose clearer.
256 * \see \ref USB_StdDescriptor_Header_t for the version of this type with standard element names.
260 uint8_t Size
; /**< Size of the descriptor, in bytes. */
261 uint8_t Type
; /**< 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_Descriptor_Header_t
;
266 /** \brief Standard USB Descriptor Header (USB-IF naming conventions).
268 * Type define for all descriptors' standard header, indicating the descriptor's length and type. This structure
269 * uses the relevant standard's given element names to ensure compatibility with the standard.
271 * \see \ref USB_Descriptor_Header_t for the version of this type with non-standard LUFA specific element names.
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.
290 USB_Descriptor_Header_t Header
; /**< Descriptor header, including type and size. */
292 uint16_t USBSpecification
; /**< BCD of the supported USB specification. */
293 uint8_t Class
; /**< USB device class. */
294 uint8_t SubClass
; /**< USB device subclass. */
295 uint8_t Protocol
; /**< USB device protocol. */
297 uint8_t Endpoint0Size
; /**< Size of the control (address 0) endpoint's bank in bytes. */
299 uint16_t VendorID
; /**< Vendor ID for the USB product. */
300 uint16_t ProductID
; /**< Unique product ID for the USB product. */
301 uint16_t ReleaseNumber
; /**< Product release (version) number. */
303 uint8_t ManufacturerStrIndex
; /**< String index for the manufacturer's name. The
304 * host will request this string via a separate
305 * control request for the string descriptor.
307 * \note If no string supplied, use \ref NO_DESCRIPTOR.
309 uint8_t ProductStrIndex
; /**< String index for the product name/details.
311 * \see ManufacturerStrIndex structure entry.
313 uint8_t SerialNumStrIndex
; /**< String index for the product's globally unique hexadecimal
314 * serial number, in uppercase Unicode ASCII.
316 * \note On some microcontroller models, there is an embedded serial number
317 * in the chip which can be used for the device serial number.
318 * To use this serial number, set this to USE_INTERNAL_SERIAL.
319 * On unsupported devices, this will evaluate to 0 and will cause
320 * the host to generate a pseudo-unique value for the device upon
323 * \see ManufacturerStrIndex structure entry.
325 uint8_t NumberOfConfigurations
; /**< Total number of configurations supported by
328 } ATTR_PACKED USB_Descriptor_Device_t
;
330 /** \brief Standard USB Device Descriptor (USB-IF naming conventions).
332 * Type define for a standard Device Descriptor. This structure uses the relevant standard's given element names
333 * to ensure compatibility with the standard.
335 * \see \ref USB_Descriptor_Device_t for the version of this type with non-standard LUFA specific element names.
339 uint8_t bLength
; /**< Size of the descriptor, in bytes. */
340 uint8_t bDescriptorType
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
341 * given by the specific class.
343 uint16_t bcdUSB
; /**< BCD of the supported USB specification. */
344 uint8_t bDeviceClass
; /**< USB device class. */
345 uint8_t bDeviceSubClass
; /**< USB device subclass. */
346 uint8_t bDeviceProtocol
; /**< USB device protocol. */
347 uint8_t bMaxPacketSize0
; /**< Size of the control (address 0) endpoint's bank in bytes. */
348 uint16_t idVendor
; /**< Vendor ID for the USB product. */
349 uint16_t idProduct
; /**< Unique product ID for the USB product. */
350 uint16_t bcdDevice
; /**< Product release (version) number. */
351 uint8_t iManufacturer
; /**< String index for the manufacturer's name. The
352 * host will request this string via a separate
353 * control request for the string descriptor.
355 * \note If no string supplied, use \ref NO_DESCRIPTOR.
357 uint8_t iProduct
; /**< String index for the product name/details.
359 * \see ManufacturerStrIndex structure entry.
361 uint8_t iSerialNumber
; /**< String index for the product's globally unique hexadecimal
362 * serial number, in uppercase Unicode ASCII.
364 * \note On some microcontroller models, there is an embedded serial number
365 * in the chip which can be used for the device serial number.
366 * To use this serial number, set this to USE_INTERNAL_SERIAL.
367 * On unsupported devices, this will evaluate to 0 and will cause
368 * the host to generate a pseudo-unique value for the device upon
371 * \see ManufacturerStrIndex structure entry.
373 uint8_t bNumConfigurations
; /**< Total number of configurations supported by
376 } ATTR_PACKED USB_StdDescriptor_Device_t
;
378 /** \brief Standard USB Configuration Descriptor (LUFA naming conventions).
380 * Type define for a standard Configuration Descriptor header. This structure uses LUFA-specific element names
381 * to make each element's purpose clearer.
383 * \see \ref USB_StdDescriptor_Configuration_Header_t for the version of this type with standard element names.
387 USB_Descriptor_Header_t Header
; /**< Descriptor header, including type and size. */
389 uint16_t TotalConfigurationSize
; /**< Size of the configuration descriptor header,
390 * and all sub descriptors inside the configuration.
392 uint8_t TotalInterfaces
; /**< Total number of interfaces in the configuration. */
394 uint8_t ConfigurationNumber
; /**< Configuration index of the current configuration. */
395 uint8_t ConfigurationStrIndex
; /**< Index of a string descriptor describing the configuration. */
397 uint8_t ConfigAttributes
; /**< Configuration attributes, comprised of a mask of zero or
398 * more USB_CONFIG_ATTR_* masks.
401 uint8_t MaxPowerConsumption
; /**< Maximum power consumption of the device while in the
402 * current configuration, calculated by the \ref USB_CONFIG_POWER_MA()
405 } ATTR_PACKED USB_Descriptor_Configuration_Header_t
;
407 /** \brief Standard USB Configuration Descriptor (USB-IF naming conventions).
409 * Type define for a standard Configuration Descriptor header. This structure uses the relevant standard's given element names
410 * to ensure compatibility with the standard.
412 * \see \ref USB_Descriptor_Device_t for the version of this type with non-standard LUFA specific element names.
416 uint8_t bLength
; /**< Size of the descriptor, in bytes. */
417 uint8_t bDescriptorType
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
418 * given by the specific class.
420 uint16_t wTotalLength
; /**< Size of the configuration descriptor header,
421 * and all sub descriptors inside the configuration.
423 uint8_t bNumInterfaces
; /**< Total number of interfaces in the configuration. */
424 uint8_t bConfigurationValue
; /**< Configuration index of the current configuration. */
425 uint8_t iConfiguration
; /**< Index of a string descriptor describing the configuration. */
426 uint8_t bmAttributes
; /**< Configuration attributes, comprised of a mask of zero or
427 * more USB_CONFIG_ATTR_* masks.
429 uint8_t bMaxPower
; /**< Maximum power consumption of the device while in the
430 * current configuration, calculated by the \ref USB_CONFIG_POWER_MA()
433 } ATTR_PACKED USB_StdDescriptor_Configuration_Header_t
;
435 /** \brief Standard USB Interface Descriptor (LUFA naming conventions).
437 * Type define for a standard Interface Descriptor. This structure uses LUFA-specific element names
438 * to make each element's purpose clearer.
440 * \see \ref USB_StdDescriptor_Interface_t for the version of this type with standard element names.
444 USB_Descriptor_Header_t Header
; /**< Descriptor header, including type and size. */
446 uint8_t InterfaceNumber
; /**< Index of the interface in the current configuration. */
447 uint8_t AlternateSetting
; /**< Alternate setting for the interface number. The same
448 * interface number can have multiple alternate settings
449 * with different endpoint configurations, which can be
450 * selected by the host.
452 uint8_t TotalEndpoints
; /**< Total number of endpoints in the interface. */
454 uint8_t Class
; /**< Interface class ID. */
455 uint8_t SubClass
; /**< Interface subclass ID. */
456 uint8_t Protocol
; /**< Interface protocol ID. */
458 uint8_t InterfaceStrIndex
; /**< Index of the string descriptor describing the interface. */
459 } ATTR_PACKED USB_Descriptor_Interface_t
;
461 /** \brief Standard USB Interface Descriptor (USB-IF naming conventions).
463 * Type define for a standard Interface Descriptor. This structure uses the relevant standard's given element names
464 * to ensure compatibility with the standard.
466 * \see \ref USB_Descriptor_Interface_t for the version of this type with non-standard LUFA specific element names.
470 uint8_t bLength
; /**< Size of the descriptor, in bytes. */
471 uint8_t bDescriptorType
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
472 * given by the specific class.
474 uint8_t bInterfaceNumber
; /**< Index of the interface in the current configuration. */
475 uint8_t bAlternateSetting
; /**< Alternate setting for the interface number. The same
476 * interface number can have multiple alternate settings
477 * with different endpoint configurations, which can be
478 * selected by the host.
480 uint8_t bNumEndpoints
; /**< Total number of endpoints in the interface. */
481 uint8_t bInterfaceClass
; /**< Interface class ID. */
482 uint8_t bInterfaceSubClass
; /**< Interface subclass ID. */
483 uint8_t bInterfaceProtocol
; /**< Interface protocol ID. */
484 uint8_t iInterface
; /**< Index of the string descriptor describing the
487 } ATTR_PACKED USB_StdDescriptor_Interface_t
;
489 /** \brief Standard USB Interface Association Descriptor (LUFA naming conventions).
491 * Type define for a standard Interface Association Descriptor. This structure uses LUFA-specific element names
492 * to make each element's purpose clearer.
494 * This descriptor has been added as a supplement to the USB2.0 standard, in the ECN located at
495 * <a>http://www.usb.org/developers/docs/InterfaceAssociationDescriptor_ecn.pdf</a>. It allows composite
496 * devices with multiple interfaces related to the same function to have the multiple interfaces bound
497 * together at the point of enumeration, loading one generic driver for all the interfaces in the single
498 * function. Read the ECN for more information.
500 * \see \ref USB_StdDescriptor_Interface_Association_t for the version of this type with standard element names.
504 USB_Descriptor_Header_t Header
; /**< Descriptor header, including type and size. */
506 uint8_t FirstInterfaceIndex
; /**< Index of the first associated interface. */
507 uint8_t TotalInterfaces
; /**< Total number of associated interfaces. */
509 uint8_t Class
; /**< Interface class ID. */
510 uint8_t SubClass
; /**< Interface subclass ID. */
511 uint8_t Protocol
; /**< Interface protocol ID. */
513 uint8_t IADStrIndex
; /**< Index of the string descriptor describing the
514 * interface association.
516 } ATTR_PACKED USB_Descriptor_Interface_Association_t
;
518 /** \brief Standard USB Interface Association Descriptor (USB-IF naming conventions).
520 * Type define for a standard Interface Association Descriptor. This structure uses the relevant standard's given
521 * element names to ensure compatibility with the standard.
523 * This descriptor has been added as a supplement to the USB2.0 standard, in the ECN located at
524 * <a>http://www.usb.org/developers/docs/InterfaceAssociationDescriptor_ecn.pdf</a>. It allows composite
525 * devices with multiple interfaces related to the same function to have the multiple interfaces bound
526 * together at the point of enumeration, loading one generic driver for all the interfaces in the single
527 * function. Read the ECN for more information.
529 * \see \ref USB_Descriptor_Interface_Association_t for the version of this type with non-standard LUFA specific
534 uint8_t bLength
; /**< Size of the descriptor, in bytes. */
535 uint8_t bDescriptorType
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
536 * given by the specific class.
538 uint8_t bFirstInterface
; /**< Index of the first associated interface. */
539 uint8_t bInterfaceCount
; /**< Total number of associated interfaces. */
540 uint8_t bFunctionClass
; /**< Interface class ID. */
541 uint8_t bFunctionSubClass
; /**< Interface subclass ID. */
542 uint8_t bFunctionProtocol
; /**< Interface protocol ID. */
543 uint8_t iFunction
; /**< Index of the string descriptor describing the
544 * interface association.
546 } ATTR_PACKED USB_StdDescriptor_Interface_Association_t
;
548 /** \brief Standard USB Endpoint Descriptor (LUFA naming conventions).
550 * Type define for a standard Endpoint Descriptor. This structure uses LUFA-specific element names
551 * to make each element's purpose clearer.
553 * \see \ref USB_StdDescriptor_Endpoint_t for the version of this type with standard element names.
557 USB_Descriptor_Header_t Header
; /**< Descriptor header, including type and size. */
559 uint8_t EndpointAddress
; /**< Logical address of the endpoint within the device for the current
560 * configuration, including direction mask.
562 uint8_t Attributes
; /**< Endpoint attributes, comprised of a mask of the endpoint type (EP_TYPE_*)
563 * and attributes (ENDPOINT_ATTR_*) masks.
565 uint16_t EndpointSize
; /**< Size of the endpoint bank, in bytes. This indicates the maximum packet
566 * size that the endpoint can receive at a time.
568 uint8_t PollingIntervalMS
; /**< Polling interval in milliseconds for the endpoint if it is an INTERRUPT
569 * or ISOCHRONOUS type.
571 } ATTR_PACKED USB_Descriptor_Endpoint_t
;
573 /** \brief Standard USB Endpoint Descriptor (USB-IF naming conventions).
575 * Type define for a standard Endpoint Descriptor. This structure uses the relevant standard's given
576 * element names to ensure compatibility with the standard.
578 * \see \ref USB_Descriptor_Endpoint_t for the version of this type with non-standard LUFA specific
583 uint8_t bLength
; /**< Size of the descriptor, in bytes. */
584 uint8_t bDescriptorType
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a
585 * value given by the specific class.
587 uint8_t bEndpointAddress
; /**< Logical address of the endpoint within the device for the current
588 * configuration, including direction mask.
590 uint8_t bmAttributes
; /**< Endpoint attributes, comprised of a mask of the endpoint type (EP_TYPE_*)
591 * and attributes (ENDPOINT_ATTR_*) masks.
593 uint16_t wMaxPacketSize
; /**< Size of the endpoint bank, in bytes. This indicates the maximum packet size
594 * that the endpoint can receive at a time.
596 uint8_t bInterval
; /**< Polling interval in milliseconds for the endpoint if it is an INTERRUPT or
599 } ATTR_PACKED USB_StdDescriptor_Endpoint_t
;
601 /** \brief Standard USB String Descriptor (LUFA naming conventions).
603 * Type define for a standard string descriptor. Unlike other standard descriptors, the length
604 * of the descriptor for placement in the descriptor header must be determined by the \ref USB_STRING_LEN()
605 * macro rather than by the size of the descriptor structure, as the length is not fixed.
607 * This structure should also be used for string index 0, which contains the supported language IDs for
608 * the device as an array.
610 * This structure uses LUFA-specific element names to make each element's purpose clearer.
612 * \see \ref USB_StdDescriptor_String_t for the version of this type with standard element names.
616 USB_Descriptor_Header_t Header
; /**< Descriptor header, including type and size. */
618 #if (ARCH == ARCH_AVR8)
619 wchar_t UnicodeString
[];
621 uint16_t UnicodeString
[]; /**< String data, as unicode characters (alternatively,
622 * string language IDs). If normal ASCII characters are
623 * to be used, they must be added as an array of characters
624 * rather than a normal C string so that they are widened to
627 * Under GCC, strings prefixed with the "L" character (before
628 * the opening string quotation mark) are considered to be
629 * Unicode strings, and may be used instead of an explicit
630 * array of ASCII characters.
633 } ATTR_PACKED USB_Descriptor_String_t
;
635 /** \brief Standard USB String Descriptor (USB-IF naming conventions).
637 * Type define for a standard string descriptor. Unlike other standard descriptors, the length
638 * of the descriptor for placement in the descriptor header must be determined by the \ref USB_STRING_LEN()
639 * macro rather than by the size of the descriptor structure, as the length is not fixed.
641 * This structure should also be used for string index 0, which contains the supported language IDs for
642 * the device as an array.
644 * This structure uses the relevant standard's given element names to ensure compatibility with the standard.
646 * \see \ref USB_Descriptor_String_t for the version of this type with with non-standard LUFA specific
651 uint8_t bLength
; /**< Size of the descriptor, in bytes. */
652 uint8_t bDescriptorType
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t
653 * or a value given by the specific class.
655 uint16_t bString
[]; /**< String data, as unicode characters (alternatively, string language IDs).
656 * If normal ASCII characters are to be used, they must be added as an array
657 * of characters rather than a normal C string so that they are widened to
660 * Under GCC, strings prefixed with the "L" character (before the opening string
661 * quotation mark) are considered to be Unicode strings, and may be used instead
662 * of an explicit array of ASCII characters.
664 } ATTR_PACKED USB_StdDescriptor_String_t
;
666 /* Private Interface - For use in library only: */
667 #if !defined(__DOXYGEN__)
669 #define VERSION_TENS(x) (int)((x) / 10)
670 #define VERSION_ONES(x) (int)((x) - (10 * VERSION_TENS(x)))
671 #define VERSION_TENTHS(x) (int)(((x) - (int)(x)) * 10)
672 #define VERSION_HUNDREDTHS(x) (int)((((x) - (int)(x)) * 100) - (10 * VERSION_TENTHS(x)))
675 /* Disable C linkage for C++ Compilers: */
676 #if defined(__cplusplus)