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