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