Update copyrights for 2021.
[pub/USBasp.git] / LUFA / Drivers / USB / Core / StdDescriptors.h
1 /*
2 LUFA Library
3 Copyright (C) Dean Camera, 2021.
4
5 dean [at] fourwalledcubicle [dot] com
6 www.lufa-lib.org
7 */
8
9 /*
10 Copyright 2021 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 disclaims 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 Common standard USB Descriptor definitions for all architectures.
33 * \copydetails Group_StdDescriptors
34 *
35 * \note This file should not be included directly. It is automatically included as needed by the USB driver
36 * dispatch header located in LUFA/Drivers/USB/USB.h.
37 */
38
39 /** \ingroup Group_USB
40 * \defgroup Group_StdDescriptors USB Descriptors
41 * \brief Standard USB Descriptor definitions.
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 "../../../Common/Common.h"
54 #include "USBMode.h"
55 #include "Events.h"
56
57 /* Enable C linkage for C++ Compilers: */
58 #if defined(__cplusplus)
59 extern "C" {
60 #endif
61
62 /* Preprocessor Checks: */
63 #if !defined(__INCLUDE_FROM_USB_DRIVER)
64 #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
65 #endif
66
67 /* Public Interface - May be used in end-application: */
68 /* Macros: */
69 /** Indicates that a given descriptor does not exist in the device. This can be used inside descriptors
70 * for string descriptor indexes, or may be use as a return value for GetDescriptor when the specified
71 * descriptor does not exist.
72 */
73 #define NO_DESCRIPTOR 0
74
75 /** Macro to calculate the power value for the configuration descriptor, from a given number of milliamperes.
76 *
77 * \param[in] mA Maximum number of milliamps the device consumes when the given configuration is selected.
78 */
79 #define USB_CONFIG_POWER_MA(mA) ((mA) >> 1)
80
81 /** Macro to calculate the Unicode length of a string with a given number of Unicode characters.
82 * Should be used in string descriptor's headers for giving the string descriptor's byte length.
83 *
84 * \param[in] UnicodeChars Number of Unicode characters in the string text.
85 */
86 #define USB_STRING_LEN(UnicodeChars) (sizeof(USB_Descriptor_Header_t) + ((UnicodeChars) << 1))
87
88 /** Convenience macro to easily create \ref USB_Descriptor_String_t instances from a wide character string.
89 *
90 * \note This macro is for little-endian systems only.
91 *
92 * \param[in] String String to initialize a USB String Descriptor structure with.
93 */
94 #define USB_STRING_DESCRIPTOR(String) { .Header = {.Size = sizeof(USB_Descriptor_Header_t) + (sizeof(String) - 2), .Type = DTYPE_String}, .UnicodeString = String }
95
96 /** Convenience macro to easily create \ref USB_Descriptor_String_t instances from an array of characters.
97 *
98 * \param[in] ... Characters to initialize a USB String Descriptor structure with.
99 */
100 #define USB_STRING_DESCRIPTOR_ARRAY(...) { .Header = {.Size = sizeof(USB_Descriptor_Header_t) + sizeof((uint16_t[]){__VA_ARGS__}), .Type = DTYPE_String}, .UnicodeString = {__VA_ARGS__} }
101
102 /** Macro to encode a given major/minor/revision version number into Binary Coded Decimal format for descriptor
103 * fields requiring BCD encoding, such as the USB version number in the standard device descriptor.
104 *
105 * \note This value is automatically converted into Little Endian, suitable for direct use inside device
106 * descriptors on all architectures without endianness conversion macros.
107 *
108 * \param[in] Major Major version number to encode.
109 * \param[in] Minor Minor version number to encode.
110 * \param[in] Revision Revision version number to encode.
111 */
112 #define VERSION_BCD(Major, Minor, Revision) \
113 CPU_TO_LE16( ((Major & 0xFF) << 8) | \
114 ((Minor & 0x0F) << 4) | \
115 (Revision & 0x0F) )
116
117 /** String language ID for the English language. Should be used in \ref USB_Descriptor_String_t descriptors
118 * to indicate that the English language is supported by the device in its string descriptors.
119 */
120 #define LANGUAGE_ID_ENG 0x0409
121
122 /** \name USB Configuration Descriptor Attribute Masks */
123 /**@{*/
124 /** Mask for the reserved bit in the Configuration Descriptor's \c ConfigAttributes field, which must be always
125 * set on all USB devices for historical purposes.
126 */
127 #define USB_CONFIG_ATTR_RESERVED 0x80
128
129 /** Can be masked with other configuration descriptor attributes for a \ref USB_Descriptor_Configuration_Header_t
130 * descriptor's \c ConfigAttributes value to indicate that the specified configuration can draw its power
131 * from the device's own power source, instead of drawing it from the USB host.
132 *
133 * Note that the host will probe this dynamically - the device should report its current power state via the
134 * \ref USB_Device_CurrentlySelfPowered global variable.
135 */
136 #define USB_CONFIG_ATTR_SELFPOWERED 0x40
137
138 /** Can be masked with other configuration descriptor attributes for a \ref USB_Descriptor_Configuration_Header_t
139 * descriptor's \c ConfigAttributes value to indicate that the specified configuration supports the
140 * remote wakeup feature of the USB standard, allowing a suspended USB device to wake up the host upon
141 * request.
142 *
143 * If set, the host will dynamically enable and disable remote wakeup support, indicated via the
144 * \ref USB_Device_RemoteWakeupEnabled global variable. To initiate a remote wakeup of the host (when allowed)
145 * see \ref USB_Device_RemoteWakeupEnabled().
146 */
147 #define USB_CONFIG_ATTR_REMOTEWAKEUP 0x20
148 /**@}*/
149
150 /** \name Endpoint Descriptor Attribute Masks */
151 /**@{*/
152 /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
153 * \c 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 * \c 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 * \c 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 * \c 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
181 /** \name Endpoint Descriptor Usage Masks */
182 /**@{*/
183 /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
184 * \c Attributes value to indicate that the specified endpoint is used for data transfers.
185 *
186 * \see The USB specification for more details on the possible Endpoint usage attributes.
187 */
188 #define ENDPOINT_USAGE_DATA (0 << 4)
189
190 /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
191 * \c Attributes value to indicate that the specified endpoint is used for feedback.
192 *
193 * \see The USB specification for more details on the possible Endpoint usage attributes.
194 */
195 #define ENDPOINT_USAGE_FEEDBACK (1 << 4)
196
197 /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
198 * \c Attributes value to indicate that the specified endpoint is used for implicit feedback.
199 *
200 * \see The USB specification for more details on the possible Endpoint usage attributes.
201 */
202 #define ENDPOINT_USAGE_IMPLICIT_FEEDBACK (2 << 4)
203 /**@}*/
204
205 /* Enums: */
206 /** Enum for the possible standard descriptor types, as given in each descriptor's header. */
207 enum USB_DescriptorTypes_t
208 {
209 DTYPE_Device = 0x01, /**< Indicates that the descriptor is a device descriptor. */
210 DTYPE_Configuration = 0x02, /**< Indicates that the descriptor is a configuration descriptor. */
211 DTYPE_String = 0x03, /**< Indicates that the descriptor is a string descriptor. */
212 DTYPE_Interface = 0x04, /**< Indicates that the descriptor is an interface descriptor. */
213 DTYPE_Endpoint = 0x05, /**< Indicates that the descriptor is an endpoint descriptor. */
214 DTYPE_DeviceQualifier = 0x06, /**< Indicates that the descriptor is a device qualifier descriptor. */
215 DTYPE_Other = 0x07, /**< Indicates that the descriptor is of other type. */
216 DTYPE_InterfacePower = 0x08, /**< Indicates that the descriptor is an interface power descriptor. */
217 DTYPE_InterfaceAssociation = 0x0B, /**< Indicates that the descriptor is an interface association descriptor. */
218 };
219
220 /** Enum for possible Class, Subclass and Protocol values of device and interface descriptors. */
221 enum USB_Descriptor_ClassSubclassProtocol_t
222 {
223 USB_CSCP_NoDeviceClass = 0x00, /**< Descriptor Class value indicating that the device does not belong
224 * to a particular class at the device level.
225 */
226 USB_CSCP_NoDeviceSubclass = 0x00, /**< Descriptor Subclass value indicating that the device does not belong
227 * to a particular subclass at the device level.
228 */
229 USB_CSCP_NoDeviceProtocol = 0x00, /**< Descriptor Protocol value indicating that the device does not belong
230 * to a particular protocol at the device level.
231 */
232 USB_CSCP_VendorSpecificClass = 0xFF, /**< Descriptor Class value indicating that the device/interface belongs
233 * to a vendor specific class.
234 */
235 USB_CSCP_VendorSpecificSubclass = 0xFF, /**< Descriptor Subclass value indicating that the device/interface belongs
236 * to a vendor specific subclass.
237 */
238 USB_CSCP_VendorSpecificProtocol = 0xFF, /**< Descriptor Protocol value indicating that the device/interface belongs
239 * to a vendor specific protocol.
240 */
241 USB_CSCP_IADDeviceClass = 0xEF, /**< Descriptor Class value indicating that the device belongs to the
242 * Interface Association Descriptor class.
243 */
244 USB_CSCP_IADDeviceSubclass = 0x02, /**< Descriptor Subclass value indicating that the device belongs to the
245 * Interface Association Descriptor subclass.
246 */
247 USB_CSCP_IADDeviceProtocol = 0x01, /**< Descriptor Protocol value indicating that the device belongs to the
248 * Interface Association Descriptor protocol.
249 */
250 };
251
252 /* Type Defines: */
253 /** \brief Standard USB Descriptor Header (LUFA naming conventions).
254 *
255 * Type define for all descriptors' standard header, indicating the descriptor's length and type. This structure
256 * uses LUFA-specific element names to make each element's purpose clearer.
257 *
258 * \see \ref USB_StdDescriptor_Header_t for the version of this type with standard element names.
259 *
260 * \note Regardless of CPU architecture, these values should be stored as little endian.
261 */
262 typedef struct
263 {
264 uint8_t Size; /**< Size of the descriptor, in bytes. */
265 uint8_t Type; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
266 * given by the specific class.
267 */
268 } ATTR_PACKED USB_Descriptor_Header_t;
269
270 /** \brief Standard USB Descriptor Header (USB-IF naming conventions).
271 *
272 * Type define for all descriptors' standard header, indicating the descriptor's length and type. This structure
273 * uses the relevant standard's given element names to ensure compatibility with the standard.
274 *
275 * \see \ref USB_Descriptor_Header_t for the version of this type with non-standard LUFA specific element names.
276 *
277 * \note Regardless of CPU architecture, these values should be stored as little endian.
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 } ATTR_PACKED USB_StdDescriptor_Header_t;
286
287 /** \brief Standard USB Device Descriptor (LUFA naming conventions).
288 *
289 * Type define for a standard Device Descriptor. This structure uses LUFA-specific element names to make each
290 * element's purpose clearer.
291 *
292 * \see \ref USB_StdDescriptor_Device_t for the version of this type with standard element names.
293 *
294 * \note Regardless of CPU architecture, these values should be stored as little endian.
295 */
296 typedef struct
297 {
298 USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */
299
300 uint16_t USBSpecification; /**< BCD of the supported USB specification.
301 *
302 * \see \ref VERSION_BCD() utility macro.
303 */
304 uint8_t Class; /**< USB device class. */
305 uint8_t SubClass; /**< USB device subclass. */
306 uint8_t Protocol; /**< USB device protocol. */
307
308 uint8_t Endpoint0Size; /**< Size of the control (address 0) endpoint's bank in bytes. */
309
310 uint16_t VendorID; /**< Vendor ID for the USB product. */
311 uint16_t ProductID; /**< Unique product ID for the USB product. */
312 uint16_t ReleaseNumber; /**< Product release (version) number.
313 *
314 * \see \ref VERSION_BCD() utility macro.
315 */
316 uint8_t ManufacturerStrIndex; /**< String index for the manufacturer's name. The
317 * host will request this string via a separate
318 * control request for the string descriptor.
319 *
320 * \note If no string supplied, use \ref NO_DESCRIPTOR.
321 */
322 uint8_t ProductStrIndex; /**< String index for the product name/details.
323 *
324 * \see ManufacturerStrIndex structure entry.
325 */
326 uint8_t SerialNumStrIndex; /**< String index for the product's globally unique hexadecimal
327 * serial number, in uppercase Unicode ASCII.
328 *
329 * \note On some microcontroller models, there is an embedded serial number
330 * in the chip which can be used for the device serial number.
331 * To use this serial number, set this to \c USE_INTERNAL_SERIAL.
332 * On unsupported devices, this will evaluate to \ref NO_DESCRIPTOR
333 * and will cause the host to generate a pseudo-unique value for the
334 * device upon insertion.
335 *
336 * \see \c ManufacturerStrIndex structure entry.
337 */
338 uint8_t NumberOfConfigurations; /**< Total number of configurations supported by
339 * the device.
340 */
341 } ATTR_PACKED USB_Descriptor_Device_t;
342
343 /** \brief Standard USB Device Descriptor (USB-IF naming conventions).
344 *
345 * Type define for a standard Device Descriptor. 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 type with non-standard LUFA specific element names.
349 *
350 * \note Regardless of CPU architecture, these values should be stored as little endian.
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 bcdUSB; /**< BCD of the supported USB specification.
359 *
360 * \see \ref VERSION_BCD() utility macro.
361 */
362 uint8_t bDeviceClass; /**< USB device class. */
363 uint8_t bDeviceSubClass; /**< USB device subclass. */
364 uint8_t bDeviceProtocol; /**< USB device protocol. */
365 uint8_t bMaxPacketSize0; /**< Size of the control (address 0) endpoint's bank in bytes. */
366 uint16_t idVendor; /**< Vendor ID for the USB product. */
367 uint16_t idProduct; /**< Unique product ID for the USB product. */
368 uint16_t bcdDevice; /**< Product release (version) number.
369 *
370 * \see \ref VERSION_BCD() utility macro.
371 */
372 uint8_t iManufacturer; /**< String index for the manufacturer's name. The
373 * host will request this string via a separate
374 * control request for the string descriptor.
375 *
376 * \note If no string supplied, use \ref NO_DESCRIPTOR.
377 */
378 uint8_t iProduct; /**< String index for the product name/details.
379 *
380 * \see ManufacturerStrIndex structure entry.
381 */
382 uint8_t iSerialNumber; /**< String index for the product's globally unique hexadecimal
383 * serial number, in uppercase Unicode ASCII.
384 *
385 * \note On some microcontroller models, there is an embedded serial number
386 * in the chip which can be used for the device serial number.
387 * To use this serial number, set this to \c USE_INTERNAL_SERIAL.
388 * On unsupported devices, this will evaluate to \ref NO_DESCRIPTOR
389 * and will cause the host to generate a pseudo-unique value for the
390 * device upon insertion.
391 *
392 * \see \c ManufacturerStrIndex structure entry.
393 */
394 uint8_t bNumConfigurations; /**< Total number of configurations supported by
395 * the device.
396 */
397 } ATTR_PACKED USB_StdDescriptor_Device_t;
398
399 /** \brief Standard USB Device Qualifier Descriptor (LUFA naming conventions).
400 *
401 * Type define for a standard Device Qualifier Descriptor. This structure uses LUFA-specific element names
402 * to make each element's purpose clearer.
403 *
404 * \see \ref USB_StdDescriptor_DeviceQualifier_t for the version of this type with standard element names.
405 */
406 typedef struct
407 {
408 USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */
409
410 uint16_t USBSpecification; /**< BCD of the supported USB specification.
411 *
412 * \see \ref VERSION_BCD() utility macro.
413 */
414 uint8_t Class; /**< USB device class. */
415 uint8_t SubClass; /**< USB device subclass. */
416 uint8_t Protocol; /**< USB device protocol. */
417
418 uint8_t Endpoint0Size; /**< Size of the control (address 0) endpoint's bank in bytes. */
419 uint8_t NumberOfConfigurations; /**< Total number of configurations supported by
420 * the device.
421 */
422 uint8_t Reserved; /**< Reserved for future use, must be 0. */
423 } ATTR_PACKED USB_Descriptor_DeviceQualifier_t;
424
425 /** \brief Standard USB Device Qualifier Descriptor (USB-IF naming conventions).
426 *
427 * Type define for a standard Device Qualifier Descriptor. This structure uses the relevant standard's given element names
428 * to ensure compatibility with the standard.
429 *
430 * \see \ref USB_Descriptor_DeviceQualifier_t for the version of this type with non-standard LUFA specific element names.
431 */
432 typedef struct
433 {
434 uint8_t bLength; /**< Size of the descriptor, in bytes. */
435 uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
436 * given by the specific class.
437 */
438 uint16_t bcdUSB; /**< BCD of the supported USB specification.
439 *
440 * \see \ref VERSION_BCD() utility macro.
441 */
442 uint8_t bDeviceClass; /**< USB device class. */
443 uint8_t bDeviceSubClass; /**< USB device subclass. */
444 uint8_t bDeviceProtocol; /**< USB device protocol. */
445 uint8_t bMaxPacketSize0; /**< Size of the control (address 0) endpoint's bank in bytes. */
446 uint8_t bNumConfigurations; /**< Total number of configurations supported by
447 * the device.
448 */
449 uint8_t bReserved; /**< Reserved for future use, must be 0. */
450 } ATTR_PACKED USB_StdDescriptor_DeviceQualifier_t;
451
452 /** \brief Standard USB Configuration Descriptor (LUFA naming conventions).
453 *
454 * Type define for a standard Configuration Descriptor header. This structure uses LUFA-specific element names
455 * to make each element's purpose clearer.
456 *
457 * \see \ref USB_StdDescriptor_Configuration_Header_t for the version of this type with standard element names.
458 *
459 * \note Regardless of CPU architecture, these values should be stored as little endian.
460 */
461 typedef struct
462 {
463 USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */
464
465 uint16_t TotalConfigurationSize; /**< Size of the configuration descriptor header,
466 * and all sub descriptors inside the configuration.
467 */
468 uint8_t TotalInterfaces; /**< Total number of interfaces in the configuration. */
469
470 uint8_t ConfigurationNumber; /**< Configuration index of the current configuration. */
471 uint8_t ConfigurationStrIndex; /**< Index of a string descriptor describing the configuration. */
472
473 uint8_t ConfigAttributes; /**< Configuration attributes, comprised of a mask of \c USB_CONFIG_ATTR_* masks.
474 * On all devices, this should include USB_CONFIG_ATTR_RESERVED at a minimum.
475 */
476
477 uint8_t MaxPowerConsumption; /**< Maximum power consumption of the device while in the
478 * current configuration, calculated by the \ref USB_CONFIG_POWER_MA()
479 * macro.
480 */
481 } ATTR_PACKED USB_Descriptor_Configuration_Header_t;
482
483 /** \brief Standard USB Configuration Descriptor (USB-IF naming conventions).
484 *
485 * Type define for a standard Configuration Descriptor header. This structure uses the relevant standard's given element names
486 * to ensure compatibility with the standard.
487 *
488 * \see \ref USB_Descriptor_Device_t for the version of this type with non-standard LUFA specific element names.
489 *
490 * \note Regardless of CPU architecture, these values should be stored as little endian.
491 */
492 typedef struct
493 {
494 uint8_t bLength; /**< Size of the descriptor, in bytes. */
495 uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
496 * given by the specific class.
497 */
498 uint16_t wTotalLength; /**< Size of the configuration descriptor header,
499 * and all sub descriptors inside the configuration.
500 */
501 uint8_t bNumInterfaces; /**< Total number of interfaces in the configuration. */
502 uint8_t bConfigurationValue; /**< Configuration index of the current configuration. */
503 uint8_t iConfiguration; /**< Index of a string descriptor describing the configuration. */
504 uint8_t bmAttributes; /**< Configuration attributes, comprised of a mask of \c USB_CONFIG_ATTR_* masks.
505 * On all devices, this should include USB_CONFIG_ATTR_RESERVED at a minimum.
506 */
507 uint8_t bMaxPower; /**< Maximum power consumption of the device while in the
508 * current configuration, calculated by the \ref USB_CONFIG_POWER_MA()
509 * macro.
510 */
511 } ATTR_PACKED USB_StdDescriptor_Configuration_Header_t;
512
513 /** \brief Standard USB Interface Descriptor (LUFA naming conventions).
514 *
515 * Type define for a standard Interface Descriptor. This structure uses LUFA-specific element names
516 * to make each element's purpose clearer.
517 *
518 * \see \ref USB_StdDescriptor_Interface_t for the version of this type with standard element names.
519 *
520 * \note Regardless of CPU architecture, these values should be stored as little endian.
521 */
522 typedef struct
523 {
524 USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */
525
526 uint8_t InterfaceNumber; /**< Index of the interface in the current configuration. */
527 uint8_t AlternateSetting; /**< Alternate setting for the interface number. The same
528 * interface number can have multiple alternate settings
529 * with different endpoint configurations, which can be
530 * selected by the host.
531 */
532 uint8_t TotalEndpoints; /**< Total number of endpoints in the interface. */
533
534 uint8_t Class; /**< Interface class ID. */
535 uint8_t SubClass; /**< Interface subclass ID. */
536 uint8_t Protocol; /**< Interface protocol ID. */
537
538 uint8_t InterfaceStrIndex; /**< Index of the string descriptor describing the interface. */
539 } ATTR_PACKED USB_Descriptor_Interface_t;
540
541 /** \brief Standard USB Interface Descriptor (USB-IF naming conventions).
542 *
543 * Type define for a standard Interface Descriptor. This structure uses the relevant standard's given element names
544 * to ensure compatibility with the standard.
545 *
546 * \see \ref USB_Descriptor_Interface_t for the version of this type with non-standard LUFA specific element names.
547 *
548 * \note Regardless of CPU architecture, these values should be stored as little endian.
549 */
550 typedef struct
551 {
552 uint8_t bLength; /**< Size of the descriptor, in bytes. */
553 uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
554 * given by the specific class.
555 */
556 uint8_t bInterfaceNumber; /**< Index of the interface in the current configuration. */
557 uint8_t bAlternateSetting; /**< Alternate setting for the interface number. The same
558 * interface number can have multiple alternate settings
559 * with different endpoint configurations, which can be
560 * selected by the host.
561 */
562 uint8_t bNumEndpoints; /**< Total number of endpoints in the interface. */
563 uint8_t bInterfaceClass; /**< Interface class ID. */
564 uint8_t bInterfaceSubClass; /**< Interface subclass ID. */
565 uint8_t bInterfaceProtocol; /**< Interface protocol ID. */
566 uint8_t iInterface; /**< Index of the string descriptor describing the
567 * interface.
568 */
569 } ATTR_PACKED USB_StdDescriptor_Interface_t;
570
571 /** \brief Standard USB Interface Association Descriptor (LUFA naming conventions).
572 *
573 * Type define for a standard Interface Association Descriptor. This structure uses LUFA-specific element names
574 * to make each element's purpose clearer.
575 *
576 * This descriptor has been added as a supplement to the USB2.0 standard, in the ECN located at
577 * <a>http://www.usb.org/developers/docs/InterfaceAssociationDescriptor_ecn.pdf</a>. It allows composite
578 * devices with multiple interfaces related to the same function to have the multiple interfaces bound
579 * together at the point of enumeration, loading one generic driver for all the interfaces in the single
580 * function. Read the ECN for more information.
581 *
582 * \see \ref USB_StdDescriptor_Interface_Association_t for the version of this type with standard element names.
583 *
584 * \note Regardless of CPU architecture, these values should be stored as little endian.
585 */
586 typedef struct
587 {
588 USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */
589
590 uint8_t FirstInterfaceIndex; /**< Index of the first associated interface. */
591 uint8_t TotalInterfaces; /**< Total number of associated interfaces. */
592
593 uint8_t Class; /**< Interface class ID. */
594 uint8_t SubClass; /**< Interface subclass ID. */
595 uint8_t Protocol; /**< Interface protocol ID. */
596
597 uint8_t IADStrIndex; /**< Index of the string descriptor describing the
598 * interface association.
599 */
600 } ATTR_PACKED USB_Descriptor_Interface_Association_t;
601
602 /** \brief Standard USB Interface Association Descriptor (USB-IF naming conventions).
603 *
604 * Type define for a standard Interface Association Descriptor. This structure uses the relevant standard's given
605 * element names to ensure compatibility with the standard.
606 *
607 * This descriptor has been added as a supplement to the USB2.0 standard, in the ECN located at
608 * <a>http://www.usb.org/developers/docs/InterfaceAssociationDescriptor_ecn.pdf</a>. It allows composite
609 * devices with multiple interfaces related to the same function to have the multiple interfaces bound
610 * together at the point of enumeration, loading one generic driver for all the interfaces in the single
611 * function. Read the ECN for more information.
612 *
613 * \see \ref USB_Descriptor_Interface_Association_t for the version of this type with non-standard LUFA specific
614 * element names.
615 *
616 * \note Regardless of CPU architecture, these values should be stored as little endian.
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 \ref USB_DescriptorTypes_t or a value
622 * given by the specific class.
623 */
624 uint8_t bFirstInterface; /**< Index of the first associated interface. */
625 uint8_t bInterfaceCount; /**< Total number of associated interfaces. */
626 uint8_t bFunctionClass; /**< Interface class ID. */
627 uint8_t bFunctionSubClass; /**< Interface subclass ID. */
628 uint8_t bFunctionProtocol; /**< Interface protocol ID. */
629 uint8_t iFunction; /**< Index of the string descriptor describing the
630 * interface association.
631 */
632 } ATTR_PACKED USB_StdDescriptor_Interface_Association_t;
633
634 /** \brief Standard USB Endpoint Descriptor (LUFA naming conventions).
635 *
636 * Type define for a standard Endpoint Descriptor. This structure uses LUFA-specific element names
637 * to make each element's purpose clearer.
638 *
639 * \see \ref USB_StdDescriptor_Endpoint_t for the version of this type with standard element names.
640 *
641 * \note Regardless of CPU architecture, these values should be stored as little endian.
642 */
643 typedef struct
644 {
645 USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */
646
647 uint8_t EndpointAddress; /**< Logical address of the endpoint within the device for the current
648 * configuration, including direction mask.
649 */
650 uint8_t Attributes; /**< Endpoint attributes, comprised of a mask of the endpoint type (EP_TYPE_*)
651 * and attributes (ENDPOINT_ATTR_*) masks.
652 */
653 uint16_t EndpointSize; /**< Size of the endpoint bank, in bytes. This indicates the maximum packet
654 * size that the endpoint can receive at a time.
655 */
656 uint8_t PollingIntervalMS; /**< Polling interval in milliseconds for the endpoint if it is an INTERRUPT
657 * or ISOCHRONOUS type.
658 */
659 } ATTR_PACKED USB_Descriptor_Endpoint_t;
660
661 /** \brief Standard USB Endpoint Descriptor (USB-IF naming conventions).
662 *
663 * Type define for a standard Endpoint Descriptor. This structure uses the relevant standard's given
664 * element names to ensure compatibility with the standard.
665 *
666 * \see \ref USB_Descriptor_Endpoint_t for the version of this type with non-standard LUFA specific
667 * element names.
668 *
669 * \note Regardless of CPU architecture, these values should be stored as little endian.
670 */
671 typedef struct
672 {
673 uint8_t bLength; /**< Size of the descriptor, in bytes. */
674 uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a
675 * value given by the specific class.
676 */
677 uint8_t bEndpointAddress; /**< Logical address of the endpoint within the device for the current
678 * configuration, including direction mask.
679 */
680 uint8_t bmAttributes; /**< Endpoint attributes, comprised of a mask of the endpoint type (EP_TYPE_*)
681 * and attributes (ENDPOINT_ATTR_*) masks.
682 */
683 uint16_t wMaxPacketSize; /**< Size of the endpoint bank, in bytes. This indicates the maximum packet size
684 * that the endpoint can receive at a time.
685 */
686 uint8_t bInterval; /**< Polling interval in milliseconds for the endpoint if it is an INTERRUPT or
687 * ISOCHRONOUS type.
688 */
689 } ATTR_PACKED USB_StdDescriptor_Endpoint_t;
690
691 /** \brief Standard USB String Descriptor (LUFA naming conventions).
692 *
693 * Type define for a standard string descriptor. Unlike other standard descriptors, the length
694 * of the descriptor for placement in the descriptor header must be determined by the \ref USB_STRING_LEN()
695 * macro rather than by the size of the descriptor structure, as the length is not fixed.
696 *
697 * This structure should also be used for string index 0, which contains the supported language IDs for
698 * the device as an array.
699 *
700 * This structure uses LUFA-specific element names to make each element's purpose clearer.
701 *
702 * \see \ref USB_StdDescriptor_String_t for the version of this type with standard element names.
703 *
704 * \note Regardless of CPU architecture, these values should be stored as little endian.
705 */
706 typedef struct
707 {
708 USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */
709
710 #if (((ARCH == ARCH_AVR8) || (ARCH == ARCH_XMEGA)) && !defined(__DOXYGEN__))
711 wchar_t UnicodeString[];
712 #else
713 uint16_t UnicodeString[]; /**< String data, as unicode characters (alternatively,
714 * string language IDs). If normal ASCII characters are
715 * to be used, they must be added as an array of characters
716 * rather than a normal C string so that they are widened to
717 * Unicode size.
718 *
719 * Under GCC, strings prefixed with the "L" character (before
720 * the opening string quotation mark) are considered to be
721 * Unicode strings, and may be used instead of an explicit
722 * array of ASCII characters on little endian devices with
723 * UTF-16-LE \c wchar_t encoding.
724 */
725 #endif
726 } ATTR_PACKED USB_Descriptor_String_t;
727
728 /** \brief Standard USB String Descriptor (USB-IF naming conventions).
729 *
730 * Type define for a standard string descriptor. Unlike other standard descriptors, the length
731 * of the descriptor for placement in the descriptor header must be determined by the \ref USB_STRING_LEN()
732 * macro rather than by the size of the descriptor structure, as the length is not fixed.
733 *
734 * This structure should also be used for string index 0, which contains the supported language IDs for
735 * the device as an array.
736 *
737 * This structure uses the relevant standard's given element names to ensure compatibility with the standard.
738 *
739 * \see \ref USB_Descriptor_String_t for the version of this type with with non-standard LUFA specific
740 * element names.
741 *
742 * \note Regardless of CPU architecture, these values should be stored as little endian.
743 */
744 typedef struct
745 {
746 uint8_t bLength; /**< Size of the descriptor, in bytes. */
747 uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t
748 * or a value given by the specific class.
749 */
750 uint16_t bString[]; /**< String data, as unicode characters (alternatively, string language IDs).
751 * If normal ASCII characters are to be used, they must be added as an array
752 * of characters rather than a normal C string so that they are widened to
753 * Unicode size.
754 *
755 * Under GCC, strings prefixed with the "L" character (before the opening string
756 * quotation mark) are considered to be Unicode strings, and may be used instead
757 * of an explicit array of ASCII characters.
758 */
759 } ATTR_PACKED USB_StdDescriptor_String_t;
760
761
762 /* Disable C linkage for C++ Compilers: */
763 #if defined(__cplusplus)
764 }
765 #endif
766
767 #endif
768
769 /** @} */
770