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) && \
84 (defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1287__) || \
85 defined(__AVR_ATmega32U6__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) || \
86 defined(__AVR_ATmega32U2__) || defined(__AVR_ATmega16U2__) || defined(__AVR_ATmega8U2__)))
87 /** String descriptor index for the device's unique serial number string descriptor within the device.
88 * This unique serial number is used by the host to associate resources to the device (such as drivers or COM port
89 * number allocations) to a device regardless of the port it is plugged in to on the host. Some USB AVRs contain
90 * a unique serial number internally, and setting the device descriptors serial number string index to this value
91 * will cause it to use the internal serial number.
93 * On unsupported devices, this will evaluate to NO_DESCRIPTOR and so will force the host to create a pseudo-serial
94 * number for the device.
96 #define USE_INTERNAL_SERIAL 0xDC
98 #define USE_INTERNAL_SERIAL NO_DESCRIPTOR
101 /** Macro to calculate the power value for the configuration descriptor, from a given number of milliamps. */
102 #define USB_CONFIG_POWER_MA(mA) ((mA) >> 1)
104 /** Macro to calculate the Unicode length of a string with a given number of Unicode characters.
105 * Should be used in string descriptor's headers for giving the string descriptor's byte length.
107 #define USB_STRING_LEN(str) (sizeof(USB_Descriptor_Header_t) + ((str) << 1))
109 /** Macro to encode a given four digit floating point version number (e.g. 01.23) into Binary Coded
110 * Decimal format for descriptor fields requiring BCD encoding, such as the USB version number in the
111 * standard device descriptor.
113 #define VERSION_BCD(x) ((((VERSION_TENS(x) << 4) | VERSION_ONES(x)) << 8) | \
114 ((VERSION_TENTHS(x) << 4) | VERSION_HUNDREDTHS(x)))
116 /** String language ID for the English language. Should be used in \ref USB_Descriptor_String_t descriptors
117 * to indicate that the English language is supported by the device in its string descriptors.
119 #define LANGUAGE_ID_ENG 0x0409
121 /** Can be masked with an endpoint address for a \ref USB_Descriptor_Endpoint_t endpoint descriptor's
122 * EndpointAddress value to indicate to the host that the endpoint is of the IN direction (i.e, from
125 #define ENDPOINT_DESCRIPTOR_DIR_IN 0x80
127 /** Can be masked with an endpoint address for a \ref USB_Descriptor_Endpoint_t endpoint descriptor's
128 * EndpointAddress value to indicate to the host that the endpoint is of the OUT direction (i.e, from
131 #define ENDPOINT_DESCRIPTOR_DIR_OUT 0x00
133 /** Can be masked with other configuration descriptor attributes for a \ref USB_Descriptor_Configuration_Header_t
134 * descriptor's ConfigAttributes value to indicate that the specified configuration can draw its power
135 * from the host's VBUS line.
137 #define USB_CONFIG_ATTR_BUSPOWERED 0x80
139 /** Can be masked with other configuration descriptor attributes for a \ref USB_Descriptor_Configuration_Header_t
140 * descriptor's ConfigAttributes value to indicate that the specified configuration can draw its power
141 * from the device's own power source.
143 #define USB_CONFIG_ATTR_SELFPOWERED 0x40
145 /** Can be masked with other configuration descriptor attributes for a \ref USB_Descriptor_Configuration_Header_t
146 * descriptor's ConfigAttributes value to indicate that the specified configuration supports the
147 * remote wakeup feature of the USB standard, allowing a suspended USB device to wake up the host upon
150 #define USB_CONFIG_ATTR_REMOTEWAKEUP 0x20
152 /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
153 * Attributes value to indicate that the specified endpoint is not synchronized.
155 * \see The USB specification for more details on the possible Endpoint attributes.
157 #define ENDPOINT_ATTR_NO_SYNC (0 << 2)
159 /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
160 * Attributes value to indicate that the specified endpoint is asynchronous.
162 * \see The USB specification for more details on the possible Endpoint attributes.
164 #define ENDPOINT_ATTR_ASYNC (1 << 2)
166 /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
167 * Attributes value to indicate that the specified endpoint is adaptive.
169 * \see The USB specification for more details on the possible Endpoint attributes.
171 #define ENDPOINT_ATTR_ADAPTIVE (2 << 2)
173 /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
174 * Attributes value to indicate that the specified endpoint is synchronized.
176 * \see The USB specification for more details on the possible Endpoint attributes.
178 #define ENDPOINT_ATTR_SYNC (3 << 2)
180 /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
181 * Attributes value to indicate that the specified endpoint is used for data transfers.
183 * \see The USB specification for more details on the possible Endpoint usage attributes.
185 #define ENDPOINT_USAGE_DATA (0 << 4)
187 /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
188 * Attributes value to indicate that the specified endpoint is used for feedback.
190 * \see The USB specification for more details on the possible Endpoint usage attributes.
192 #define ENDPOINT_USAGE_FEEDBACK (1 << 4)
194 /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
195 * Attributes value to indicate that the specified endpoint is used for implicit feedback.
197 * \see The USB specification for more details on the possible Endpoint usage attributes.
199 #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. */
217 /** \brief Standard USB Descriptor Header (LUFA naming conventions).
219 * Type define for all descriptors' standard header, indicating the descriptor's length and type. This structure
220 * uses LUFA-specific element names to make each element's purpose clearer.
222 * \see \ref USB_StdDescriptor_Header_t for the version of this define with standard element names.
226 uint8_t Size
; /**< Size of the descriptor, in bytes. */
227 uint8_t Type
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
228 * given by the specific class.
230 } USB_Descriptor_Header_t
;
232 /** \brief Standard USB Descriptor Header (USB-IF naming conventions).
234 * Type define for all descriptors' standard header, indicating the descriptor's length and type. This structure
235 * uses the relevant standard's given element names to ensure compatibility with the standard.
237 * \see \ref USB_Descriptor_Header_t for the version of this define with non-standard LUFA specific element names.
241 uint8_t bLength
; /**< Size of the descriptor, in bytes. */
242 uint8_t bDescriptorType
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
243 * given by the specific class.
245 } USB_StdDescriptor_Header_t
;
247 /** \brief Standard USB Device Descriptor (LUFA naming conventions).
249 * Type define for a standard Device Descriptor. This structure uses LUFA-specific element names to make each
250 * element's purpose clearer.
252 * \see \ref USB_StdDescriptor_Device_t for the version of this define with standard element names.
256 USB_Descriptor_Header_t Header
; /**< Descriptor header, including type and size. */
258 uint16_t USBSpecification
; /**< BCD of the supported USB specification. */
259 uint8_t Class
; /**< USB device class. */
260 uint8_t SubClass
; /**< USB device subclass. */
261 uint8_t Protocol
; /**< USB device protocol. */
263 uint8_t Endpoint0Size
; /**< Size of the control (address 0) endpoint's bank in bytes. */
265 uint16_t VendorID
; /**< Vendor ID for the USB product. */
266 uint16_t ProductID
; /**< Unique product ID for the USB product. */
267 uint16_t ReleaseNumber
; /**< Product release (version) number. */
269 uint8_t ManufacturerStrIndex
; /**< String index for the manufacturer's name. The
270 * host will request this string via a separate
271 * control request for the string descriptor.
273 * \note If no string supplied, use \ref NO_DESCRIPTOR.
275 uint8_t ProductStrIndex
; /**< String index for the product name/details.
277 * \see ManufacturerStrIndex structure entry.
279 uint8_t SerialNumStrIndex
; /**< String index for the product's globally unique hexadecimal
280 * serial number, in uppercase Unicode ASCII.
282 * \note On some AVR models, there is an embedded serial number
283 * in the chip which can be used for the device serial number.
284 * To use this serial number, set this to USE_INTERNAL_SERIAL.
285 * On unsupported devices, this will evaluate to 0 and will cause
286 * the host to generate a pseudo-unique value for the device upon
289 * \see ManufacturerStrIndex structure entry.
291 uint8_t NumberOfConfigurations
; /**< Total number of configurations supported by
294 } USB_Descriptor_Device_t
;
296 /** \brief Standard USB Device Descriptor (USB-IF naming conventions).
298 * Type define for a standard Device Descriptor. This structure uses the relevant standard's given element names
299 * to ensure compatibility with the standard.
301 * \see \ref USB_Descriptor_Device_t for the version of this define with non-standard LUFA specific element names.
305 uint8_t bLength
; /**< Size of the descriptor, in bytes. */
306 uint8_t bDescriptorType
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
307 * given by the specific class.
309 uint16_t bcdUSB
; /**< BCD of the supported USB specification. */
310 uint8_t bDeviceClass
; /**< USB device class. */
311 uint8_t bDeviceSubClass
; /**< USB device subclass. */
312 uint8_t bDeviceProtocol
; /**< USB device protocol. */
313 uint8_t bMaxPacketSize0
; /**< Size of the control (address 0) endpoint's bank in bytes. */
314 uint16_t idVendor
; /**< Vendor ID for the USB product. */
315 uint16_t idProduct
; /**< Unique product ID for the USB product. */
316 uint16_t bcdDevice
; /**< Product release (version) number. */
317 uint8_t iManufacturer
; /**< String index for the manufacturer's name. The
318 * host will request this string via a separate
319 * control request for the string descriptor.
321 * \note If no string supplied, use \ref NO_DESCRIPTOR.
323 uint8_t iProduct
; /**< String index for the product name/details.
325 * \see ManufacturerStrIndex structure entry.
327 uint8_t iSerialNumber
; /**< String index for the product's globally unique hexadecimal
328 * serial number, in uppercase Unicode ASCII.
330 * \note On some AVR models, there is an embedded serial number
331 * in the chip which can be used for the device serial number.
332 * To use this serial number, set this to USE_INTERNAL_SERIAL.
333 * On unsupported devices, this will evaluate to 0 and will cause
334 * the host to generate a pseudo-unique value for the device upon
337 * \see ManufacturerStrIndex structure entry.
339 uint8_t bNumConfigurations
; /**< Total number of configurations supported by
342 } USB_StdDescriptor_Device_t
;
344 /** \brief Standard USB Configuration Descriptor (LUFA naming conventions).
346 * Type define for a standard Configuration Descriptor header. This structure uses LUFA-specific element names
347 * to make each element's purpose clearer.
349 * \see \ref USB_StdDescriptor_Configuration_Header_t for the version of this define with standard element names.
353 USB_Descriptor_Header_t Header
; /**< Descriptor header, including type and size. */
355 uint16_t TotalConfigurationSize
; /**< Size of the configuration descriptor header,
356 * and all sub descriptors inside the configuration.
358 uint8_t TotalInterfaces
; /**< Total number of interfaces in the configuration. */
360 uint8_t ConfigurationNumber
; /**< Configuration index of the current configuration. */
361 uint8_t ConfigurationStrIndex
; /**< Index of a string descriptor describing the configuration. */
363 uint8_t ConfigAttributes
; /**< Configuration attributes, comprised of a mask of zero or
364 * more USB_CONFIG_ATTR_* masks.
367 uint8_t MaxPowerConsumption
; /**< Maximum power consumption of the device while in the
368 * current configuration, calculated by the \ref USB_CONFIG_POWER_MA()
371 } USB_Descriptor_Configuration_Header_t
;
373 /** \brief Standard USB Configuration Descriptor (USB-IF naming conventions).
375 * Type define for a standard Configuration Descriptor header. This structure uses the relevant standard's given element names
376 * to ensure compatibility with the standard.
378 * \see \ref USB_Descriptor_Device_t for the version of this define with non-standard LUFA specific element names.
382 uint8_t bLength
; /**< Size of the descriptor, in bytes. */
383 uint8_t bDescriptorType
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
384 * given by the specific class.
386 uint16_t wTotalLength
; /**< Size of the configuration descriptor header,
387 * and all sub descriptors inside the configuration.
389 uint8_t bNumInterfaces
; /**< Total number of interfaces in the configuration. */
390 uint8_t bConfigurationValue
; /**< Configuration index of the current configuration. */
391 uint8_t iConfiguration
; /**< Index of a string descriptor describing the configuration. */
392 uint8_t bmAttributes
; /**< Configuration attributes, comprised of a mask of zero or
393 * more USB_CONFIG_ATTR_* masks.
395 uint8_t bMaxPower
; /**< Maximum power consumption of the device while in the
396 * current configuration, calculated by the \ref USB_CONFIG_POWER_MA()
399 } USB_StdDescriptor_Configuration_Header_t
;
401 /** \brief Standard USB Interface Descriptor (LUFA naming conventions).
403 * Type define for a standard Interface Descriptor. This structure uses LUFA-specific element names
404 * to make each element's purpose clearer.
406 * \see \ref USB_StdDescriptor_Interface_t for the version of this define with standard element names.
410 USB_Descriptor_Header_t Header
; /**< Descriptor header, including type and size. */
412 uint8_t InterfaceNumber
; /**< Index of the interface in the current configuration. */
413 uint8_t AlternateSetting
; /**< Alternate setting for the interface number. The same
414 * interface number can have multiple alternate settings
415 * with different endpoint configurations, which can be
416 * selected by the host.
418 uint8_t TotalEndpoints
; /**< Total number of endpoints in the interface. */
420 uint8_t Class
; /**< Interface class ID. */
421 uint8_t SubClass
; /**< Interface subclass ID. */
422 uint8_t Protocol
; /**< Interface protocol ID. */
424 uint8_t InterfaceStrIndex
; /**< Index of the string descriptor describing the interface. */
425 } USB_Descriptor_Interface_t
;
427 /** \brief Standard USB Interface Descriptor (USB-IF naming conventions).
429 * Type define for a standard Interface Descriptor. This structure uses the relevant standard's given element names
430 * to ensure compatibility with the standard.
432 * \see \ref USB_Descriptor_Interface_t for the version of this define with non-standard LUFA specific element names.
436 uint8_t bLength
; /**< Size of the descriptor, in bytes. */
437 uint8_t bDescriptorType
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
438 * given by the specific class.
440 uint8_t bInterfaceNumber
; /**< Index of the interface in the current configuration. */
441 uint8_t bAlternateSetting
; /**< Alternate setting for the interface number. The same
442 * interface number can have multiple alternate settings
443 * with different endpoint configurations, which can be
444 * selected by the host.
446 uint8_t bNumEndpoints
; /**< Total number of endpoints in the interface. */
447 uint8_t bInterfaceClass
; /**< Interface class ID. */
448 uint8_t bInterfaceSubClass
; /**< Interface subclass ID. */
449 uint8_t bInterfaceProtocol
; /**< Interface protocol ID. */
450 uint8_t iInterface
; /**< Index of the string descriptor describing the
453 } USB_StdDescriptor_Interface_t
;
455 /** \brief Standard USB Interface Association Descriptor (LUFA naming conventions).
457 * Type define for a standard Interface Association Descriptor. This structure uses LUFA-specific element names
458 * to make each element's purpose clearer.
460 * This descriptor has been added as a supplement to the USB2.0 standard, in the ECN located at
461 * <a>http://www.usb.org/developers/docs/InterfaceAssociationDescriptor_ecn.pdf</a>. It allows compound
462 * devices with multiple interfaces related to the same function to have the multiple interfaces bound
463 * together at the point of enumeration, loading one generic driver for all the interfaces in the single
464 * function. Read the ECN for more information.
466 * \see \ref USB_StdDescriptor_Interface_Association_t for the version of this define with standard element names.
470 USB_Descriptor_Header_t Header
; /**< Descriptor header, including type and size. */
472 uint8_t FirstInterfaceIndex
; /**< Index of the first associated interface. */
473 uint8_t TotalInterfaces
; /**< Total number of associated interfaces. */
475 uint8_t Class
; /**< Interface class ID. */
476 uint8_t SubClass
; /**< Interface subclass ID. */
477 uint8_t Protocol
; /**< Interface protocol ID. */
479 uint8_t IADStrIndex
; /**< Index of the string descriptor describing the
480 * interface association.
482 } USB_Descriptor_Interface_Association_t
;
484 /** \brief Standard USB Interface Association Descriptor (USB-IF naming conventions).
486 * Type define for a standard Interface Association Descriptor. This structure uses the relevant standard's given
487 * element names to ensure compatibility with the standard.
489 * This descriptor has been added as a supplement to the USB2.0 standard, in the ECN located at
490 * <a>http://www.usb.org/developers/docs/InterfaceAssociationDescriptor_ecn.pdf</a>. It allows compound
491 * devices with multiple interfaces related to the same function to have the multiple interfaces bound
492 * together at the point of enumeration, loading one generic driver for all the interfaces in the single
493 * function. Read the ECN for more information.
495 * \see \ref USB_Descriptor_Interface_Association_t for the version of this define with non-standard LUFA specific
500 uint8_t bLength
; /**< Size of the descriptor, in bytes. */
501 uint8_t bDescriptorType
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
502 * given by the specific class.
504 uint8_t bFirstInterface
; /**< Index of the first associated interface. */
505 uint8_t bInterfaceCount
; /**< Total number of associated interfaces. */
506 uint8_t bFunctionClass
; /**< Interface class ID. */
507 uint8_t bFunctionSubClass
; /**< Interface subclass ID. */
508 uint8_t bFunctionProtocol
; /**< Interface protocol ID. */
509 uint8_t iFunction
; /**< Index of the string descriptor describing the
510 * interface association.
512 } USB_StdDescriptor_Interface_Association_t
;
514 /** \brief Standard USB Endpoint Descriptor (LUFA naming conventions).
516 * Type define for a standard Endpoint Descriptor. This structure uses LUFA-specific element names
517 * to make each element's purpose clearer.
519 * \see \ref USB_StdDescriptor_Endpoint_t for the version of this define with standard element names.
523 USB_Descriptor_Header_t Header
; /**< Descriptor header, including type and size. */
525 uint8_t EndpointAddress
; /**< Logical address of the endpoint within the device for the current
526 * configuration, including direction mask.
528 uint8_t Attributes
; /**< Endpoint attributes, comprised of a mask of the endpoint type (EP_TYPE_*)
529 * and attributes (ENDPOINT_ATTR_*) masks.
531 uint16_t EndpointSize
; /**< Size of the endpoint bank, in bytes. This indicates the maximum packet
532 * size that the endpoint can receive at a time.
534 uint8_t PollingIntervalMS
; /**< Polling interval in milliseconds for the endpoint if it is an INTERRUPT
535 * or ISOCHRONOUS type.
537 } USB_Descriptor_Endpoint_t
;
539 /** \brief Standard USB Endpoint Descriptor (USB-IF naming conventions).
541 * Type define for a standard Endpoint Descriptor. This structure uses the relevant standard's given
542 * element names to ensure compatibility with the standard.
544 * \see \ref USB_Descriptor_Endpoint_t for the version of this define with non-standard LUFA specific
549 uint8_t bLength
; /**< Size of the descriptor, in bytes. */
550 uint8_t bDescriptorType
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a
551 * value given by the specific class.
553 uint8_t bEndpointAddress
; /**< Logical address of the endpoint within the device for the current
554 * configuration, including direction mask.
556 uint8_t bmAttributes
; /**< Endpoint attributes, comprised of a mask of the endpoint type (EP_TYPE_*)
557 * and attributes (ENDPOINT_ATTR_*) masks.
559 uint16_t wMaxPacketSize
; /**< Size of the endpoint bank, in bytes. This indicates the maximum packet size
560 * that the endpoint can receive at a time.
562 uint8_t bInterval
; /**< Polling interval in milliseconds for the endpoint if it is an INTERRUPT or
565 } USB_StdDescriptor_Endpoint_t
;
567 /** \brief Standard USB String Descriptor (LUFA naming conventions).
569 * Type define for a standard string descriptor. Unlike other standard descriptors, the length
570 * of the descriptor for placement in the descriptor header must be determined by the \ref USB_STRING_LEN()
571 * macro rather than by the size of the descriptor structure, as the length is not fixed.
573 * This structure should also be used for string index 0, which contains the supported language IDs for
574 * the device as an array.
576 * This structure uses LUFA-specific element names to make each element's purpose clearer.
578 * \see \ref USB_StdDescriptor_String_t for the version of this define with standard element names.
582 USB_Descriptor_Header_t Header
; /**< Descriptor header, including type and size. */
584 wchar_t UnicodeString
[]; /**< String data, as unicode characters (alternatively,
585 * string language IDs). If normal ASCII characters are
586 * to be used, they must be added as an array of characters
587 * rather than a normal C string so that they are widened to
590 * Under GCC, strings prefixed with the "L" character (before
591 * the opening string quotation mark) are considered to be
592 * Unicode strings, and may be used instead of an explicit
593 * array of ASCII characters.
595 } USB_Descriptor_String_t
;
597 /** \brief Standard USB String Descriptor (USB-IF naming conventions).
599 * Type define for a standard string descriptor. Unlike other standard descriptors, the length
600 * of the descriptor for placement in the descriptor header must be determined by the \ref USB_STRING_LEN()
601 * macro rather than by the size of the descriptor structure, as the length is not fixed.
603 * This structure should also be used for string index 0, which contains the supported language IDs for
604 * the device as an array.
606 * This structure uses the relevant standard's given element names to ensure compatibility with the standard.
608 * \see \ref USB_Descriptor_String_t for the version of this define with with non-standard LUFA specific
613 uint8_t bLength
; /**< Size of the descriptor, in bytes. */
614 uint8_t bDescriptorType
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t
615 * or a value given by the specific class.
617 int16_t bString
[]; /**< String data, as unicode characters (alternatively, string language IDs).
618 * If normal ASCII characters are to be used, they must be added as an array
619 * of characters rather than a normal C string so that they are widened to
622 * Under GCC, strings prefixed with the "L" character (before the opening string
623 * quotation mark) are considered to be Unicode strings, and may be used instead
624 * of an explicit array of ASCII characters.
626 } USB_StdDescriptor_String_t
;
628 /* Private Interface - For use in library only: */
629 #if !defined(__DOXYGEN__)
631 #define VERSION_TENS(x) (int)((x) / 10)
632 #define VERSION_ONES(x) (int)((x) - (10 * VERSION_TENS(x)))
633 #define VERSION_TENTHS(x) (int)(((x) - (int)(x)) * 10)
634 #define VERSION_HUNDREDTHS(x) (int)((((x) - (int)(x)) * 100) - (10 * VERSION_TENTHS(x)))
637 /* Disable C linkage for C++ Compilers: */
638 #if defined(__cplusplus)