Fix XPLAIN Dataflash and LED drivers.
[pub/USBasp.git] / LUFA / Drivers / USB / HighLevel / StdDescriptors.h
1 /*
2 LUFA Library
3 Copyright (C) Dean Camera, 2010.
4
5 dean [at] fourwalledcubicle [dot] com
6 www.fourwalledcubicle.com
7 */
8
9 /*
10 Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
11
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.
20
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
28 this software.
29 */
30
31 /** \ingroup Group_USB
32 * @defgroup Group_Descriptors USB Descriptors
33 *
34 * Standard USB device descriptor defines and retrieval routines, for USB devices. This module contains
35 * structures and macros for the easy creation of standard USB descriptors in USB device projects.
36 *
37 * @{
38 */
39
40 #ifndef __USBDESCRIPTORS_H__
41 #define __USBDESCRIPTORS_H__
42
43 /* Includes: */
44 #include <avr/pgmspace.h>
45 #include <stdbool.h>
46 #include <stddef.h>
47
48 #include "../../../Common/Common.h"
49 #include "USBMode.h"
50 #include "Events.h"
51
52 #if defined(USB_CAN_BE_DEVICE)
53 #include "../LowLevel/Device.h"
54 #endif
55
56 /* Enable C linkage for C++ Compilers: */
57 #if defined(__cplusplus)
58 extern "C" {
59 #endif
60
61 /* Public Interface - May be used in end-application: */
62 /* Macros: */
63 /** Indicates that a given descriptor does not exist in the device. This can be used inside descriptors
64 * for string descriptor indexes, or may be use as a return value for GetDescriptor when the specified
65 * descriptor does not exist.
66 */
67 #define NO_DESCRIPTOR 0
68
69 #if (!defined(NO_INTERNAL_SERIAL) && (defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR))) || defined(__DOXYGEN__)
70 /** String descriptor index for the device's unique serial number string descriptor within the device.
71 * This unique serial number is used by the host to associate resources to the device (such as drivers or COM port
72 * number allocations) to a device regardless of the port it is plugged in to on the host. Some USB AVRs contain
73 * a unique serial number internally, and setting the device descriptors serial number string index to this value
74 * will cause it to use the internal serial number.
75 *
76 * On unsupported devices, this will evaluate to NO_DESCRIPTOR and so will force the host to create a pseudo-serial
77 * number for the device.
78 */
79 #define USE_INTERNAL_SERIAL 0xDC
80 #else
81 #define USE_INTERNAL_SERIAL NO_DESCRIPTOR
82 #endif
83
84 /** Macro to calculate the power value for the device descriptor, from a given number of milliamps. */
85 #define USB_CONFIG_POWER_MA(mA) ((mA) >> 1)
86
87 /** Macro to calculate the Unicode length of a string with a given number of Unicode characters.
88 * Should be used in string descriptor's headers for giving the string descriptor's byte length.
89 */
90 #define USB_STRING_LEN(str) (sizeof(USB_Descriptor_Header_t) + ((str) << 1))
91
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.
95 */
96 #define VERSION_BCD(x) ((((VERSION_TENS(x) << 4) | VERSION_ONES(x)) << 8) | \
97 ((VERSION_TENTHS(x) << 4) | VERSION_HUNDREDTHS(x)))
98
99 /** String language ID for the English language. Should be used in \ref USB_Descriptor_String_t descriptors
100 * to indicate that the English language is supported by the device in its string descriptors.
101 */
102 #define LANGUAGE_ID_ENG 0x0409
103
104 /** Can be masked with an endpoint address for a \ref USB_Descriptor_Endpoint_t endpoint descriptor's
105 * EndpointAddress value to indicate to the host that the endpoint is of the IN direction (i.e, from
106 * device to host).
107 */
108 #define ENDPOINT_DESCRIPTOR_DIR_IN 0x80
109
110 /** Can be masked with an endpoint address for a \ref USB_Descriptor_Endpoint_t endpoint descriptor's
111 * EndpointAddress value to indicate to the host that the endpoint is of the OUT direction (i.e, from
112 * host to device).
113 */
114 #define ENDPOINT_DESCRIPTOR_DIR_OUT 0x00
115
116 /** Can be masked with other configuration descriptor attributes for a \ref USB_Descriptor_Configuration_Header_t
117 * descriptor's ConfigAttributes value to indicate that the specified configuration can draw its power
118 * from the host's VBUS line.
119 */
120 #define USB_CONFIG_ATTR_BUSPOWERED 0x80
121
122
123 /** Can be masked with other configuration descriptor attributes for a \ref USB_Descriptor_Configuration_Header_t
124 * descriptor's ConfigAttributes value to indicate that the specified configuration can draw its power
125 * from the device's own power source.
126 */
127 #define USB_CONFIG_ATTR_SELFPOWERED 0xC0
128
129 /** Can be masked with other configuration descriptor attributes for a \ref USB_Descriptor_Configuration_Header_t
130 * descriptor's ConfigAttributes value to indicate that the specified configuration supports the
131 * remote wakeup feature of the USB standard, allowing a suspended USB device to wake up the host upon
132 * request.
133 */
134 #define USB_CONFIG_ATTR_REMOTEWAKEUP 0xA0
135
136 /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
137 * Attributes value to indicate that the specified endpoint is not synchronized.
138 *
139 * \see The USB specification for more details on the possible Endpoint attributes.
140 */
141 #define ENDPOINT_ATTR_NO_SYNC (0 << 2)
142
143 /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
144 * Attributes value to indicate that the specified endpoint is asynchronous.
145 *
146 * \see The USB specification for more details on the possible Endpoint attributes.
147 */
148 #define ENDPOINT_ATTR_ASYNC (1 << 2)
149
150 /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
151 * Attributes value to indicate that the specified endpoint is adaptive.
152 *
153 * \see The USB specification for more details on the possible Endpoint attributes.
154 */
155 #define ENDPOINT_ATTR_ADAPTIVE (2 << 2)
156
157 /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
158 * Attributes value to indicate that the specified endpoint is synchronized.
159 *
160 * \see The USB specification for more details on the possible Endpoint attributes.
161 */
162 #define ENDPOINT_ATTR_SYNC (3 << 2)
163
164 /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
165 * Attributes value to indicate that the specified endpoint is used for data transfers.
166 *
167 * \see The USB specification for more details on the possible Endpoint usage attributes.
168 */
169 #define ENDPOINT_USAGE_DATA (0 << 4)
170
171 /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
172 * Attributes value to indicate that the specified endpoint is used for feedback.
173 *
174 * \see The USB specification for more details on the possible Endpoint usage attributes.
175 */
176 #define ENDPOINT_USAGE_FEEDBACK (1 << 4)
177
178 /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
179 * Attributes value to indicate that the specified endpoint is used for implicit feedback.
180 *
181 * \see The USB specification for more details on the possible Endpoint usage attributes.
182 */
183 #define ENDPOINT_USAGE_IMPLICIT_FEEDBACK (2 << 4)
184
185 /* Enums: */
186 /** Enum for the possible standard descriptor types, as given in each descriptor's header. */
187 enum USB_DescriptorTypes_t
188 {
189 DTYPE_Device = 0x01, /**< Indicates that the descriptor is a device descriptor. */
190 DTYPE_Configuration = 0x02, /**< Indicates that the descriptor is a configuration descriptor. */
191 DTYPE_String = 0x03, /**< Indicates that the descriptor is a string descriptor. */
192 DTYPE_Interface = 0x04, /**< Indicates that the descriptor is an interface descriptor. */
193 DTYPE_Endpoint = 0x05, /**< Indicates that the descriptor is an endpoint descriptor. */
194 DTYPE_DeviceQualifier = 0x06, /**< Indicates that the descriptor is a device qualifier descriptor. */
195 DTYPE_Other = 0x07, /**< Indicates that the descriptor is of other type. */
196 DTYPE_InterfacePower = 0x08, /**< Indicates that the descriptor is an interface power descriptor. */
197 DTYPE_InterfaceAssociation = 0x0B, /**< Indicates that the descriptor is an interface association descriptor. */
198 };
199
200 /* Type Defines: */
201 /** Type define for all descriptors standard header, indicating the descriptor's length and type. This structure
202 * uses LUFA-specific element names to make each element's purpose clearer.
203 *
204 * \see \ref USB_StdDescriptor_Header_t for the version of this define with standard element names
205 */
206 typedef struct
207 {
208 uint8_t Size; /**< Size of the descriptor, in bytes. */
209 uint8_t Type; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
210 * given by the specific class.
211 */
212 } USB_Descriptor_Header_t;
213
214 /** Type define for all descriptors standard header, indicating the descriptor's length and type. This structure
215 * uses the relevant standard's given element names to ensure compatibility with the standard.
216 *
217 * \see \ref USB_Descriptor_Header_t for the version of this define with non-standard LUFA specific element names
218 */
219 typedef struct
220 {
221 uint8_t bLength; /**< Size of the descriptor, in bytes. */
222 uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
223 * given by the specific class.
224 */
225 } USB_StdDescriptor_Header_t;
226
227 /** Type define for a standard Device Descriptor. This structure uses LUFA-specific element names to make each
228 * element's purpose clearer.
229 *
230 * \see \ref USB_StdDescriptor_Device_t for the version of this define with standard element names
231 */
232 typedef struct
233 {
234 USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */
235
236 uint16_t USBSpecification; /**< BCD of the supported USB specification. */
237 uint8_t Class; /**< USB device class. */
238 uint8_t SubClass; /**< USB device subclass. */
239 uint8_t Protocol; /**< USB device protocol. */
240
241 uint8_t Endpoint0Size; /**< Size of the control (address 0) endpoint's bank in bytes. */
242
243 uint16_t VendorID; /**< Vendor ID for the USB product. */
244 uint16_t ProductID; /**< Unique product ID for the USB product. */
245 uint16_t ReleaseNumber; /**< Product release (version) number. */
246
247 uint8_t ManufacturerStrIndex; /**< String index for the manufacturer's name. The
248 * host will request this string via a separate
249 * control request for the string descriptor.
250 *
251 * \note If no string supplied, use \ref NO_DESCRIPTOR.
252 */
253 uint8_t ProductStrIndex; /**< String index for the product name/details.
254 *
255 * \see ManufacturerStrIndex structure entry.
256 */
257 uint8_t SerialNumStrIndex; /**< String index for the product's globally unique hexadecimal
258 * serial number, in uppercase Unicode ASCII.
259 *
260 * \note On some AVR models, there is an embedded serial number
261 * in the chip which can be used for the device serial number.
262 * To use this serial number, set this to USE_INTERNAL_SERIAL.
263 * On unsupported devices, this will evaluate to 0 and will cause
264 * the host to generate a pseudo-unique value for the device upon
265 * insertion.
266 *
267 * \see ManufacturerStrIndex structure entry.
268 */
269 uint8_t NumberOfConfigurations; /**< Total number of configurations supported by
270 * the device.
271 */
272 } USB_Descriptor_Device_t;
273
274 /** Type define for a standard Device Descriptor. This structure uses the relevant standard's given element names
275 * to ensure compatibility with the standard.
276 *
277 * \see \ref USB_Descriptor_Device_t for the version of this define with non-standard LUFA specific element names
278 */
279 typedef struct
280 {
281 uint8_t bLength; /**< Size of the descriptor, in bytes. */
282 uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
283 * given by the specific class.
284 */
285 uint16_t bcdUSB; /**< BCD of the supported USB specification. */
286 uint8_t bDeviceClass; /**< USB device class. */
287 uint8_t bDeviceSubClass; /**< USB device subclass. */
288 uint8_t bDeviceProtocol; /**< USB device protocol. */
289 uint8_t bMaxPacketSize0; /**< Size of the control (address 0) endpoint's bank in bytes. */
290 uint16_t idVendor; /**< Vendor ID for the USB product. */
291 uint16_t idProduct; /**< Unique product ID for the USB product. */
292 uint16_t bcdDevice; /**< Product release (version) number. */
293 uint8_t iManufacturer; /**< String index for the manufacturer's name. The
294 * host will request this string via a separate
295 * control request for the string descriptor.
296 *
297 * \note If no string supplied, use \ref NO_DESCRIPTOR.
298 */
299 uint8_t iProduct; /**< String index for the product name/details.
300 *
301 * \see ManufacturerStrIndex structure entry.
302 */
303 uint8_t iSerialNumber; /**< String index for the product's globally unique hexadecimal
304 * serial number, in uppercase Unicode ASCII.
305 *
306 * \note On some AVR models, there is an embedded serial number
307 * in the chip which can be used for the device serial number.
308 * To use this serial number, set this to USE_INTERNAL_SERIAL.
309 * On unsupported devices, this will evaluate to 0 and will cause
310 * the host to generate a pseudo-unique value for the device upon
311 * insertion.
312 *
313 * \see ManufacturerStrIndex structure entry.
314 */
315 uint8_t bNumConfigurations; /**< Total number of configurations supported by
316 * the device.
317 */
318 } USB_StdDescriptor_Device_t;
319
320 /** Type define for a standard Configuration Descriptor header. This structure uses LUFA-specific element names
321 * to make each element's purpose clearer.
322 *
323 * \see \ref USB_StdDescriptor_Configuration_Header_t for the version of this define with standard element names
324 */
325 typedef struct
326 {
327 USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */
328
329 uint16_t TotalConfigurationSize; /**< Size of the configuration descriptor header,
330 * and all sub descriptors inside the configuration.
331 */
332 uint8_t TotalInterfaces; /**< Total number of interfaces in the configuration. */
333
334 uint8_t ConfigurationNumber; /**< Configuration index of the current configuration. */
335 uint8_t ConfigurationStrIndex; /**< Index of a string descriptor describing the configuration. */
336
337 uint8_t ConfigAttributes; /**< Configuration attributes, comprised of a mask of zero or
338 * more USB_CONFIG_ATTR_* masks.
339 */
340
341 uint8_t MaxPowerConsumption; /**< Maximum power consumption of the device while in the
342 * current configuration, calculated by the \ref USB_CONFIG_POWER_MA()
343 * macro.
344 */
345 } USB_Descriptor_Configuration_Header_t;
346
347 /** Type define for a standard Configuration Descriptor header. This structure uses the relevant standard's given element names
348 * to ensure compatibility with the standard.
349 *
350 * \see \ref USB_Descriptor_Device_t for the version of this define with non-standard LUFA specific element names
351 */
352 typedef struct
353 {
354 uint8_t bLength; /**< Size of the descriptor, in bytes. */
355 uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
356 * given by the specific class.
357 */
358 uint16_t wTotalLength; /**< Size of the configuration descriptor header,
359 * and all sub descriptors inside the configuration.
360 */
361 uint8_t bNumInterfaces; /**< Total number of interfaces in the configuration. */
362 uint8_t bConfigurationValue; /**< Configuration index of the current configuration. */
363 uint8_t iConfiguration; /**< Index of a string descriptor describing the configuration. */
364 uint8_t bmAttributes; /**< Configuration attributes, comprised of a mask of zero or
365 * more USB_CONFIG_ATTR_* masks.
366 */
367 uint8_t bMaxPower; /**< Maximum power consumption of the device while in the
368 * current configuration, calculated by the \ref USB_CONFIG_POWER_MA()
369 * macro.
370 */
371 } USB_StdDescriptor_Configuration_Header_t;
372
373 /** Type define for a standard Interface Descriptor. This structure uses LUFA-specific element names
374 * to make each element's purpose clearer.
375 *
376 * \see \ref USB_StdDescriptor_Interface_t for the version of this define with standard element names
377 */
378 typedef struct
379 {
380 USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */
381
382 uint8_t InterfaceNumber; /**< Index of the interface in the current configuration. */
383 uint8_t AlternateSetting; /**< Alternate setting for the interface number. The same
384 * interface number can have multiple alternate settings
385 * with different endpoint configurations, which can be
386 * selected by the host.
387 */
388 uint8_t TotalEndpoints; /**< Total number of endpoints in the interface. */
389
390 uint8_t Class; /**< Interface class ID. */
391 uint8_t SubClass; /**< Interface subclass ID. */
392 uint8_t Protocol; /**< Interface protocol ID. */
393
394 uint8_t InterfaceStrIndex; /**< Index of the string descriptor describing the
395 * interface.
396 */
397 } USB_Descriptor_Interface_t;
398
399 /** Type define for a standard Interface Descriptor. This structure uses the relevant standard's given element names
400 * to ensure compatibility with the standard.
401 *
402 * \see \ref USB_Descriptor_Interface_t for the version of this define with non-standard LUFA specific element names
403 */
404 typedef struct
405 {
406 uint8_t bLength; /**< Size of the descriptor, in bytes. */
407 uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
408 * given by the specific class.
409 */
410 uint8_t bInterfaceNumber; /**< Index of the interface in the current configuration. */
411 uint8_t bAlternateSetting; /**< Alternate setting for the interface number. The same
412 * interface number can have multiple alternate settings
413 * with different endpoint configurations, which can be
414 * selected by the host.
415 */
416 uint8_t bNumEndpoints; /**< Total number of endpoints in the interface. */
417 uint8_t bInterfaceClass; /**< Interface class ID. */
418 uint8_t bInterfaceSubClass; /**< Interface subclass ID. */
419 uint8_t bInterfaceProtocol; /**< Interface protocol ID. */
420 uint8_t iInterface; /**< Index of the string descriptor describing the
421 * interface.
422 */
423 } USB_StdDescriptor_Interface_t;
424
425 /** Type define for a standard Interface Association Descriptor. This structure uses LUFA-specific element names
426 * to make each element's purpose clearer.
427 *
428 * This descriptor has been added as a supplement to the USB2.0 standard, in the ECN located at
429 * <a>http://www.usb.org/developers/docs/InterfaceAssociationDescriptor_ecn.pdf</a>. It allows compound
430 * devices with multiple interfaces related to the same function to have the multiple interfaces bound
431 * together at the point of enumeration, loading one generic driver for all the interfaces in the single
432 * function. Read the ECN for more information.
433 *
434 * \see \ref USB_StdDescriptor_Interface_Association_t for the version of this define with standard element names
435 */
436 typedef struct
437 {
438 USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */
439
440 uint8_t FirstInterfaceIndex; /**< Index of the first associated interface. */
441 uint8_t TotalInterfaces; /** Total number of associated interfaces. */
442
443 uint8_t Class; /**< Interface class ID. */
444 uint8_t SubClass; /**< Interface subclass ID. */
445 uint8_t Protocol; /**< Interface protocol ID. */
446
447 uint8_t IADStrIndex; /**< Index of the string descriptor describing the
448 * interface association.
449 */
450 } USB_Descriptor_Interface_Association_t;
451
452 /** Type define for a standard Interface Association Descriptor. This structure uses the relevant standard's given
453 * element names to ensure compatibility with the standard.
454 *
455 * This descriptor has been added as a supplement to the USB2.0 standard, in the ECN located at
456 * <a>http://www.usb.org/developers/docs/InterfaceAssociationDescriptor_ecn.pdf</a>. It allows compound
457 * devices with multiple interfaces related to the same function to have the multiple interfaces bound
458 * together at the point of enumeration, loading one generic driver for all the interfaces in the single
459 * function. Read the ECN for more information.
460 *
461 * \see \ref USB_Descriptor_Interface_Association_t for the version of this define with non-standard LUFA specific
462 * element names
463 */
464 typedef struct
465 {
466 uint8_t bLength; /**< Size of the descriptor, in bytes. */
467 uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
468 * given by the specific class.
469 */
470 uint8_t bFirstInterface; /**< Index of the first associated interface. */
471 uint8_t bInterfaceCount; /** Total number of associated interfaces. */
472 uint8_t bFunctionClass; /**< Interface class ID. */
473 uint8_t bFunctionSubClass; /**< Interface subclass ID. */
474 uint8_t bFunctionProtocol; /**< Interface protocol ID. */
475 uint8_t iFunction; /**< Index of the string descriptor describing the
476 * interface association.
477 */
478 } USB_StdDescriptor_Interface_Association_t;
479
480 /** Type define for a standard Endpoint Descriptor. This structure uses LUFA-specific element names
481 * to make each element's purpose clearer.
482 *
483 * \see \ref USB_StdDescriptor_Endpoint_t for the version of this define with standard element names
484 */
485 typedef struct
486 {
487 USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */
488
489 uint8_t EndpointAddress; /**< Logical address of the endpoint within the device
490 * for the current configuration, including direction
491 * mask.
492 */
493 uint8_t Attributes; /**< Endpoint attributes, comprised of a mask of the
494 * endpoint type (EP_TYPE_*) and attributes (ENDPOINT_ATTR_*)
495 * masks.
496 */
497 uint16_t EndpointSize; /**< Size of the endpoint bank, in bytes. This indicates the
498 * maximum packet size that the endpoint can receive at a time.
499 */
500
501 uint8_t PollingIntervalMS; /**< Polling interval in milliseconds for the endpoint
502 * if it is an INTERRUPT or ISOCHRONOUS type.
503 */
504 } USB_Descriptor_Endpoint_t;
505
506 /** Type define for a standard Endpoint Descriptor. This structure uses the relevant standard's given
507 * element names to ensure compatibility with the standard.
508 *
509 * \see \ref USB_Descriptor_Endpoint_t for the version of this define with non-standard LUFA specific
510 * element names
511 */
512 typedef struct
513 {
514 uint8_t bLength; /**< Size of the descriptor, in bytes. */
515 uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
516 * given by the specific class.
517 */
518 uint8_t bEndpointAddress; /**< Logical address of the endpoint within the device
519 * for the current configuration, including direction
520 * mask.
521 */
522 uint8_t bmAttributes; /**< Endpoint attributes, comprised of a mask of the
523 * endpoint type (EP_TYPE_*) and attributes (ENDPOINT_ATTR_*)
524 * masks.
525 */
526 uint16_t wMaxPacketSize; /**< Size of the endpoint bank, in bytes. This indicates the
527 * maximum packet size that the endpoint can receive at a time.
528 */
529 uint8_t bInterval; /**< Polling interval in milliseconds for the endpoint
530 * if it is an INTERRUPT or ISOCHRONOUS type.
531 */
532 } USB_StdDescriptor_Endpoint_t;
533
534 /** Type define for a standard string descriptor. Unlike other standard descriptors, the length
535 * of the descriptor for placement in the descriptor header must be determined by the \ref USB_STRING_LEN()
536 * macro rather than by the size of the descriptor structure, as the length is not fixed.
537 *
538 * This structure should also be used for string index 0, which contains the supported language IDs for
539 * the device as an array.
540 *
541 * This structure uses LUFA-specific element names to make each element's purpose clearer.
542 *
543 * \see \ref USB_StdDescriptor_String_t for the version of this define with standard element names
544 */
545 typedef struct
546 {
547 USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */
548
549 wchar_t UnicodeString[]; /**< String data, as unicode characters (alternatively,
550 * string language IDs). If normal ASCII characters are
551 * to be used, they must be added as an array of characters
552 * rather than a normal C string so that they are widened to
553 * Unicode size.
554 *
555 * Under GCC, strings prefixed with the "L" character (before
556 * the opening string quotation mark) are considered to be
557 * Unicode strings, and may be used instead of an explicit
558 * array of ASCII characters.
559 */
560 } USB_Descriptor_String_t;
561
562 /** Type define for a standard string descriptor. Unlike other standard descriptors, the length
563 * of the descriptor for placement in the descriptor header must be determined by the \ref USB_STRING_LEN()
564 * macro rather than by the size of the descriptor structure, as the length is not fixed.
565 *
566 * This structure should also be used for string index 0, which contains the supported language IDs for
567 * the device as an array.
568 *
569 * This structure uses the relevant standard's given element names to ensure compatibility with the standard.
570 *
571 * \see \ref USB_Descriptor_String_t for the version of this define with with non-standard LUFA specific
572 * element names
573 */
574 typedef struct
575 {
576 uint8_t bLength; /**< Size of the descriptor, in bytes. */
577 uint8_t bDescriptorType; /**< Type of the descriptor, either a value in
578 * \ref USB_DescriptorTypes_t or a value
579 * given by the specific class.
580 */
581 int16_t bString[]; /**< String data, as unicode characters (alternatively,
582 * string language IDs). If normal ASCII characters are
583 * to be used, they must be added as an array of characters
584 * rather than a normal C string so that they are widened to
585 * Unicode size.
586 *
587 * Under GCC, strings prefixed with the "L" character (before
588 * the opening string quotation mark) are considered to be
589 * Unicode strings, and may be used instead of an explicit
590 * array of ASCII characters.
591 */
592 } USB_StdDescriptor_String_t;
593
594 /* Private Interface - For use in library only: */
595 #if !defined(__DOXYGEN__)
596 /* Macros: */
597 #define VERSION_TENS(x) (int)((x) / 10)
598 #define VERSION_ONES(x) (int)((x) - (10 * VERSION_TENS(x)))
599 #define VERSION_TENTHS(x) (int)(((x) - (int)(x)) * 10)
600 #define VERSION_HUNDREDTHS(x) (int)((((x) - (int)(x)) * 100) - (10 * VERSION_TENTHS(x)))
601 #endif
602
603 /* Disable C linkage for C++ Compilers: */
604 #if defined(__cplusplus)
605 }
606 #endif
607
608 #endif
609
610 /** @} */