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