Update copyrights for 2018.
[pub/USBasp.git] / LUFA / Drivers / USB / Core / StdDescriptors.h
1 /*
2 LUFA Library
3 Copyright (C) Dean Camera, 2018.
4
5 dean [at] fourwalledcubicle [dot] com
6 www.lufa-lib.org
7 */
8
9 /*
10 Copyright 2018 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 DTYPE_CSInterface = 0x24, /**< Indicates that the descriptor is a class specific interface descriptor. */
219 DTYPE_CSEndpoint = 0x25, /**< Indicates that the descriptor is a class specific endpoint descriptor. */
220 };
221
222 /** Enum for possible Class, Subclass and Protocol values of device and interface descriptors. */
223 enum USB_Descriptor_ClassSubclassProtocol_t
224 {
225 USB_CSCP_NoDeviceClass = 0x00, /**< Descriptor Class value indicating that the device does not belong
226 * to a particular class at the device level.
227 */
228 USB_CSCP_NoDeviceSubclass = 0x00, /**< Descriptor Subclass value indicating that the device does not belong
229 * to a particular subclass at the device level.
230 */
231 USB_CSCP_NoDeviceProtocol = 0x00, /**< Descriptor Protocol value indicating that the device does not belong
232 * to a particular protocol at the device level.
233 */
234 USB_CSCP_VendorSpecificClass = 0xFF, /**< Descriptor Class value indicating that the device/interface belongs
235 * to a vendor specific class.
236 */
237 USB_CSCP_VendorSpecificSubclass = 0xFF, /**< Descriptor Subclass value indicating that the device/interface belongs
238 * to a vendor specific subclass.
239 */
240 USB_CSCP_VendorSpecificProtocol = 0xFF, /**< Descriptor Protocol value indicating that the device/interface belongs
241 * to a vendor specific protocol.
242 */
243 USB_CSCP_IADDeviceClass = 0xEF, /**< Descriptor Class value indicating that the device belongs to the
244 * Interface Association Descriptor class.
245 */
246 USB_CSCP_IADDeviceSubclass = 0x02, /**< Descriptor Subclass value indicating that the device belongs to the
247 * Interface Association Descriptor subclass.
248 */
249 USB_CSCP_IADDeviceProtocol = 0x01, /**< Descriptor Protocol value indicating that the device belongs to the
250 * Interface Association Descriptor protocol.
251 */
252 };
253
254 /* Type Defines: */
255 /** \brief Standard USB Descriptor Header (LUFA naming conventions).
256 *
257 * Type define for all descriptors' standard header, indicating the descriptor's length and type. This structure
258 * uses LUFA-specific element names to make each element's purpose clearer.
259 *
260 * \see \ref USB_StdDescriptor_Header_t for the version of this type with standard element names.
261 *
262 * \note Regardless of CPU architecture, these values should be stored as little endian.
263 */
264 typedef struct
265 {
266 uint8_t Size; /**< Size of the descriptor, in bytes. */
267 uint8_t Type; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
268 * given by the specific class.
269 */
270 } ATTR_PACKED USB_Descriptor_Header_t;
271
272 /** \brief Standard USB Descriptor Header (USB-IF naming conventions).
273 *
274 * Type define for all descriptors' standard header, indicating the descriptor's length and type. This structure
275 * uses the relevant standard's given element names to ensure compatibility with the standard.
276 *
277 * \see \ref USB_Descriptor_Header_t for the version of this type with non-standard LUFA specific element names.
278 *
279 * \note Regardless of CPU architecture, these values should be stored as little endian.
280 */
281 typedef struct
282 {
283 uint8_t bLength; /**< Size of the descriptor, in bytes. */
284 uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
285 * given by the specific class.
286 */
287 } ATTR_PACKED USB_StdDescriptor_Header_t;
288
289 /** \brief Standard USB Device Descriptor (LUFA naming conventions).
290 *
291 * Type define for a standard Device Descriptor. This structure uses LUFA-specific element names to make each
292 * element's purpose clearer.
293 *
294 * \see \ref USB_StdDescriptor_Device_t for the version of this type with standard element names.
295 *
296 * \note Regardless of CPU architecture, these values should be stored as little endian.
297 */
298 typedef struct
299 {
300 USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */
301
302 uint16_t USBSpecification; /**< BCD of the supported USB specification.
303 *
304 * \see \ref VERSION_BCD() utility macro.
305 */
306 uint8_t Class; /**< USB device class. */
307 uint8_t SubClass; /**< USB device subclass. */
308 uint8_t Protocol; /**< USB device protocol. */
309
310 uint8_t Endpoint0Size; /**< Size of the control (address 0) endpoint's bank in bytes. */
311
312 uint16_t VendorID; /**< Vendor ID for the USB product. */
313 uint16_t ProductID; /**< Unique product ID for the USB product. */
314 uint16_t ReleaseNumber; /**< Product release (version) number.
315 *
316 * \see \ref VERSION_BCD() utility macro.
317 */
318 uint8_t ManufacturerStrIndex; /**< String index for the manufacturer's name. The
319 * host will request this string via a separate
320 * control request for the string descriptor.
321 *
322 * \note If no string supplied, use \ref NO_DESCRIPTOR.
323 */
324 uint8_t ProductStrIndex; /**< String index for the product name/details.
325 *
326 * \see ManufacturerStrIndex structure entry.
327 */
328 uint8_t SerialNumStrIndex; /**< String index for the product's globally unique hexadecimal
329 * serial number, in uppercase Unicode ASCII.
330 *
331 * \note On some microcontroller models, there is an embedded serial number
332 * in the chip which can be used for the device serial number.
333 * To use this serial number, set this to \c USE_INTERNAL_SERIAL.
334 * On unsupported devices, this will evaluate to \ref NO_DESCRIPTOR
335 * and will cause the host to generate a pseudo-unique value for the
336 * device upon insertion.
337 *
338 * \see \c ManufacturerStrIndex structure entry.
339 */
340 uint8_t NumberOfConfigurations; /**< Total number of configurations supported by
341 * the device.
342 */
343 } ATTR_PACKED USB_Descriptor_Device_t;
344
345 /** \brief Standard USB Device Descriptor (USB-IF naming conventions).
346 *
347 * Type define for a standard Device Descriptor. This structure uses the relevant standard's given element names
348 * to ensure compatibility with the standard.
349 *
350 * \see \ref USB_Descriptor_Device_t for the version of this type with non-standard LUFA specific element names.
351 *
352 * \note Regardless of CPU architecture, these values should be stored as little endian.
353 */
354 typedef struct
355 {
356 uint8_t bLength; /**< Size of the descriptor, in bytes. */
357 uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
358 * given by the specific class.
359 */
360 uint16_t bcdUSB; /**< BCD of the supported USB specification.
361 *
362 * \see \ref VERSION_BCD() utility macro.
363 */
364 uint8_t bDeviceClass; /**< USB device class. */
365 uint8_t bDeviceSubClass; /**< USB device subclass. */
366 uint8_t bDeviceProtocol; /**< USB device protocol. */
367 uint8_t bMaxPacketSize0; /**< Size of the control (address 0) endpoint's bank in bytes. */
368 uint16_t idVendor; /**< Vendor ID for the USB product. */
369 uint16_t idProduct; /**< Unique product ID for the USB product. */
370 uint16_t bcdDevice; /**< Product release (version) number.
371 *
372 * \see \ref VERSION_BCD() utility macro.
373 */
374 uint8_t iManufacturer; /**< String index for the manufacturer's name. The
375 * host will request this string via a separate
376 * control request for the string descriptor.
377 *
378 * \note If no string supplied, use \ref NO_DESCRIPTOR.
379 */
380 uint8_t iProduct; /**< String index for the product name/details.
381 *
382 * \see ManufacturerStrIndex structure entry.
383 */
384 uint8_t iSerialNumber; /**< String index for the product's globally unique hexadecimal
385 * serial number, in uppercase Unicode ASCII.
386 *
387 * \note On some microcontroller models, there is an embedded serial number
388 * in the chip which can be used for the device serial number.
389 * To use this serial number, set this to \c USE_INTERNAL_SERIAL.
390 * On unsupported devices, this will evaluate to \ref NO_DESCRIPTOR
391 * and will cause the host to generate a pseudo-unique value for the
392 * device upon insertion.
393 *
394 * \see \c ManufacturerStrIndex structure entry.
395 */
396 uint8_t bNumConfigurations; /**< Total number of configurations supported by
397 * the device.
398 */
399 } ATTR_PACKED USB_StdDescriptor_Device_t;
400
401 /** \brief Standard USB Device Qualifier Descriptor (LUFA naming conventions).
402 *
403 * Type define for a standard Device Qualifier Descriptor. This structure uses LUFA-specific element names
404 * to make each element's purpose clearer.
405 *
406 * \see \ref USB_StdDescriptor_DeviceQualifier_t for the version of this type with standard element names.
407 */
408 typedef struct
409 {
410 USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */
411
412 uint16_t USBSpecification; /**< BCD of the supported USB specification.
413 *
414 * \see \ref VERSION_BCD() utility macro.
415 */
416 uint8_t Class; /**< USB device class. */
417 uint8_t SubClass; /**< USB device subclass. */
418 uint8_t Protocol; /**< USB device protocol. */
419
420 uint8_t Endpoint0Size; /**< Size of the control (address 0) endpoint's bank in bytes. */
421 uint8_t NumberOfConfigurations; /**< Total number of configurations supported by
422 * the device.
423 */
424 uint8_t Reserved; /**< Reserved for future use, must be 0. */
425 } ATTR_PACKED USB_Descriptor_DeviceQualifier_t;
426
427 /** \brief Standard USB Device Qualifier Descriptor (USB-IF naming conventions).
428 *
429 * Type define for a standard Device Qualifier Descriptor. This structure uses the relevant standard's given element names
430 * to ensure compatibility with the standard.
431 *
432 * \see \ref USB_Descriptor_DeviceQualifier_t for the version of this type with non-standard LUFA specific element names.
433 */
434 typedef struct
435 {
436 uint8_t bLength; /**< Size of the descriptor, in bytes. */
437 uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
438 * given by the specific class.
439 */
440 uint16_t bcdUSB; /**< BCD of the supported USB specification.
441 *
442 * \see \ref VERSION_BCD() utility macro.
443 */
444 uint8_t bDeviceClass; /**< USB device class. */
445 uint8_t bDeviceSubClass; /**< USB device subclass. */
446 uint8_t bDeviceProtocol; /**< USB device protocol. */
447 uint8_t bMaxPacketSize0; /**< Size of the control (address 0) endpoint's bank in bytes. */
448 uint8_t bNumConfigurations; /**< Total number of configurations supported by
449 * the device.
450 */
451 uint8_t bReserved; /**< Reserved for future use, must be 0. */
452 } ATTR_PACKED USB_StdDescriptor_DeviceQualifier_t;
453
454 /** \brief Standard USB Configuration Descriptor (LUFA naming conventions).
455 *
456 * Type define for a standard Configuration Descriptor header. This structure uses LUFA-specific element names
457 * to make each element's purpose clearer.
458 *
459 * \see \ref USB_StdDescriptor_Configuration_Header_t for the version of this type with standard element names.
460 *
461 * \note Regardless of CPU architecture, these values should be stored as little endian.
462 */
463 typedef struct
464 {
465 USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */
466
467 uint16_t TotalConfigurationSize; /**< Size of the configuration descriptor header,
468 * and all sub descriptors inside the configuration.
469 */
470 uint8_t TotalInterfaces; /**< Total number of interfaces in the configuration. */
471
472 uint8_t ConfigurationNumber; /**< Configuration index of the current configuration. */
473 uint8_t ConfigurationStrIndex; /**< Index of a string descriptor describing the configuration. */
474
475 uint8_t ConfigAttributes; /**< Configuration attributes, comprised of a mask of \c USB_CONFIG_ATTR_* masks.
476 * On all devices, this should include USB_CONFIG_ATTR_RESERVED at a minimum.
477 */
478
479 uint8_t MaxPowerConsumption; /**< Maximum power consumption of the device while in the
480 * current configuration, calculated by the \ref USB_CONFIG_POWER_MA()
481 * macro.
482 */
483 } ATTR_PACKED USB_Descriptor_Configuration_Header_t;
484
485 /** \brief Standard USB Configuration Descriptor (USB-IF naming conventions).
486 *
487 * Type define for a standard Configuration Descriptor header. This structure uses the relevant standard's given element names
488 * to ensure compatibility with the standard.
489 *
490 * \see \ref USB_Descriptor_Device_t for the version of this type with non-standard LUFA specific element names.
491 *
492 * \note Regardless of CPU architecture, these values should be stored as little endian.
493 */
494 typedef struct
495 {
496 uint8_t bLength; /**< Size of the descriptor, in bytes. */
497 uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
498 * given by the specific class.
499 */
500 uint16_t wTotalLength; /**< Size of the configuration descriptor header,
501 * and all sub descriptors inside the configuration.
502 */
503 uint8_t bNumInterfaces; /**< Total number of interfaces in the configuration. */
504 uint8_t bConfigurationValue; /**< Configuration index of the current configuration. */
505 uint8_t iConfiguration; /**< Index of a string descriptor describing the configuration. */
506 uint8_t bmAttributes; /**< Configuration attributes, comprised of a mask of \c USB_CONFIG_ATTR_* masks.
507 * On all devices, this should include USB_CONFIG_ATTR_RESERVED at a minimum.
508 */
509 uint8_t bMaxPower; /**< Maximum power consumption of the device while in the
510 * current configuration, calculated by the \ref USB_CONFIG_POWER_MA()
511 * macro.
512 */
513 } ATTR_PACKED USB_StdDescriptor_Configuration_Header_t;
514
515 /** \brief Standard USB Interface Descriptor (LUFA naming conventions).
516 *
517 * Type define for a standard Interface Descriptor. This structure uses LUFA-specific element names
518 * to make each element's purpose clearer.
519 *
520 * \see \ref USB_StdDescriptor_Interface_t for the version of this type with standard element names.
521 *
522 * \note Regardless of CPU architecture, these values should be stored as little endian.
523 */
524 typedef struct
525 {
526 USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */
527
528 uint8_t InterfaceNumber; /**< Index of the interface in the current configuration. */
529 uint8_t AlternateSetting; /**< Alternate setting for the interface number. The same
530 * interface number can have multiple alternate settings
531 * with different endpoint configurations, which can be
532 * selected by the host.
533 */
534 uint8_t TotalEndpoints; /**< Total number of endpoints in the interface. */
535
536 uint8_t Class; /**< Interface class ID. */
537 uint8_t SubClass; /**< Interface subclass ID. */
538 uint8_t Protocol; /**< Interface protocol ID. */
539
540 uint8_t InterfaceStrIndex; /**< Index of the string descriptor describing the interface. */
541 } ATTR_PACKED USB_Descriptor_Interface_t;
542
543 /** \brief Standard USB Interface Descriptor (USB-IF naming conventions).
544 *
545 * Type define for a standard Interface Descriptor. This structure uses the relevant standard's given element names
546 * to ensure compatibility with the standard.
547 *
548 * \see \ref USB_Descriptor_Interface_t for the version of this type with non-standard LUFA specific element names.
549 *
550 * \note Regardless of CPU architecture, these values should be stored as little endian.
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 bInterfaceNumber; /**< Index of the interface in the current configuration. */
559 uint8_t bAlternateSetting; /**< Alternate setting for the interface number. The same
560 * interface number can have multiple alternate settings
561 * with different endpoint configurations, which can be
562 * selected by the host.
563 */
564 uint8_t bNumEndpoints; /**< Total number of endpoints in the interface. */
565 uint8_t bInterfaceClass; /**< Interface class ID. */
566 uint8_t bInterfaceSubClass; /**< Interface subclass ID. */
567 uint8_t bInterfaceProtocol; /**< Interface protocol ID. */
568 uint8_t iInterface; /**< Index of the string descriptor describing the
569 * interface.
570 */
571 } ATTR_PACKED USB_StdDescriptor_Interface_t;
572
573 /** \brief Standard USB Interface Association Descriptor (LUFA naming conventions).
574 *
575 * Type define for a standard Interface Association Descriptor. This structure uses LUFA-specific element names
576 * to make each element's purpose clearer.
577 *
578 * This descriptor has been added as a supplement to the USB2.0 standard, in the ECN located at
579 * <a>http://www.usb.org/developers/docs/InterfaceAssociationDescriptor_ecn.pdf</a>. It allows composite
580 * devices with multiple interfaces related to the same function to have the multiple interfaces bound
581 * together at the point of enumeration, loading one generic driver for all the interfaces in the single
582 * function. Read the ECN for more information.
583 *
584 * \see \ref USB_StdDescriptor_Interface_Association_t for the version of this type with standard element names.
585 *
586 * \note Regardless of CPU architecture, these values should be stored as little endian.
587 */
588 typedef struct
589 {
590 USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */
591
592 uint8_t FirstInterfaceIndex; /**< Index of the first associated interface. */
593 uint8_t TotalInterfaces; /**< Total number of associated interfaces. */
594
595 uint8_t Class; /**< Interface class ID. */
596 uint8_t SubClass; /**< Interface subclass ID. */
597 uint8_t Protocol; /**< Interface protocol ID. */
598
599 uint8_t IADStrIndex; /**< Index of the string descriptor describing the
600 * interface association.
601 */
602 } ATTR_PACKED USB_Descriptor_Interface_Association_t;
603
604 /** \brief Standard USB Interface Association Descriptor (USB-IF naming conventions).
605 *
606 * Type define for a standard Interface Association Descriptor. This structure uses the relevant standard's given
607 * element names to ensure compatibility with the standard.
608 *
609 * This descriptor has been added as a supplement to the USB2.0 standard, in the ECN located at
610 * <a>http://www.usb.org/developers/docs/InterfaceAssociationDescriptor_ecn.pdf</a>. It allows composite
611 * devices with multiple interfaces related to the same function to have the multiple interfaces bound
612 * together at the point of enumeration, loading one generic driver for all the interfaces in the single
613 * function. Read the ECN for more information.
614 *
615 * \see \ref USB_Descriptor_Interface_Association_t for the version of this type with non-standard LUFA specific
616 * element names.
617 *
618 * \note Regardless of CPU architecture, these values should be stored as little endian.
619 */
620 typedef struct
621 {
622 uint8_t bLength; /**< Size of the descriptor, in bytes. */
623 uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
624 * given by the specific class.
625 */
626 uint8_t bFirstInterface; /**< Index of the first associated interface. */
627 uint8_t bInterfaceCount; /**< Total number of associated interfaces. */
628 uint8_t bFunctionClass; /**< Interface class ID. */
629 uint8_t bFunctionSubClass; /**< Interface subclass ID. */
630 uint8_t bFunctionProtocol; /**< Interface protocol ID. */
631 uint8_t iFunction; /**< Index of the string descriptor describing the
632 * interface association.
633 */
634 } ATTR_PACKED USB_StdDescriptor_Interface_Association_t;
635
636 /** \brief Standard USB Endpoint Descriptor (LUFA naming conventions).
637 *
638 * Type define for a standard Endpoint Descriptor. This structure uses LUFA-specific element names
639 * to make each element's purpose clearer.
640 *
641 * \see \ref USB_StdDescriptor_Endpoint_t for the version of this type with standard element names.
642 *
643 * \note Regardless of CPU architecture, these values should be stored as little endian.
644 */
645 typedef struct
646 {
647 USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */
648
649 uint8_t EndpointAddress; /**< Logical address of the endpoint within the device for the current
650 * configuration, including direction mask.
651 */
652 uint8_t Attributes; /**< Endpoint attributes, comprised of a mask of the endpoint type (EP_TYPE_*)
653 * and attributes (ENDPOINT_ATTR_*) masks.
654 */
655 uint16_t EndpointSize; /**< Size of the endpoint bank, in bytes. This indicates the maximum packet
656 * size that the endpoint can receive at a time.
657 */
658 uint8_t PollingIntervalMS; /**< Polling interval in milliseconds for the endpoint if it is an INTERRUPT
659 * or ISOCHRONOUS type.
660 */
661 } ATTR_PACKED USB_Descriptor_Endpoint_t;
662
663 /** \brief Standard USB Endpoint Descriptor (USB-IF naming conventions).
664 *
665 * Type define for a standard Endpoint Descriptor. This structure uses the relevant standard's given
666 * element names to ensure compatibility with the standard.
667 *
668 * \see \ref USB_Descriptor_Endpoint_t for the version of this type with non-standard LUFA specific
669 * element names.
670 *
671 * \note Regardless of CPU architecture, these values should be stored as little endian.
672 */
673 typedef struct
674 {
675 uint8_t bLength; /**< Size of the descriptor, in bytes. */
676 uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a
677 * value given by the specific class.
678 */
679 uint8_t bEndpointAddress; /**< Logical address of the endpoint within the device for the current
680 * configuration, including direction mask.
681 */
682 uint8_t bmAttributes; /**< Endpoint attributes, comprised of a mask of the endpoint type (EP_TYPE_*)
683 * and attributes (ENDPOINT_ATTR_*) masks.
684 */
685 uint16_t wMaxPacketSize; /**< Size of the endpoint bank, in bytes. This indicates the maximum packet size
686 * that the endpoint can receive at a time.
687 */
688 uint8_t bInterval; /**< Polling interval in milliseconds for the endpoint if it is an INTERRUPT or
689 * ISOCHRONOUS type.
690 */
691 } ATTR_PACKED USB_StdDescriptor_Endpoint_t;
692
693 /** \brief Standard USB String Descriptor (LUFA naming conventions).
694 *
695 * Type define for a standard string descriptor. Unlike other standard descriptors, the length
696 * of the descriptor for placement in the descriptor header must be determined by the \ref USB_STRING_LEN()
697 * macro rather than by the size of the descriptor structure, as the length is not fixed.
698 *
699 * This structure should also be used for string index 0, which contains the supported language IDs for
700 * the device as an array.
701 *
702 * This structure uses LUFA-specific element names to make each element's purpose clearer.
703 *
704 * \see \ref USB_StdDescriptor_String_t for the version of this type with standard element names.
705 *
706 * \note Regardless of CPU architecture, these values should be stored as little endian.
707 */
708 typedef struct
709 {
710 USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */
711
712 #if (((ARCH == ARCH_AVR8) || (ARCH == ARCH_XMEGA)) && !defined(__DOXYGEN__))
713 wchar_t UnicodeString[];
714 #else
715 uint16_t UnicodeString[]; /**< String data, as unicode characters (alternatively,
716 * string language IDs). If normal ASCII characters are
717 * to be used, they must be added as an array of characters
718 * rather than a normal C string so that they are widened to
719 * Unicode size.
720 *
721 * Under GCC, strings prefixed with the "L" character (before
722 * the opening string quotation mark) are considered to be
723 * Unicode strings, and may be used instead of an explicit
724 * array of ASCII characters on little endian devices with
725 * UTF-16-LE \c wchar_t encoding.
726 */
727 #endif
728 } ATTR_PACKED USB_Descriptor_String_t;
729
730 /** \brief Standard USB String Descriptor (USB-IF naming conventions).
731 *
732 * Type define for a standard string descriptor. Unlike other standard descriptors, the length
733 * of the descriptor for placement in the descriptor header must be determined by the \ref USB_STRING_LEN()
734 * macro rather than by the size of the descriptor structure, as the length is not fixed.
735 *
736 * This structure should also be used for string index 0, which contains the supported language IDs for
737 * the device as an array.
738 *
739 * This structure uses the relevant standard's given element names to ensure compatibility with the standard.
740 *
741 * \see \ref USB_Descriptor_String_t for the version of this type with with non-standard LUFA specific
742 * element names.
743 *
744 * \note Regardless of CPU architecture, these values should be stored as little endian.
745 */
746 typedef struct
747 {
748 uint8_t bLength; /**< Size of the descriptor, in bytes. */
749 uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t
750 * or a value given by the specific class.
751 */
752 uint16_t bString[]; /**< String data, as unicode characters (alternatively, string language IDs).
753 * If normal ASCII characters are to be used, they must be added as an array
754 * of characters rather than a normal C string so that they are widened to
755 * Unicode size.
756 *
757 * Under GCC, strings prefixed with the "L" character (before the opening string
758 * quotation mark) are considered to be Unicode strings, and may be used instead
759 * of an explicit array of ASCII characters.
760 */
761 } ATTR_PACKED USB_StdDescriptor_String_t;
762
763
764 /* Disable C linkage for C++ Compilers: */
765 #if defined(__cplusplus)
766 }
767 #endif
768
769 #endif
770
771 /** @} */
772