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