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>
57 #include "../../../Common/Common.h"
61 #if defined(USB_CAN_BE_DEVICE)
62 #include "../LowLevel/Device.h"
65 /* Enable C linkage for C++ Compilers: */
66 #if defined(__cplusplus)
70 /* Preprocessor Checks: */
71 #if !defined(__INCLUDE_FROM_USB_DRIVER)
72 #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
75 /* Public Interface - May be used in end-application: */
77 /** Indicates that a given descriptor does not exist in the device. This can be used inside descriptors
78 * for string descriptor indexes, or may be use as a return value for GetDescriptor when the specified
79 * descriptor does not exist.
81 #define NO_DESCRIPTOR 0
83 #if (!defined(NO_INTERNAL_SERIAL) && (defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR))) || defined(__DOXYGEN__)
84 /** String descriptor index for the device's unique serial number string descriptor within the device.
85 * This unique serial number is used by the host to associate resources to the device (such as drivers or COM port
86 * number allocations) to a device regardless of the port it is plugged in to on the host. Some USB AVRs contain
87 * a unique serial number internally, and setting the device descriptors serial number string index to this value
88 * will cause it to use the internal serial number.
90 * On unsupported devices, this will evaluate to NO_DESCRIPTOR and so will force the host to create a pseudo-serial
91 * number for the device.
93 #define USE_INTERNAL_SERIAL 0xDC
95 #define USE_INTERNAL_SERIAL NO_DESCRIPTOR
98 /** Macro to calculate the power value for the configuration descriptor, from a given number of milliamps. */
99 #define USB_CONFIG_POWER_MA(mA) ((mA) >> 1)
101 /** Macro to calculate the Unicode length of a string with a given number of Unicode characters.
102 * Should be used in string descriptor's headers for giving the string descriptor's byte length.
104 #define USB_STRING_LEN(str) (sizeof(USB_Descriptor_Header_t) + ((str) << 1))
106 /** Macro to encode a given four digit floating point version number (e.g. 01.23) into Binary Coded
107 * Decimal format for descriptor fields requiring BCD encoding, such as the USB version number in the
108 * standard device descriptor.
110 #define VERSION_BCD(x) ((((VERSION_TENS(x) << 4) | VERSION_ONES(x)) << 8) | \
111 ((VERSION_TENTHS(x) << 4) | VERSION_HUNDREDTHS(x)))
113 /** String language ID for the English language. Should be used in \ref USB_Descriptor_String_t descriptors
114 * to indicate that the English language is supported by the device in its string descriptors.
116 #define LANGUAGE_ID_ENG 0x0409
118 /** Can be masked with an endpoint address for a \ref USB_Descriptor_Endpoint_t endpoint descriptor's
119 * EndpointAddress value to indicate to the host that the endpoint is of the IN direction (i.e, from
122 #define ENDPOINT_DESCRIPTOR_DIR_IN 0x80
124 /** Can be masked with an endpoint address for a \ref USB_Descriptor_Endpoint_t endpoint descriptor's
125 * EndpointAddress value to indicate to the host that the endpoint is of the OUT direction (i.e, from
128 #define ENDPOINT_DESCRIPTOR_DIR_OUT 0x00
130 /** Can be masked with other configuration descriptor attributes for a \ref USB_Descriptor_Configuration_Header_t
131 * descriptor's ConfigAttributes value to indicate that the specified configuration can draw its power
132 * from the host's VBUS line.
134 #define USB_CONFIG_ATTR_BUSPOWERED 0x80
136 /** Can be masked with other configuration descriptor attributes for a \ref USB_Descriptor_Configuration_Header_t
137 * descriptor's ConfigAttributes value to indicate that the specified configuration can draw its power
138 * from the device's own power source.
140 #define USB_CONFIG_ATTR_SELFPOWERED 0x40
142 /** Can be masked with other configuration descriptor attributes for a \ref USB_Descriptor_Configuration_Header_t
143 * descriptor's ConfigAttributes value to indicate that the specified configuration supports the
144 * remote wakeup feature of the USB standard, allowing a suspended USB device to wake up the host upon
147 #define USB_CONFIG_ATTR_REMOTEWAKEUP 0x20
149 /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
150 * Attributes value to indicate that the specified endpoint is not synchronized.
152 * \see The USB specification for more details on the possible Endpoint attributes.
154 #define ENDPOINT_ATTR_NO_SYNC (0 << 2)
156 /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
157 * Attributes value to indicate that the specified endpoint is asynchronous.
159 * \see The USB specification for more details on the possible Endpoint attributes.
161 #define ENDPOINT_ATTR_ASYNC (1 << 2)
163 /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
164 * Attributes value to indicate that the specified endpoint is adaptive.
166 * \see The USB specification for more details on the possible Endpoint attributes.
168 #define ENDPOINT_ATTR_ADAPTIVE (2 << 2)
170 /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
171 * Attributes value to indicate that the specified endpoint is synchronized.
173 * \see The USB specification for more details on the possible Endpoint attributes.
175 #define ENDPOINT_ATTR_SYNC (3 << 2)
177 /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
178 * Attributes value to indicate that the specified endpoint is used for data transfers.
180 * \see The USB specification for more details on the possible Endpoint usage attributes.
182 #define ENDPOINT_USAGE_DATA (0 << 4)
184 /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
185 * Attributes value to indicate that the specified endpoint is used for feedback.
187 * \see The USB specification for more details on the possible Endpoint usage attributes.
189 #define ENDPOINT_USAGE_FEEDBACK (1 << 4)
191 /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
192 * Attributes value to indicate that the specified endpoint is used for implicit feedback.
194 * \see The USB specification for more details on the possible Endpoint usage attributes.
196 #define ENDPOINT_USAGE_IMPLICIT_FEEDBACK (2 << 4)
199 /** Enum for the possible standard descriptor types, as given in each descriptor's header. */
200 enum USB_DescriptorTypes_t
202 DTYPE_Device
= 0x01, /**< Indicates that the descriptor is a device descriptor. */
203 DTYPE_Configuration
= 0x02, /**< Indicates that the descriptor is a configuration descriptor. */
204 DTYPE_String
= 0x03, /**< Indicates that the descriptor is a string descriptor. */
205 DTYPE_Interface
= 0x04, /**< Indicates that the descriptor is an interface descriptor. */
206 DTYPE_Endpoint
= 0x05, /**< Indicates that the descriptor is an endpoint descriptor. */
207 DTYPE_DeviceQualifier
= 0x06, /**< Indicates that the descriptor is a device qualifier descriptor. */
208 DTYPE_Other
= 0x07, /**< Indicates that the descriptor is of other type. */
209 DTYPE_InterfacePower
= 0x08, /**< Indicates that the descriptor is an interface power descriptor. */
210 DTYPE_InterfaceAssociation
= 0x0B, /**< Indicates that the descriptor is an interface association descriptor. */
214 /** \brief Standard USB Descriptor Header (LUFA naming conventions).
216 * Type define for all descriptors' standard header, indicating the descriptor's length and type. This structure
217 * uses LUFA-specific element names to make each element's purpose clearer.
219 * \see \ref USB_StdDescriptor_Header_t for the version of this define with standard element names
223 uint8_t Size
; /**< Size of the descriptor, in bytes. */
224 uint8_t Type
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
225 * given by the specific class.
227 } USB_Descriptor_Header_t
;
229 /** \brief Standard USB Descriptor Header (USB-IF naming conventions).
231 * Type define for all descriptors' standard header, indicating the descriptor's length and type. This structure
232 * uses the relevant standard's given element names to ensure compatibility with the standard.
234 * \see \ref USB_Descriptor_Header_t for the version of this define with non-standard LUFA specific element names
238 uint8_t bLength
; /**< Size of the descriptor, in bytes. */
239 uint8_t bDescriptorType
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
240 * given by the specific class.
242 } USB_StdDescriptor_Header_t
;
244 /** \brief Standard USB Device Descriptor (LUFA naming conventions).
246 * Type define for a standard Device Descriptor. This structure uses LUFA-specific element names to make each
247 * element's purpose clearer.
249 * \see \ref USB_StdDescriptor_Device_t for the version of this define with standard element names
253 USB_Descriptor_Header_t Header
; /**< Descriptor header, including type and size. */
255 uint16_t USBSpecification
; /**< BCD of the supported USB specification. */
256 uint8_t Class
; /**< USB device class. */
257 uint8_t SubClass
; /**< USB device subclass. */
258 uint8_t Protocol
; /**< USB device protocol. */
260 uint8_t Endpoint0Size
; /**< Size of the control (address 0) endpoint's bank in bytes. */
262 uint16_t VendorID
; /**< Vendor ID for the USB product. */
263 uint16_t ProductID
; /**< Unique product ID for the USB product. */
264 uint16_t ReleaseNumber
; /**< Product release (version) number. */
266 uint8_t ManufacturerStrIndex
; /**< String index for the manufacturer's name. The
267 * host will request this string via a separate
268 * control request for the string descriptor.
270 * \note If no string supplied, use \ref NO_DESCRIPTOR.
272 uint8_t ProductStrIndex
; /**< String index for the product name/details.
274 * \see ManufacturerStrIndex structure entry.
276 uint8_t SerialNumStrIndex
; /**< String index for the product's globally unique hexadecimal
277 * serial number, in uppercase Unicode ASCII.
279 * \note On some AVR models, there is an embedded serial number
280 * in the chip which can be used for the device serial number.
281 * To use this serial number, set this to USE_INTERNAL_SERIAL.
282 * On unsupported devices, this will evaluate to 0 and will cause
283 * the host to generate a pseudo-unique value for the device upon
286 * \see ManufacturerStrIndex structure entry.
288 uint8_t NumberOfConfigurations
; /**< Total number of configurations supported by
291 } USB_Descriptor_Device_t
;
293 /** \brief Standard USB Device Descriptor (USB-IF naming conventions).
295 * Type define for a standard Device Descriptor. This structure uses the relevant standard's given element names
296 * to ensure compatibility with the standard.
298 * \see \ref USB_Descriptor_Device_t for the version of this define with non-standard LUFA specific element names
302 uint8_t bLength
; /**< Size of the descriptor, in bytes. */
303 uint8_t bDescriptorType
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
304 * given by the specific class.
306 uint16_t bcdUSB
; /**< BCD of the supported USB specification. */
307 uint8_t bDeviceClass
; /**< USB device class. */
308 uint8_t bDeviceSubClass
; /**< USB device subclass. */
309 uint8_t bDeviceProtocol
; /**< USB device protocol. */
310 uint8_t bMaxPacketSize0
; /**< Size of the control (address 0) endpoint's bank in bytes. */
311 uint16_t idVendor
; /**< Vendor ID for the USB product. */
312 uint16_t idProduct
; /**< Unique product ID for the USB product. */
313 uint16_t bcdDevice
; /**< Product release (version) number. */
314 uint8_t iManufacturer
; /**< String index for the manufacturer's name. The
315 * host will request this string via a separate
316 * control request for the string descriptor.
318 * \note If no string supplied, use \ref NO_DESCRIPTOR.
320 uint8_t iProduct
; /**< String index for the product name/details.
322 * \see ManufacturerStrIndex structure entry.
324 uint8_t iSerialNumber
; /**< String index for the product's globally unique hexadecimal
325 * serial number, in uppercase Unicode ASCII.
327 * \note On some AVR models, there is an embedded serial number
328 * in the chip which can be used for the device serial number.
329 * To use this serial number, set this to USE_INTERNAL_SERIAL.
330 * On unsupported devices, this will evaluate to 0 and will cause
331 * the host to generate a pseudo-unique value for the device upon
334 * \see ManufacturerStrIndex structure entry.
336 uint8_t bNumConfigurations
; /**< Total number of configurations supported by
339 } USB_StdDescriptor_Device_t
;
341 /** \brief Standard USB Configuration Descriptor (LUFA naming conventions).
343 * Type define for a standard Configuration Descriptor header. This structure uses LUFA-specific element names
344 * to make each element's purpose clearer.
346 * \see \ref USB_StdDescriptor_Configuration_Header_t for the version of this define with standard element names
350 USB_Descriptor_Header_t Header
; /**< Descriptor header, including type and size. */
352 uint16_t TotalConfigurationSize
; /**< Size of the configuration descriptor header,
353 * and all sub descriptors inside the configuration.
355 uint8_t TotalInterfaces
; /**< Total number of interfaces in the configuration. */
357 uint8_t ConfigurationNumber
; /**< Configuration index of the current configuration. */
358 uint8_t ConfigurationStrIndex
; /**< Index of a string descriptor describing the configuration. */
360 uint8_t ConfigAttributes
; /**< Configuration attributes, comprised of a mask of zero or
361 * more USB_CONFIG_ATTR_* masks.
364 uint8_t MaxPowerConsumption
; /**< Maximum power consumption of the device while in the
365 * current configuration, calculated by the \ref USB_CONFIG_POWER_MA()
368 } USB_Descriptor_Configuration_Header_t
;
370 /** \brief Standard USB Configuration Descriptor (USB-IF naming conventions).
372 * Type define for a standard Configuration Descriptor header. This structure uses the relevant standard's given element names
373 * to ensure compatibility with the standard.
375 * \see \ref USB_Descriptor_Device_t for the version of this define with non-standard LUFA specific element names
379 uint8_t bLength
; /**< Size of the descriptor, in bytes. */
380 uint8_t bDescriptorType
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
381 * given by the specific class.
383 uint16_t wTotalLength
; /**< Size of the configuration descriptor header,
384 * and all sub descriptors inside the configuration.
386 uint8_t bNumInterfaces
; /**< Total number of interfaces in the configuration. */
387 uint8_t bConfigurationValue
; /**< Configuration index of the current configuration. */
388 uint8_t iConfiguration
; /**< Index of a string descriptor describing the configuration. */
389 uint8_t bmAttributes
; /**< Configuration attributes, comprised of a mask of zero or
390 * more USB_CONFIG_ATTR_* masks.
392 uint8_t bMaxPower
; /**< Maximum power consumption of the device while in the
393 * current configuration, calculated by the \ref USB_CONFIG_POWER_MA()
396 } USB_StdDescriptor_Configuration_Header_t
;
398 /** \brief Standard USB Interface Descriptor (LUFA naming conventions).
400 * Type define for a standard Interface Descriptor. This structure uses LUFA-specific element names
401 * to make each element's purpose clearer.
403 * \see \ref USB_StdDescriptor_Interface_t for the version of this define with standard element names
407 USB_Descriptor_Header_t Header
; /**< Descriptor header, including type and size. */
409 uint8_t InterfaceNumber
; /**< Index of the interface in the current configuration. */
410 uint8_t AlternateSetting
; /**< Alternate setting for the interface number. The same
411 * interface number can have multiple alternate settings
412 * with different endpoint configurations, which can be
413 * selected by the host.
415 uint8_t TotalEndpoints
; /**< Total number of endpoints in the interface. */
417 uint8_t Class
; /**< Interface class ID. */
418 uint8_t SubClass
; /**< Interface subclass ID. */
419 uint8_t Protocol
; /**< Interface protocol ID. */
421 uint8_t InterfaceStrIndex
; /**< Index of the string descriptor describing the
424 } USB_Descriptor_Interface_t
;
426 /** \brief Standard USB Interface Descriptor (USB-IF naming conventions).
428 * Type define for a standard Interface Descriptor. This structure uses the relevant standard's given element names
429 * to ensure compatibility with the standard.
431 * \see \ref USB_Descriptor_Interface_t for the version of this define with non-standard LUFA specific element names
435 uint8_t bLength
; /**< Size of the descriptor, in bytes. */
436 uint8_t bDescriptorType
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
437 * given by the specific class.
439 uint8_t bInterfaceNumber
; /**< Index of the interface in the current configuration. */
440 uint8_t bAlternateSetting
; /**< Alternate setting for the interface number. The same
441 * interface number can have multiple alternate settings
442 * with different endpoint configurations, which can be
443 * selected by the host.
445 uint8_t bNumEndpoints
; /**< Total number of endpoints in the interface. */
446 uint8_t bInterfaceClass
; /**< Interface class ID. */
447 uint8_t bInterfaceSubClass
; /**< Interface subclass ID. */
448 uint8_t bInterfaceProtocol
; /**< Interface protocol ID. */
449 uint8_t iInterface
; /**< Index of the string descriptor describing the
452 } USB_StdDescriptor_Interface_t
;
454 /** \brief Standard USB Interface Association Descriptor (LUFA naming conventions).
456 * Type define for a standard Interface Association Descriptor. This structure uses LUFA-specific element names
457 * to make each element's purpose clearer.
459 * This descriptor has been added as a supplement to the USB2.0 standard, in the ECN located at
460 * <a>http://www.usb.org/developers/docs/InterfaceAssociationDescriptor_ecn.pdf</a>. It allows compound
461 * devices with multiple interfaces related to the same function to have the multiple interfaces bound
462 * together at the point of enumeration, loading one generic driver for all the interfaces in the single
463 * function. Read the ECN for more information.
465 * \see \ref USB_StdDescriptor_Interface_Association_t for the version of this define with standard element names
469 USB_Descriptor_Header_t Header
; /**< Descriptor header, including type and size. */
471 uint8_t FirstInterfaceIndex
; /**< Index of the first associated interface. */
472 uint8_t TotalInterfaces
; /** Total number of associated interfaces. */
474 uint8_t Class
; /**< Interface class ID. */
475 uint8_t SubClass
; /**< Interface subclass ID. */
476 uint8_t Protocol
; /**< Interface protocol ID. */
478 uint8_t IADStrIndex
; /**< Index of the string descriptor describing the
479 * interface association.
481 } USB_Descriptor_Interface_Association_t
;
483 /** \brief Standard USB Interface Association Descriptor (USB-IF naming conventions).
485 * Type define for a standard Interface Association Descriptor. This structure uses the relevant standard's given
486 * element names to ensure compatibility with the standard.
488 * This descriptor has been added as a supplement to the USB2.0 standard, in the ECN located at
489 * <a>http://www.usb.org/developers/docs/InterfaceAssociationDescriptor_ecn.pdf</a>. It allows compound
490 * devices with multiple interfaces related to the same function to have the multiple interfaces bound
491 * together at the point of enumeration, loading one generic driver for all the interfaces in the single
492 * function. Read the ECN for more information.
494 * \see \ref USB_Descriptor_Interface_Association_t for the version of this define with non-standard LUFA specific
499 uint8_t bLength
; /**< Size of the descriptor, in bytes. */
500 uint8_t bDescriptorType
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
501 * given by the specific class.
503 uint8_t bFirstInterface
; /**< Index of the first associated interface. */
504 uint8_t bInterfaceCount
; /** Total number of associated interfaces. */
505 uint8_t bFunctionClass
; /**< Interface class ID. */
506 uint8_t bFunctionSubClass
; /**< Interface subclass ID. */
507 uint8_t bFunctionProtocol
; /**< Interface protocol ID. */
508 uint8_t iFunction
; /**< Index of the string descriptor describing the
509 * interface association.
511 } USB_StdDescriptor_Interface_Association_t
;
513 /** \brief Standard USB Endpoint Descriptor (LUFA naming conventions).
515 * Type define for a standard Endpoint Descriptor. This structure uses LUFA-specific element names
516 * to make each element's purpose clearer.
518 * \see \ref USB_StdDescriptor_Endpoint_t for the version of this define with standard element names
522 USB_Descriptor_Header_t Header
; /**< Descriptor header, including type and size. */
524 uint8_t EndpointAddress
; /**< Logical address of the endpoint within the device
525 * for the current configuration, including direction
528 uint8_t Attributes
; /**< Endpoint attributes, comprised of a mask of the
529 * endpoint type (EP_TYPE_*) and attributes (ENDPOINT_ATTR_*)
532 uint16_t EndpointSize
; /**< Size of the endpoint bank, in bytes. This indicates the
533 * maximum packet size that the endpoint can receive at a time.
536 uint8_t PollingIntervalMS
; /**< Polling interval in milliseconds for the endpoint
537 * if it is an INTERRUPT or ISOCHRONOUS type.
539 } USB_Descriptor_Endpoint_t
;
541 /** \brief Standard USB Endpoint Descriptor (USB-IF naming conventions).
543 * Type define for a standard Endpoint Descriptor. This structure uses the relevant standard's given
544 * element names to ensure compatibility with the standard.
546 * \see \ref USB_Descriptor_Endpoint_t for the version of this define with non-standard LUFA specific
551 uint8_t bLength
; /**< Size of the descriptor, in bytes. */
552 uint8_t bDescriptorType
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
553 * given by the specific class.
555 uint8_t bEndpointAddress
; /**< Logical address of the endpoint within the device
556 * for the current configuration, including direction
559 uint8_t bmAttributes
; /**< Endpoint attributes, comprised of a mask of the
560 * endpoint type (EP_TYPE_*) and attributes (ENDPOINT_ATTR_*)
563 uint16_t wMaxPacketSize
; /**< Size of the endpoint bank, in bytes. This indicates the
564 * maximum packet size that the endpoint can receive at a time.
566 uint8_t bInterval
; /**< Polling interval in milliseconds for the endpoint
567 * if it is an INTERRUPT or ISOCHRONOUS type.
569 } USB_StdDescriptor_Endpoint_t
;
571 /** \brief Standard USB String Descriptor (LUFA naming conventions).
573 * Type define for a standard string descriptor. Unlike other standard descriptors, the length
574 * of the descriptor for placement in the descriptor header must be determined by the \ref USB_STRING_LEN()
575 * macro rather than by the size of the descriptor structure, as the length is not fixed.
577 * This structure should also be used for string index 0, which contains the supported language IDs for
578 * the device as an array.
580 * This structure uses LUFA-specific element names to make each element's purpose clearer.
582 * \see \ref USB_StdDescriptor_String_t for the version of this define with standard element names
586 USB_Descriptor_Header_t Header
; /**< Descriptor header, including type and size. */
588 wchar_t UnicodeString
[]; /**< String data, as unicode characters (alternatively,
589 * string language IDs). If normal ASCII characters are
590 * to be used, they must be added as an array of characters
591 * rather than a normal C string so that they are widened to
594 * Under GCC, strings prefixed with the "L" character (before
595 * the opening string quotation mark) are considered to be
596 * Unicode strings, and may be used instead of an explicit
597 * array of ASCII characters.
599 } USB_Descriptor_String_t
;
601 /** \brief Standard USB String Descriptor (USB-IF 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 the relevant standard's given element names to ensure compatibility with the standard.
612 * \see \ref USB_Descriptor_String_t for the version of this define with with non-standard LUFA specific
617 uint8_t bLength
; /**< Size of the descriptor, in bytes. */
618 uint8_t bDescriptorType
; /**< Type of the descriptor, either a value in
619 * \ref USB_DescriptorTypes_t or a value
620 * given by the specific class.
622 int16_t bString
[]; /**< String data, as unicode characters (alternatively,
623 * string language IDs). If normal ASCII characters are
624 * to be used, they must be added as an array of characters
625 * rather than a normal C string so that they are widened to
628 * Under GCC, strings prefixed with the "L" character (before
629 * the opening string quotation mark) are considered to be
630 * Unicode strings, and may be used instead of an explicit
631 * array of ASCII characters.
633 } USB_StdDescriptor_String_t
;
635 /* Private Interface - For use in library only: */
636 #if !defined(__DOXYGEN__)
638 #define VERSION_TENS(x) (int)((x) / 10)
639 #define VERSION_ONES(x) (int)((x) - (10 * VERSION_TENS(x)))
640 #define VERSION_TENTHS(x) (int)(((x) - (int)(x)) * 10)
641 #define VERSION_HUNDREDTHS(x) (int)((((x) - (int)(x)) * 100) - (10 * VERSION_TENTHS(x)))
644 /* Disable C linkage for C++ Compilers: */
645 #if defined(__cplusplus)