3 Copyright (C) Dean Camera, 2010.
5 dean [at] fourwalledcubicle [dot] com
6 www.fourwalledcubicle.com
10 Copyright 2010 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 USB standard descriptor definitions.
34 * This file contains structures and macros for the easy creation of standard USB descriptors in USB device projects.
36 * \note This file should not be included directly. It is automatically included as needed by the USB driver
37 * dispatch header located in LUFA/Drivers/USB/USB.h.
40 /** \ingroup Group_USB
41 * @defgroup Group_Descriptors USB Descriptors
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 <avr/pgmspace.h>
58 #include "../../../Common/Common.h"
62 #if defined(USB_CAN_BE_DEVICE)
63 #include "../LowLevel/Device.h"
66 /* Enable C linkage for C++ Compilers: */
67 #if defined(__cplusplus)
71 /* Preprocessor Checks: */
72 #if !defined(__INCLUDE_FROM_USB_DRIVER)
73 #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
76 /* Public Interface - May be used in end-application: */
78 /** Indicates that a given descriptor does not exist in the device. This can be used inside descriptors
79 * for string descriptor indexes, or may be use as a return value for GetDescriptor when the specified
80 * descriptor does not exist.
82 #define NO_DESCRIPTOR 0
84 #if (!defined(NO_INTERNAL_SERIAL) && \
85 (defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1287__) || \
86 defined(__AVR_ATmega32U6__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) || \
87 defined(__AVR_ATmega32U2__) || defined(__AVR_ATmega16U2__) || defined(__AVR_ATmega8U2__)))
88 /** String descriptor index for the device's unique serial number string descriptor within the device.
89 * This unique serial number is used by the host to associate resources to the device (such as drivers or COM port
90 * number allocations) to a device regardless of the port it is plugged in to on the host. Some USB AVRs contain
91 * a unique serial number internally, and setting the device descriptors serial number string index to this value
92 * will cause it to use the internal serial number.
94 * On unsupported devices, this will evaluate to NO_DESCRIPTOR and so will force the host to create a pseudo-serial
95 * number for the device.
97 #define USE_INTERNAL_SERIAL 0xDC
99 #define USE_INTERNAL_SERIAL NO_DESCRIPTOR
102 /** Macro to calculate the power value for the configuration descriptor, from a given number of milliamperes. */
103 #define USB_CONFIG_POWER_MA(mA) ((mA) >> 1)
105 /** Macro to calculate the Unicode length of a string with a given number of Unicode characters.
106 * Should be used in string descriptor's headers for giving the string descriptor's byte length.
108 #define USB_STRING_LEN(str) (sizeof(USB_Descriptor_Header_t) + ((str) << 1))
110 /** Macro to encode a given four digit floating point version number (e.g. 01.23) into Binary Coded
111 * Decimal format for descriptor fields requiring BCD encoding, such as the USB version number in the
112 * standard device descriptor.
114 #define VERSION_BCD(x) ((((VERSION_TENS(x) << 4) | VERSION_ONES(x)) << 8) | \
115 ((VERSION_TENTHS(x) << 4) | VERSION_HUNDREDTHS(x)))
117 /** String language ID for the English language. Should be used in \ref USB_Descriptor_String_t descriptors
118 * to indicate that the English language is supported by the device in its string descriptors.
120 #define LANGUAGE_ID_ENG 0x0409
122 /** Can be masked with an endpoint address for a \ref USB_Descriptor_Endpoint_t endpoint descriptor's
123 * EndpointAddress value to indicate to the host that the endpoint is of the IN direction (i.e, from
126 #define ENDPOINT_DESCRIPTOR_DIR_IN 0x80
128 /** Can be masked with an endpoint address for a \ref USB_Descriptor_Endpoint_t endpoint descriptor's
129 * EndpointAddress value to indicate to the host that the endpoint is of the OUT direction (i.e, from
132 #define ENDPOINT_DESCRIPTOR_DIR_OUT 0x00
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 can draw its power
136 * from the host's VBUS line.
138 #define USB_CONFIG_ATTR_BUSPOWERED 0x80
140 /** Can be masked with other configuration descriptor attributes for a \ref USB_Descriptor_Configuration_Header_t
141 * descriptor's ConfigAttributes value to indicate that the specified configuration can draw its power
142 * from the device's own power source.
144 #define USB_CONFIG_ATTR_SELFPOWERED 0x40
146 /** Can be masked with other configuration descriptor attributes for a \ref USB_Descriptor_Configuration_Header_t
147 * descriptor's ConfigAttributes value to indicate that the specified configuration supports the
148 * remote wakeup feature of the USB standard, allowing a suspended USB device to wake up the host upon
151 #define USB_CONFIG_ATTR_REMOTEWAKEUP 0x20
153 /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
154 * Attributes value to indicate that the specified endpoint is not synchronized.
156 * \see The USB specification for more details on the possible Endpoint attributes.
158 #define ENDPOINT_ATTR_NO_SYNC (0 << 2)
160 /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
161 * Attributes value to indicate that the specified endpoint is asynchronous.
163 * \see The USB specification for more details on the possible Endpoint attributes.
165 #define ENDPOINT_ATTR_ASYNC (1 << 2)
167 /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
168 * Attributes value to indicate that the specified endpoint is adaptive.
170 * \see The USB specification for more details on the possible Endpoint attributes.
172 #define ENDPOINT_ATTR_ADAPTIVE (2 << 2)
174 /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
175 * Attributes value to indicate that the specified endpoint is synchronized.
177 * \see The USB specification for more details on the possible Endpoint attributes.
179 #define ENDPOINT_ATTR_SYNC (3 << 2)
181 /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
182 * Attributes value to indicate that the specified endpoint is used for data transfers.
184 * \see The USB specification for more details on the possible Endpoint usage attributes.
186 #define ENDPOINT_USAGE_DATA (0 << 4)
188 /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
189 * Attributes value to indicate that the specified endpoint is used for feedback.
191 * \see The USB specification for more details on the possible Endpoint usage attributes.
193 #define ENDPOINT_USAGE_FEEDBACK (1 << 4)
195 /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
196 * Attributes value to indicate that the specified endpoint is used for implicit feedback.
198 * \see The USB specification for more details on the possible Endpoint usage attributes.
200 #define ENDPOINT_USAGE_IMPLICIT_FEEDBACK (2 << 4)
203 /** Enum for the possible standard descriptor types, as given in each descriptor's header. */
204 enum USB_DescriptorTypes_t
206 DTYPE_Device
= 0x01, /**< Indicates that the descriptor is a device descriptor. */
207 DTYPE_Configuration
= 0x02, /**< Indicates that the descriptor is a configuration descriptor. */
208 DTYPE_String
= 0x03, /**< Indicates that the descriptor is a string descriptor. */
209 DTYPE_Interface
= 0x04, /**< Indicates that the descriptor is an interface descriptor. */
210 DTYPE_Endpoint
= 0x05, /**< Indicates that the descriptor is an endpoint descriptor. */
211 DTYPE_DeviceQualifier
= 0x06, /**< Indicates that the descriptor is a device qualifier descriptor. */
212 DTYPE_Other
= 0x07, /**< Indicates that the descriptor is of other type. */
213 DTYPE_InterfacePower
= 0x08, /**< Indicates that the descriptor is an interface power descriptor. */
214 DTYPE_InterfaceAssociation
= 0x0B, /**< Indicates that the descriptor is an interface association descriptor. */
215 DTYPE_CSInterface
= 0x24, /**< Indicates that the descriptor is a class specific interface descriptor. */
216 DTYPE_CSEndpoint
= 0x25, /**< Indicates that the descriptor is a class specific endpoint descriptor. */
220 /** \brief Standard USB Descriptor Header (LUFA naming conventions).
222 * Type define for all descriptors' standard header, indicating the descriptor's length and type. This structure
223 * uses LUFA-specific element names to make each element's purpose clearer.
225 * \see \ref USB_StdDescriptor_Header_t for the version of this type with standard element names.
229 uint8_t Size
; /**< Size of the descriptor, in bytes. */
230 uint8_t Type
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
231 * given by the specific class.
233 } USB_Descriptor_Header_t
;
235 /** \brief Standard USB Descriptor Header (USB-IF naming conventions).
237 * Type define for all descriptors' standard header, indicating the descriptor's length and type. This structure
238 * uses the relevant standard's given element names to ensure compatibility with the standard.
240 * \see \ref USB_Descriptor_Header_t for the version of this type with non-standard LUFA specific element names.
244 uint8_t bLength
; /**< Size of the descriptor, in bytes. */
245 uint8_t bDescriptorType
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
246 * given by the specific class.
248 } USB_StdDescriptor_Header_t
;
250 /** \brief Standard USB Device Descriptor (LUFA naming conventions).
252 * Type define for a standard Device Descriptor. This structure uses LUFA-specific element names to make each
253 * element's purpose clearer.
255 * \see \ref USB_StdDescriptor_Device_t for the version of this type with standard element names.
259 USB_Descriptor_Header_t Header
; /**< Descriptor header, including type and size. */
261 uint16_t USBSpecification
; /**< BCD of the supported USB specification. */
262 uint8_t Class
; /**< USB device class. */
263 uint8_t SubClass
; /**< USB device subclass. */
264 uint8_t Protocol
; /**< USB device protocol. */
266 uint8_t Endpoint0Size
; /**< Size of the control (address 0) endpoint's bank in bytes. */
268 uint16_t VendorID
; /**< Vendor ID for the USB product. */
269 uint16_t ProductID
; /**< Unique product ID for the USB product. */
270 uint16_t ReleaseNumber
; /**< Product release (version) number. */
272 uint8_t ManufacturerStrIndex
; /**< String index for the manufacturer's name. The
273 * host will request this string via a separate
274 * control request for the string descriptor.
276 * \note If no string supplied, use \ref NO_DESCRIPTOR.
278 uint8_t ProductStrIndex
; /**< String index for the product name/details.
280 * \see ManufacturerStrIndex structure entry.
282 uint8_t SerialNumStrIndex
; /**< String index for the product's globally unique hexadecimal
283 * serial number, in uppercase Unicode ASCII.
285 * \note On some AVR models, there is an embedded serial number
286 * in the chip which can be used for the device serial number.
287 * To use this serial number, set this to USE_INTERNAL_SERIAL.
288 * On unsupported devices, this will evaluate to 0 and will cause
289 * the host to generate a pseudo-unique value for the device upon
292 * \see ManufacturerStrIndex structure entry.
294 uint8_t NumberOfConfigurations
; /**< Total number of configurations supported by
297 } USB_Descriptor_Device_t
;
299 /** \brief Standard USB Device Descriptor (USB-IF naming conventions).
301 * Type define for a standard Device Descriptor. This structure uses the relevant standard's given element names
302 * to ensure compatibility with the standard.
304 * \see \ref USB_Descriptor_Device_t for the version of this type with non-standard LUFA specific element names.
308 uint8_t bLength
; /**< Size of the descriptor, in bytes. */
309 uint8_t bDescriptorType
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
310 * given by the specific class.
312 uint16_t bcdUSB
; /**< BCD of the supported USB specification. */
313 uint8_t bDeviceClass
; /**< USB device class. */
314 uint8_t bDeviceSubClass
; /**< USB device subclass. */
315 uint8_t bDeviceProtocol
; /**< USB device protocol. */
316 uint8_t bMaxPacketSize0
; /**< Size of the control (address 0) endpoint's bank in bytes. */
317 uint16_t idVendor
; /**< Vendor ID for the USB product. */
318 uint16_t idProduct
; /**< Unique product ID for the USB product. */
319 uint16_t bcdDevice
; /**< Product release (version) number. */
320 uint8_t iManufacturer
; /**< String index for the manufacturer's name. The
321 * host will request this string via a separate
322 * control request for the string descriptor.
324 * \note If no string supplied, use \ref NO_DESCRIPTOR.
326 uint8_t iProduct
; /**< String index for the product name/details.
328 * \see ManufacturerStrIndex structure entry.
330 uint8_t iSerialNumber
; /**< String index for the product's globally unique hexadecimal
331 * serial number, in uppercase Unicode ASCII.
333 * \note On some AVR models, there is an embedded serial number
334 * in the chip which can be used for the device serial number.
335 * To use this serial number, set this to USE_INTERNAL_SERIAL.
336 * On unsupported devices, this will evaluate to 0 and will cause
337 * the host to generate a pseudo-unique value for the device upon
340 * \see ManufacturerStrIndex structure entry.
342 uint8_t bNumConfigurations
; /**< Total number of configurations supported by
345 } USB_StdDescriptor_Device_t
;
347 /** \brief Standard USB Configuration Descriptor (LUFA naming conventions).
349 * Type define for a standard Configuration Descriptor header. This structure uses LUFA-specific element names
350 * to make each element's purpose clearer.
352 * \see \ref USB_StdDescriptor_Configuration_Header_t for the version of this type with standard element names.
356 USB_Descriptor_Header_t Header
; /**< Descriptor header, including type and size. */
358 uint16_t TotalConfigurationSize
; /**< Size of the configuration descriptor header,
359 * and all sub descriptors inside the configuration.
361 uint8_t TotalInterfaces
; /**< Total number of interfaces in the configuration. */
363 uint8_t ConfigurationNumber
; /**< Configuration index of the current configuration. */
364 uint8_t ConfigurationStrIndex
; /**< Index of a string descriptor describing the configuration. */
366 uint8_t ConfigAttributes
; /**< Configuration attributes, comprised of a mask of zero or
367 * more USB_CONFIG_ATTR_* masks.
370 uint8_t MaxPowerConsumption
; /**< Maximum power consumption of the device while in the
371 * current configuration, calculated by the \ref USB_CONFIG_POWER_MA()
374 } USB_Descriptor_Configuration_Header_t
;
376 /** \brief Standard USB Configuration Descriptor (USB-IF naming conventions).
378 * Type define for a standard Configuration Descriptor header. This structure uses the relevant standard's given element names
379 * to ensure compatibility with the standard.
381 * \see \ref USB_Descriptor_Device_t for the version of this type with non-standard LUFA specific element names.
385 uint8_t bLength
; /**< Size of the descriptor, in bytes. */
386 uint8_t bDescriptorType
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
387 * given by the specific class.
389 uint16_t wTotalLength
; /**< Size of the configuration descriptor header,
390 * and all sub descriptors inside the configuration.
392 uint8_t bNumInterfaces
; /**< Total number of interfaces in the configuration. */
393 uint8_t bConfigurationValue
; /**< Configuration index of the current configuration. */
394 uint8_t iConfiguration
; /**< Index of a string descriptor describing the configuration. */
395 uint8_t bmAttributes
; /**< Configuration attributes, comprised of a mask of zero or
396 * more USB_CONFIG_ATTR_* masks.
398 uint8_t bMaxPower
; /**< Maximum power consumption of the device while in the
399 * current configuration, calculated by the \ref USB_CONFIG_POWER_MA()
402 } USB_StdDescriptor_Configuration_Header_t
;
404 /** \brief Standard USB Interface Descriptor (LUFA naming conventions).
406 * Type define for a standard Interface Descriptor. This structure uses LUFA-specific element names
407 * to make each element's purpose clearer.
409 * \see \ref USB_StdDescriptor_Interface_t for the version of this type with standard element names.
413 USB_Descriptor_Header_t Header
; /**< Descriptor header, including type and size. */
415 uint8_t InterfaceNumber
; /**< Index of the interface in the current configuration. */
416 uint8_t AlternateSetting
; /**< Alternate setting for the interface number. The same
417 * interface number can have multiple alternate settings
418 * with different endpoint configurations, which can be
419 * selected by the host.
421 uint8_t TotalEndpoints
; /**< Total number of endpoints in the interface. */
423 uint8_t Class
; /**< Interface class ID. */
424 uint8_t SubClass
; /**< Interface subclass ID. */
425 uint8_t Protocol
; /**< Interface protocol ID. */
427 uint8_t InterfaceStrIndex
; /**< Index of the string descriptor describing the interface. */
428 } USB_Descriptor_Interface_t
;
430 /** \brief Standard USB Interface Descriptor (USB-IF naming conventions).
432 * Type define for a standard Interface Descriptor. This structure uses the relevant standard's given element names
433 * to ensure compatibility with the standard.
435 * \see \ref USB_Descriptor_Interface_t for the version of this type with non-standard LUFA specific element names.
439 uint8_t bLength
; /**< Size of the descriptor, in bytes. */
440 uint8_t bDescriptorType
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
441 * given by the specific class.
443 uint8_t bInterfaceNumber
; /**< Index of the interface in the current configuration. */
444 uint8_t bAlternateSetting
; /**< Alternate setting for the interface number. The same
445 * interface number can have multiple alternate settings
446 * with different endpoint configurations, which can be
447 * selected by the host.
449 uint8_t bNumEndpoints
; /**< Total number of endpoints in the interface. */
450 uint8_t bInterfaceClass
; /**< Interface class ID. */
451 uint8_t bInterfaceSubClass
; /**< Interface subclass ID. */
452 uint8_t bInterfaceProtocol
; /**< Interface protocol ID. */
453 uint8_t iInterface
; /**< Index of the string descriptor describing the
456 } USB_StdDescriptor_Interface_t
;
458 /** \brief Standard USB Interface Association Descriptor (LUFA naming conventions).
460 * Type define for a standard Interface Association Descriptor. This structure uses LUFA-specific element names
461 * to make each element's purpose clearer.
463 * This descriptor has been added as a supplement to the USB2.0 standard, in the ECN located at
464 * <a>http://www.usb.org/developers/docs/InterfaceAssociationDescriptor_ecn.pdf</a>. It allows composite
465 * devices with multiple interfaces related to the same function to have the multiple interfaces bound
466 * together at the point of enumeration, loading one generic driver for all the interfaces in the single
467 * function. Read the ECN for more information.
469 * \see \ref USB_StdDescriptor_Interface_Association_t for the version of this type with standard element names.
473 USB_Descriptor_Header_t Header
; /**< Descriptor header, including type and size. */
475 uint8_t FirstInterfaceIndex
; /**< Index of the first associated interface. */
476 uint8_t TotalInterfaces
; /**< Total number of associated interfaces. */
478 uint8_t Class
; /**< Interface class ID. */
479 uint8_t SubClass
; /**< Interface subclass ID. */
480 uint8_t Protocol
; /**< Interface protocol ID. */
482 uint8_t IADStrIndex
; /**< Index of the string descriptor describing the
483 * interface association.
485 } USB_Descriptor_Interface_Association_t
;
487 /** \brief Standard USB Interface Association Descriptor (USB-IF naming conventions).
489 * Type define for a standard Interface Association Descriptor. This structure uses the relevant standard's given
490 * element names to ensure compatibility with the standard.
492 * This descriptor has been added as a supplement to the USB2.0 standard, in the ECN located at
493 * <a>http://www.usb.org/developers/docs/InterfaceAssociationDescriptor_ecn.pdf</a>. It allows composite
494 * devices with multiple interfaces related to the same function to have the multiple interfaces bound
495 * together at the point of enumeration, loading one generic driver for all the interfaces in the single
496 * function. Read the ECN for more information.
498 * \see \ref USB_Descriptor_Interface_Association_t for the version of this type with non-standard LUFA specific
503 uint8_t bLength
; /**< Size of the descriptor, in bytes. */
504 uint8_t bDescriptorType
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
505 * given by the specific class.
507 uint8_t bFirstInterface
; /**< Index of the first associated interface. */
508 uint8_t bInterfaceCount
; /**< Total number of associated interfaces. */
509 uint8_t bFunctionClass
; /**< Interface class ID. */
510 uint8_t bFunctionSubClass
; /**< Interface subclass ID. */
511 uint8_t bFunctionProtocol
; /**< Interface protocol ID. */
512 uint8_t iFunction
; /**< Index of the string descriptor describing the
513 * interface association.
515 } USB_StdDescriptor_Interface_Association_t
;
517 /** \brief Standard USB Endpoint Descriptor (LUFA naming conventions).
519 * Type define for a standard Endpoint Descriptor. This structure uses LUFA-specific element names
520 * to make each element's purpose clearer.
522 * \see \ref USB_StdDescriptor_Endpoint_t for the version of this type with standard element names.
526 USB_Descriptor_Header_t Header
; /**< Descriptor header, including type and size. */
528 uint8_t EndpointAddress
; /**< Logical address of the endpoint within the device for the current
529 * configuration, including direction mask.
531 uint8_t Attributes
; /**< Endpoint attributes, comprised of a mask of the endpoint type (EP_TYPE_*)
532 * and attributes (ENDPOINT_ATTR_*) masks.
534 uint16_t EndpointSize
; /**< Size of the endpoint bank, in bytes. This indicates the maximum packet
535 * size that the endpoint can receive at a time.
537 uint8_t PollingIntervalMS
; /**< Polling interval in milliseconds for the endpoint if it is an INTERRUPT
538 * or ISOCHRONOUS type.
540 } USB_Descriptor_Endpoint_t
;
542 /** \brief Standard USB Endpoint Descriptor (USB-IF naming conventions).
544 * Type define for a standard Endpoint Descriptor. This structure uses the relevant standard's given
545 * element names to ensure compatibility with the standard.
547 * \see \ref USB_Descriptor_Endpoint_t for the version of this type with non-standard LUFA specific
552 uint8_t bLength
; /**< Size of the descriptor, in bytes. */
553 uint8_t bDescriptorType
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a
554 * value given by the specific class.
556 uint8_t bEndpointAddress
; /**< Logical address of the endpoint within the device for the current
557 * configuration, including direction mask.
559 uint8_t bmAttributes
; /**< Endpoint attributes, comprised of a mask of the endpoint type (EP_TYPE_*)
560 * and attributes (ENDPOINT_ATTR_*) masks.
562 uint16_t wMaxPacketSize
; /**< Size of the endpoint bank, in bytes. This indicates the maximum packet size
563 * that the endpoint can receive at a time.
565 uint8_t bInterval
; /**< Polling interval in milliseconds for the endpoint if it is an INTERRUPT or
568 } USB_StdDescriptor_Endpoint_t
;
570 /** \brief Standard USB String Descriptor (LUFA naming conventions).
572 * Type define for a standard string descriptor. Unlike other standard descriptors, the length
573 * of the descriptor for placement in the descriptor header must be determined by the \ref USB_STRING_LEN()
574 * macro rather than by the size of the descriptor structure, as the length is not fixed.
576 * This structure should also be used for string index 0, which contains the supported language IDs for
577 * the device as an array.
579 * This structure uses LUFA-specific element names to make each element's purpose clearer.
581 * \see \ref USB_StdDescriptor_String_t for the version of this type with standard element names.
585 USB_Descriptor_Header_t Header
; /**< Descriptor header, including type and size. */
587 wchar_t UnicodeString
[]; /**< String data, as unicode characters (alternatively,
588 * string language IDs). If normal ASCII characters are
589 * to be used, they must be added as an array of characters
590 * rather than a normal C string so that they are widened to
593 * Under GCC, strings prefixed with the "L" character (before
594 * the opening string quotation mark) are considered to be
595 * Unicode strings, and may be used instead of an explicit
596 * array of ASCII characters.
598 } USB_Descriptor_String_t
;
600 /** \brief Standard USB String Descriptor (USB-IF naming conventions).
602 * Type define for a standard string descriptor. Unlike other standard descriptors, the length
603 * of the descriptor for placement in the descriptor header must be determined by the \ref USB_STRING_LEN()
604 * macro rather than by the size of the descriptor structure, as the length is not fixed.
606 * This structure should also be used for string index 0, which contains the supported language IDs for
607 * the device as an array.
609 * This structure uses the relevant standard's given element names to ensure compatibility with the standard.
611 * \see \ref USB_Descriptor_String_t for the version of this type with with non-standard LUFA specific
616 uint8_t bLength
; /**< Size of the descriptor, in bytes. */
617 uint8_t bDescriptorType
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t
618 * or a value given by the specific class.
620 int16_t bString
[]; /**< String data, as unicode characters (alternatively, string language IDs).
621 * If normal ASCII characters are to be used, they must be added as an array
622 * of characters rather than a normal C string so that they are widened to
625 * Under GCC, strings prefixed with the "L" character (before the opening string
626 * quotation mark) are considered to be Unicode strings, and may be used instead
627 * of an explicit array of ASCII characters.
629 } USB_StdDescriptor_String_t
;
631 /* Private Interface - For use in library only: */
632 #if !defined(__DOXYGEN__)
634 #define VERSION_TENS(x) (int)((x) / 10)
635 #define VERSION_ONES(x) (int)((x) - (10 * VERSION_TENS(x)))
636 #define VERSION_TENTHS(x) (int)(((x) - (int)(x)) * 10)
637 #define VERSION_HUNDREDTHS(x) (int)((((x) - (int)(x)) * 100) - (10 * VERSION_TENTHS(x)))
640 /* Disable C linkage for C++ Compilers: */
641 #if defined(__cplusplus)