Fixed internal device serial not being accessible on the ATMEGAXXU2 AVRs (thanks...
[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) && \
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.
92 *
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.
95 */
96 #define USE_INTERNAL_SERIAL 0xDC
97 #else
98 #define USE_INTERNAL_SERIAL NO_DESCRIPTOR
99 #endif
100
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)
103
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.
106 */
107 #define USB_STRING_LEN(str) (sizeof(USB_Descriptor_Header_t) + ((str) << 1))
108
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.
112 */
113 #define VERSION_BCD(x) ((((VERSION_TENS(x) << 4) | VERSION_ONES(x)) << 8) | \
114 ((VERSION_TENTHS(x) << 4) | VERSION_HUNDREDTHS(x)))
115
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.
118 */
119 #define LANGUAGE_ID_ENG 0x0409
120
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
123 * device to host).
124 */
125 #define ENDPOINT_DESCRIPTOR_DIR_IN 0x80
126
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
129 * host to device).
130 */
131 #define ENDPOINT_DESCRIPTOR_DIR_OUT 0x00
132
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.
136 */
137 #define USB_CONFIG_ATTR_BUSPOWERED 0x80
138
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.
142 */
143 #define USB_CONFIG_ATTR_SELFPOWERED 0x40
144
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
148 * request.
149 */
150 #define USB_CONFIG_ATTR_REMOTEWAKEUP 0x20
151
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.
154 *
155 * \see The USB specification for more details on the possible Endpoint attributes.
156 */
157 #define ENDPOINT_ATTR_NO_SYNC (0 << 2)
158
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.
161 *
162 * \see The USB specification for more details on the possible Endpoint attributes.
163 */
164 #define ENDPOINT_ATTR_ASYNC (1 << 2)
165
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.
168 *
169 * \see The USB specification for more details on the possible Endpoint attributes.
170 */
171 #define ENDPOINT_ATTR_ADAPTIVE (2 << 2)
172
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.
175 *
176 * \see The USB specification for more details on the possible Endpoint attributes.
177 */
178 #define ENDPOINT_ATTR_SYNC (3 << 2)
179
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.
182 *
183 * \see The USB specification for more details on the possible Endpoint usage attributes.
184 */
185 #define ENDPOINT_USAGE_DATA (0 << 4)
186
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.
189 *
190 * \see The USB specification for more details on the possible Endpoint usage attributes.
191 */
192 #define ENDPOINT_USAGE_FEEDBACK (1 << 4)
193
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.
196 *
197 * \see The USB specification for more details on the possible Endpoint usage attributes.
198 */
199 #define ENDPOINT_USAGE_IMPLICIT_FEEDBACK (2 << 4)
200
201 /* Enums: */
202 /** Enum for the possible standard descriptor types, as given in each descriptor's header. */
203 enum USB_DescriptorTypes_t
204 {
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. */
214 };
215
216 /* Type Defines: */
217 /** \brief Standard USB Descriptor Header (LUFA naming conventions).
218 *
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.
221 *
222 * \see \ref USB_StdDescriptor_Header_t for the version of this define with standard element names
223 */
224 typedef struct
225 {
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.
229 */
230 } USB_Descriptor_Header_t;
231
232 /** \brief Standard USB Descriptor Header (USB-IF naming conventions).
233 *
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.
236 *
237 * \see \ref USB_Descriptor_Header_t for the version of this define with non-standard LUFA specific element names
238 */
239 typedef struct
240 {
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.
244 */
245 } USB_StdDescriptor_Header_t;
246
247 /** \brief Standard USB Device Descriptor (LUFA naming conventions).
248 *
249 * Type define for a standard Device Descriptor. This structure uses LUFA-specific element names to make each
250 * element's purpose clearer.
251 *
252 * \see \ref USB_StdDescriptor_Device_t for the version of this define with standard element names
253 */
254 typedef struct
255 {
256 USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */
257
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. */
262
263 uint8_t Endpoint0Size; /**< Size of the control (address 0) endpoint's bank in bytes. */
264
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. */
268
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.
272 *
273 * \note If no string supplied, use \ref NO_DESCRIPTOR.
274 */
275 uint8_t ProductStrIndex; /**< String index for the product name/details.
276 *
277 * \see ManufacturerStrIndex structure entry.
278 */
279 uint8_t SerialNumStrIndex; /**< String index for the product's globally unique hexadecimal
280 * serial number, in uppercase Unicode ASCII.
281 *
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
287 * insertion.
288 *
289 * \see ManufacturerStrIndex structure entry.
290 */
291 uint8_t NumberOfConfigurations; /**< Total number of configurations supported by
292 * the device.
293 */
294 } USB_Descriptor_Device_t;
295
296 /** \brief Standard USB Device Descriptor (USB-IF naming conventions).
297 *
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.
300 *
301 * \see \ref USB_Descriptor_Device_t for the version of this define with non-standard LUFA specific element names
302 */
303 typedef struct
304 {
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.
308 */
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.
320 *
321 * \note If no string supplied, use \ref NO_DESCRIPTOR.
322 */
323 uint8_t iProduct; /**< String index for the product name/details.
324 *
325 * \see ManufacturerStrIndex structure entry.
326 */
327 uint8_t iSerialNumber; /**< String index for the product's globally unique hexadecimal
328 * serial number, in uppercase Unicode ASCII.
329 *
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
335 * insertion.
336 *
337 * \see ManufacturerStrIndex structure entry.
338 */
339 uint8_t bNumConfigurations; /**< Total number of configurations supported by
340 * the device.
341 */
342 } USB_StdDescriptor_Device_t;
343
344 /** \brief Standard USB Configuration Descriptor (LUFA naming conventions).
345 *
346 * Type define for a standard Configuration Descriptor header. This structure uses LUFA-specific element names
347 * to make each element's purpose clearer.
348 *
349 * \see \ref USB_StdDescriptor_Configuration_Header_t for the version of this define with standard element names
350 */
351 typedef struct
352 {
353 USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */
354
355 uint16_t TotalConfigurationSize; /**< Size of the configuration descriptor header,
356 * and all sub descriptors inside the configuration.
357 */
358 uint8_t TotalInterfaces; /**< Total number of interfaces in the configuration. */
359
360 uint8_t ConfigurationNumber; /**< Configuration index of the current configuration. */
361 uint8_t ConfigurationStrIndex; /**< Index of a string descriptor describing the configuration. */
362
363 uint8_t ConfigAttributes; /**< Configuration attributes, comprised of a mask of zero or
364 * more USB_CONFIG_ATTR_* masks.
365 */
366
367 uint8_t MaxPowerConsumption; /**< 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_Descriptor_Configuration_Header_t;
372
373 /** \brief Standard USB Configuration Descriptor (USB-IF naming conventions).
374 *
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.
377 *
378 * \see \ref USB_Descriptor_Device_t for the version of this define with non-standard LUFA specific element names
379 */
380 typedef struct
381 {
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.
385 */
386 uint16_t wTotalLength; /**< Size of the configuration descriptor header,
387 * and all sub descriptors inside the configuration.
388 */
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.
394 */
395 uint8_t bMaxPower; /**< Maximum power consumption of the device while in the
396 * current configuration, calculated by the \ref USB_CONFIG_POWER_MA()
397 * macro.
398 */
399 } USB_StdDescriptor_Configuration_Header_t;
400
401 /** \brief Standard USB Interface Descriptor (LUFA naming conventions).
402 *
403 * Type define for a standard Interface Descriptor. This structure uses LUFA-specific element names
404 * to make each element's purpose clearer.
405 *
406 * \see \ref USB_StdDescriptor_Interface_t for the version of this define with standard element names
407 */
408 typedef struct
409 {
410 USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */
411
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.
417 */
418 uint8_t TotalEndpoints; /**< Total number of endpoints in the interface. */
419
420 uint8_t Class; /**< Interface class ID. */
421 uint8_t SubClass; /**< Interface subclass ID. */
422 uint8_t Protocol; /**< Interface protocol ID. */
423
424 uint8_t InterfaceStrIndex; /**< Index of the string descriptor describing the
425 * interface.
426 */
427 } USB_Descriptor_Interface_t;
428
429 /** \brief Standard USB Interface Descriptor (USB-IF naming conventions).
430 *
431 * Type define for a standard Interface Descriptor. This structure uses the relevant standard's given element names
432 * to ensure compatibility with the standard.
433 *
434 * \see \ref USB_Descriptor_Interface_t for the version of this define with non-standard LUFA specific element names
435 */
436 typedef struct
437 {
438 uint8_t bLength; /**< Size of the descriptor, in bytes. */
439 uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
440 * given by the specific class.
441 */
442 uint8_t bInterfaceNumber; /**< Index of the interface in the current configuration. */
443 uint8_t bAlternateSetting; /**< Alternate setting for the interface number. The same
444 * interface number can have multiple alternate settings
445 * with different endpoint configurations, which can be
446 * selected by the host.
447 */
448 uint8_t bNumEndpoints; /**< Total number of endpoints in the interface. */
449 uint8_t bInterfaceClass; /**< Interface class ID. */
450 uint8_t bInterfaceSubClass; /**< Interface subclass ID. */
451 uint8_t bInterfaceProtocol; /**< Interface protocol ID. */
452 uint8_t iInterface; /**< Index of the string descriptor describing the
453 * interface.
454 */
455 } USB_StdDescriptor_Interface_t;
456
457 /** \brief Standard USB Interface Association Descriptor (LUFA naming conventions).
458 *
459 * Type define for a standard Interface Association Descriptor. This structure uses LUFA-specific element names
460 * to make each element's purpose clearer.
461 *
462 * This descriptor has been added as a supplement to the USB2.0 standard, in the ECN located at
463 * <a>http://www.usb.org/developers/docs/InterfaceAssociationDescriptor_ecn.pdf</a>. It allows compound
464 * devices with multiple interfaces related to the same function to have the multiple interfaces bound
465 * together at the point of enumeration, loading one generic driver for all the interfaces in the single
466 * function. Read the ECN for more information.
467 *
468 * \see \ref USB_StdDescriptor_Interface_Association_t for the version of this define with standard element names
469 */
470 typedef struct
471 {
472 USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */
473
474 uint8_t FirstInterfaceIndex; /**< Index of the first associated interface. */
475 uint8_t TotalInterfaces; /** Total number of associated interfaces. */
476
477 uint8_t Class; /**< Interface class ID. */
478 uint8_t SubClass; /**< Interface subclass ID. */
479 uint8_t Protocol; /**< Interface protocol ID. */
480
481 uint8_t IADStrIndex; /**< Index of the string descriptor describing the
482 * interface association.
483 */
484 } USB_Descriptor_Interface_Association_t;
485
486 /** \brief Standard USB Interface Association Descriptor (USB-IF naming conventions).
487 *
488 * Type define for a standard Interface Association Descriptor. This structure uses the relevant standard's given
489 * element names to ensure compatibility with the standard.
490 *
491 * This descriptor has been added as a supplement to the USB2.0 standard, in the ECN located at
492 * <a>http://www.usb.org/developers/docs/InterfaceAssociationDescriptor_ecn.pdf</a>. It allows compound
493 * devices with multiple interfaces related to the same function to have the multiple interfaces bound
494 * together at the point of enumeration, loading one generic driver for all the interfaces in the single
495 * function. Read the ECN for more information.
496 *
497 * \see \ref USB_Descriptor_Interface_Association_t for the version of this define with non-standard LUFA specific
498 * element names
499 */
500 typedef struct
501 {
502 uint8_t bLength; /**< Size of the descriptor, in bytes. */
503 uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
504 * given by the specific class.
505 */
506 uint8_t bFirstInterface; /**< Index of the first associated interface. */
507 uint8_t bInterfaceCount; /** Total number of associated interfaces. */
508 uint8_t bFunctionClass; /**< Interface class ID. */
509 uint8_t bFunctionSubClass; /**< Interface subclass ID. */
510 uint8_t bFunctionProtocol; /**< Interface protocol ID. */
511 uint8_t iFunction; /**< Index of the string descriptor describing the
512 * interface association.
513 */
514 } USB_StdDescriptor_Interface_Association_t;
515
516 /** \brief Standard USB Endpoint Descriptor (LUFA naming conventions).
517 *
518 * Type define for a standard Endpoint Descriptor. This structure uses LUFA-specific element names
519 * to make each element's purpose clearer.
520 *
521 * \see \ref USB_StdDescriptor_Endpoint_t for the version of this define with standard element names
522 */
523 typedef struct
524 {
525 USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */
526
527 uint8_t EndpointAddress; /**< Logical address of the endpoint within the device
528 * for the current configuration, including direction
529 * mask.
530 */
531 uint8_t Attributes; /**< Endpoint attributes, comprised of a mask of the
532 * endpoint type (EP_TYPE_*) and attributes (ENDPOINT_ATTR_*)
533 * masks.
534 */
535 uint16_t EndpointSize; /**< Size of the endpoint bank, in bytes. This indicates the
536 * maximum packet size that the endpoint can receive at a time.
537 */
538
539 uint8_t PollingIntervalMS; /**< Polling interval in milliseconds for the endpoint
540 * if it is an INTERRUPT or ISOCHRONOUS type.
541 */
542 } USB_Descriptor_Endpoint_t;
543
544 /** \brief Standard USB Endpoint Descriptor (USB-IF naming conventions).
545 *
546 * Type define for a standard Endpoint Descriptor. This structure uses the relevant standard's given
547 * element names to ensure compatibility with the standard.
548 *
549 * \see \ref USB_Descriptor_Endpoint_t for the version of this define with non-standard LUFA specific
550 * element names
551 */
552 typedef struct
553 {
554 uint8_t bLength; /**< Size of the descriptor, in bytes. */
555 uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
556 * given by the specific class.
557 */
558 uint8_t bEndpointAddress; /**< Logical address of the endpoint within the device
559 * for the current configuration, including direction
560 * mask.
561 */
562 uint8_t bmAttributes; /**< Endpoint attributes, comprised of a mask of the
563 * endpoint type (EP_TYPE_*) and attributes (ENDPOINT_ATTR_*)
564 * masks.
565 */
566 uint16_t wMaxPacketSize; /**< Size of the endpoint bank, in bytes. This indicates the
567 * maximum packet size that the endpoint can receive at a time.
568 */
569 uint8_t bInterval; /**< Polling interval in milliseconds for the endpoint
570 * if it is an INTERRUPT or ISOCHRONOUS type.
571 */
572 } USB_StdDescriptor_Endpoint_t;
573
574 /** \brief Standard USB String Descriptor (LUFA naming conventions).
575 *
576 * Type define for a standard string descriptor. Unlike other standard descriptors, the length
577 * of the descriptor for placement in the descriptor header must be determined by the \ref USB_STRING_LEN()
578 * macro rather than by the size of the descriptor structure, as the length is not fixed.
579 *
580 * This structure should also be used for string index 0, which contains the supported language IDs for
581 * the device as an array.
582 *
583 * This structure uses LUFA-specific element names to make each element's purpose clearer.
584 *
585 * \see \ref USB_StdDescriptor_String_t for the version of this define with standard element names
586 */
587 typedef struct
588 {
589 USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */
590
591 wchar_t UnicodeString[]; /**< String data, as unicode characters (alternatively,
592 * string language IDs). If normal ASCII characters are
593 * to be used, they must be added as an array of characters
594 * rather than a normal C string so that they are widened to
595 * Unicode size.
596 *
597 * Under GCC, strings prefixed with the "L" character (before
598 * the opening string quotation mark) are considered to be
599 * Unicode strings, and may be used instead of an explicit
600 * array of ASCII characters.
601 */
602 } USB_Descriptor_String_t;
603
604 /** \brief Standard USB String Descriptor (USB-IF naming conventions).
605 *
606 * Type define for a standard string descriptor. Unlike other standard descriptors, the length
607 * of the descriptor for placement in the descriptor header must be determined by the \ref USB_STRING_LEN()
608 * macro rather than by the size of the descriptor structure, as the length is not fixed.
609 *
610 * This structure should also be used for string index 0, which contains the supported language IDs for
611 * the device as an array.
612 *
613 * This structure uses the relevant standard's given element names to ensure compatibility with the standard.
614 *
615 * \see \ref USB_Descriptor_String_t for the version of this define with with non-standard LUFA specific
616 * element names
617 */
618 typedef struct
619 {
620 uint8_t bLength; /**< Size of the descriptor, in bytes. */
621 uint8_t bDescriptorType; /**< Type of the descriptor, either a value in
622 * \ref USB_DescriptorTypes_t or a value
623 * given by the specific class.
624 */
625 int16_t bString[]; /**< String data, as unicode characters (alternatively,
626 * string language IDs). If normal ASCII characters are
627 * to be used, they must be added as an array of characters
628 * rather than a normal C string so that they are widened to
629 * Unicode size.
630 *
631 * Under GCC, strings prefixed with the "L" character (before
632 * the opening string quotation mark) are considered to be
633 * Unicode strings, and may be used instead of an explicit
634 * array of ASCII characters.
635 */
636 } USB_StdDescriptor_String_t;
637
638 /* Private Interface - For use in library only: */
639 #if !defined(__DOXYGEN__)
640 /* Macros: */
641 #define VERSION_TENS(x) (int)((x) / 10)
642 #define VERSION_ONES(x) (int)((x) - (10 * VERSION_TENS(x)))
643 #define VERSION_TENTHS(x) (int)(((x) - (int)(x)) * 10)
644 #define VERSION_HUNDREDTHS(x) (int)((((x) - (int)(x)) * 100) - (10 * VERSION_TENTHS(x)))
645 #endif
646
647 /* Disable C linkage for C++ Compilers: */
648 #if defined(__cplusplus)
649 }
650 #endif
651
652 #endif
653
654 /** @} */