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