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