3      Copyright (C) Dean Camera, 2010. 
   5   dean [at] fourwalledcubicle [dot] com 
   6       www.fourwalledcubicle.com 
  10   Copyright 2010  Dean Camera (dean [at] fourwalledcubicle [dot] com) 
  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. 
  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 
  31 /** \ingroup Group_USB 
  32  *  @defgroup Group_Descriptors USB Descriptors 
  34  *  Standard USB device descriptor defines and retrieval routines, for USB devices. This module contains 
  35  *  structures and macros for the easy creation of standard USB descriptors in USB device projects. 
  40 #ifndef __USBDESCRIPTORS_H__ 
  41 #define __USBDESCRIPTORS_H__ 
  44                 #include <avr/pgmspace.h> 
  48                 #include "../../../Common/Common.h" 
  52                 #if defined(USB_CAN_BE_DEVICE) 
  53                         #include "../LowLevel/Device.h" 
  56         /* Enable C linkage for C++ Compilers: */ 
  57                 #if defined(__cplusplus) 
  61         /* Preprocessor Checks: */ 
  62                 #if !defined(__INCLUDE_FROM_USB_DRIVER) 
  63                         #error Do not include this file directly. Include LUFA/Drivers/USB.h instead. 
  66         /* Public Interface - May be used in end-application: */ 
  68                         /** Indicates that a given descriptor does not exist in the device. This can be used inside descriptors 
  69                          *  for string descriptor indexes, or may be use as a return value for GetDescriptor when the specified 
  70                          *  descriptor does not exist. 
  72                         #define NO_DESCRIPTOR                     0 
  74                         #if (!defined(NO_INTERNAL_SERIAL) && (defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR))) || defined(__DOXYGEN__) 
  75                                 /** String descriptor index for the device's unique serial number string descriptor within the device. 
  76                                  *  This unique serial number is used by the host to associate resources to the device (such as drivers or COM port 
  77                                  *  number allocations) to a device regardless of the port it is plugged in to on the host. Some USB AVRs contain 
  78                                  *  a unique serial number internally, and setting the device descriptors serial number string index to this value 
  79                                  *  will cause it to use the internal serial number. 
  81                                  *  On unsupported devices, this will evaluate to NO_DESCRIPTOR and so will force the host to create a pseudo-serial 
  82                                  *  number for the device. 
  84                                 #define USE_INTERNAL_SERIAL           0xDC 
  86                                 #define USE_INTERNAL_SERIAL           NO_DESCRIPTOR 
  89                         /** Macro to calculate the power value for the device descriptor, from a given number of milliamps. */ 
  90                         #define USB_CONFIG_POWER_MA(mA)           ((mA) >> 1) 
  92                         /** Macro to calculate the Unicode length of a string with a given number of Unicode characters. 
  93                          *  Should be used in string descriptor's headers for giving the string descriptor's byte length. 
  95                         #define USB_STRING_LEN(str)               (sizeof(USB_Descriptor_Header_t) + ((str) << 1)) 
  97                         /** Macro to encode a given four digit floating point version number (e.g. 01.23) into Binary Coded 
  98                          *  Decimal format for descriptor fields requiring BCD encoding, such as the USB version number in the 
  99                          *  standard device descriptor. 
 101                         #define VERSION_BCD(x)                    ((((VERSION_TENS(x) << 4) | VERSION_ONES(x)) << 8) | \ 
 102                                                                   ((VERSION_TENTHS(x) << 4) | VERSION_HUNDREDTHS(x))) 
 104                         /** String language ID for the English language. Should be used in \ref USB_Descriptor_String_t descriptors 
 105                          *  to indicate that the English language is supported by the device in its string descriptors. 
 107                         #define LANGUAGE_ID_ENG                   0x0409 
 109                         /** Can be masked with an endpoint address for a \ref USB_Descriptor_Endpoint_t endpoint descriptor's 
 110                          *  EndpointAddress value to indicate to the host that the endpoint is of the IN direction (i.e, from 
 113                         #define ENDPOINT_DESCRIPTOR_DIR_IN        0x80 
 115                         /** Can be masked with an endpoint address for a \ref USB_Descriptor_Endpoint_t endpoint descriptor's 
 116                          *  EndpointAddress value to indicate to the host that the endpoint is of the OUT direction (i.e, from 
 119                         #define ENDPOINT_DESCRIPTOR_DIR_OUT       0x00           
 121                         /** Can be masked with other configuration descriptor attributes for a \ref USB_Descriptor_Configuration_Header_t 
 122                          *  descriptor's ConfigAttributes value to indicate that the specified configuration can draw its power 
 123                          *  from the host's VBUS line. 
 125                         #define USB_CONFIG_ATTR_BUSPOWERED        0x80 
 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 can draw its power 
 130                          *  from the device's own power source. 
 132                         #define USB_CONFIG_ATTR_SELFPOWERED       0x40 
 134                         /** Can be masked with other configuration descriptor attributes for a \ref USB_Descriptor_Configuration_Header_t 
 135                          *  descriptor's ConfigAttributes value to indicate that the specified configuration supports the 
 136                          *  remote wakeup feature of the USB standard, allowing a suspended USB device to wake up the host upon 
 139                         #define USB_CONFIG_ATTR_REMOTEWAKEUP      0x20 
 141                         /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's 
 142                          *  Attributes value to indicate that the specified endpoint is not synchronized. 
 144                          *  \see The USB specification for more details on the possible Endpoint attributes. 
 146                         #define ENDPOINT_ATTR_NO_SYNC             (0 << 2) 
 148                         /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's 
 149                          *  Attributes value to indicate that the specified endpoint is asynchronous. 
 151                          *  \see The USB specification for more details on the possible Endpoint attributes. 
 153                         #define ENDPOINT_ATTR_ASYNC               (1 << 2) 
 155                         /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's 
 156                          *  Attributes value to indicate that the specified endpoint is adaptive. 
 158                          *  \see The USB specification for more details on the possible Endpoint attributes. 
 160                         #define ENDPOINT_ATTR_ADAPTIVE            (2 << 2) 
 162                         /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's 
 163                          *  Attributes value to indicate that the specified endpoint is synchronized. 
 165                          *  \see The USB specification for more details on the possible Endpoint attributes. 
 167                         #define ENDPOINT_ATTR_SYNC                (3 << 2) 
 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. 
 172                          *  \see The USB specification for more details on the possible Endpoint usage attributes. 
 174                         #define ENDPOINT_USAGE_DATA               (0 << 4) 
 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. 
 179                          *  \see The USB specification for more details on the possible Endpoint usage attributes. 
 181                         #define ENDPOINT_USAGE_FEEDBACK           (1 << 4) 
 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. 
 186                          *  \see The USB specification for more details on the possible Endpoint usage attributes. 
 188                         #define ENDPOINT_USAGE_IMPLICIT_FEEDBACK  (2 << 4) 
 191                         /** Enum for the possible standard descriptor types, as given in each descriptor's header. */ 
 192                         enum USB_DescriptorTypes_t
 
 194                                 DTYPE_Device               
= 0x01, /**< Indicates that the descriptor is a device descriptor. */ 
 195                                 DTYPE_Configuration        
= 0x02, /**< Indicates that the descriptor is a configuration descriptor. */ 
 196                                 DTYPE_String               
= 0x03, /**< Indicates that the descriptor is a string descriptor. */ 
 197                                 DTYPE_Interface            
= 0x04, /**< Indicates that the descriptor is an interface descriptor. */ 
 198                                 DTYPE_Endpoint             
= 0x05, /**< Indicates that the descriptor is an endpoint descriptor. */ 
 199                                 DTYPE_DeviceQualifier      
= 0x06, /**< Indicates that the descriptor is a device qualifier descriptor. */ 
 200                                 DTYPE_Other                
= 0x07, /**< Indicates that the descriptor is of other type. */ 
 201                                 DTYPE_InterfacePower       
= 0x08, /**< Indicates that the descriptor is an interface power descriptor. */ 
 202                                 DTYPE_InterfaceAssociation 
= 0x0B, /**< Indicates that the descriptor is an interface association descriptor. */ 
 206                         /** Type define for all descriptors standard header, indicating the descriptor's length and type. This structure 
 207                          *  uses LUFA-specific element names to make each element's purpose clearer. 
 209                          *  \see \ref USB_StdDescriptor_Header_t for the version of this define with standard element names 
 213                                 uint8_t     Size
; /**< Size of the descriptor, in bytes. */ 
 214                                 uint8_t     Type
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value 
 215                                                    *   given by the specific class. 
 217                         } USB_Descriptor_Header_t
; 
 219                         /** Type define for all descriptors standard header, indicating the descriptor's length and type. This structure 
 220                          *  uses the relevant standard's given element names to ensure compatibility with the standard. 
 222                          *  \see \ref USB_Descriptor_Header_t for the version of this define with non-standard LUFA specific element names 
 226                                 uint8_t     bLength
; /**< Size of the descriptor, in bytes. */ 
 227                                 uint8_t     bDescriptorType
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value 
 228                                                               *   given by the specific class. 
 230                         } USB_StdDescriptor_Header_t
; 
 232                         /** Type define for a standard Device Descriptor. This structure uses LUFA-specific element names to make each 
 233                          *  element's purpose clearer. 
 235                          *  \see \ref USB_StdDescriptor_Device_t for the version of this define with standard element names 
 239                                 USB_Descriptor_Header_t Header
; /**< Descriptor header, including type and size. */ 
 241                                 uint16_t    USBSpecification
; /**< BCD of the supported USB specification. */ 
 242                                 uint8_t     Class
; /**< USB device class. */ 
 243                                 uint8_t     SubClass
; /**< USB device subclass. */ 
 244                                 uint8_t     Protocol
; /**< USB device protocol. */ 
 246                                 uint8_t     Endpoint0Size
; /**< Size of the control (address 0) endpoint's bank in bytes. */ 
 248                                 uint16_t    VendorID
; /**< Vendor ID for the USB product. */ 
 249                                 uint16_t    ProductID
; /**< Unique product ID for the USB product. */ 
 250                                 uint16_t    ReleaseNumber
; /**< Product release (version) number. */ 
 252                                 uint8_t     ManufacturerStrIndex
; /**< String index for the manufacturer's name. The 
 253                                                                    *   host will request this string via a separate 
 254                                                                    *   control request for the string descriptor. 
 256                                                                    *   \note If no string supplied, use \ref NO_DESCRIPTOR. 
 258                                 uint8_t     ProductStrIndex
; /**< String index for the product name/details. 
 260                                                               *  \see ManufacturerStrIndex structure entry. 
 262                                 uint8_t     SerialNumStrIndex
; /**< String index for the product's globally unique hexadecimal 
 263                                                                 *   serial number, in uppercase Unicode ASCII. 
 265                                                                 *  \note On some AVR models, there is an embedded serial number 
 266                                                                 *        in the chip which can be used for the device serial number. 
 267                                                                 *        To use this serial number, set this to USE_INTERNAL_SERIAL. 
 268                                                                 *        On unsupported devices, this will evaluate to 0 and will cause 
 269                                                                 *        the host to generate a pseudo-unique value for the device upon 
 272                                                                 *  \see ManufacturerStrIndex structure entry. 
 274                                 uint8_t     NumberOfConfigurations
; /**< Total number of configurations supported by 
 277                         } USB_Descriptor_Device_t
; 
 279                         /** Type define for a standard Device Descriptor. This structure uses the relevant standard's given element names 
 280                          *  to ensure compatibility with the standard. 
 282                          *  \see \ref USB_Descriptor_Device_t for the version of this define with non-standard LUFA specific element names 
 286                                 uint8_t     bLength
; /**< Size of the descriptor, in bytes. */ 
 287                                 uint8_t     bDescriptorType
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value 
 288                                                               *   given by the specific class. 
 290                                 uint16_t    bcdUSB
; /**< BCD of the supported USB specification. */ 
 291                                 uint8_t     bDeviceClass
; /**< USB device class. */ 
 292                                 uint8_t     bDeviceSubClass
; /**< USB device subclass. */ 
 293                                 uint8_t     bDeviceProtocol
; /**< USB device protocol. */ 
 294                                 uint8_t     bMaxPacketSize0
; /**< Size of the control (address 0) endpoint's bank in bytes. */ 
 295                                 uint16_t    idVendor
; /**< Vendor ID for the USB product. */ 
 296                                 uint16_t    idProduct
; /**< Unique product ID for the USB product. */ 
 297                                 uint16_t    bcdDevice
; /**< Product release (version) number. */ 
 298                                 uint8_t     iManufacturer
; /**< String index for the manufacturer's name. The 
 299                                                             *   host will request this string via a separate 
 300                                                             *   control request for the string descriptor. 
 302                                                             *   \note If no string supplied, use \ref NO_DESCRIPTOR. 
 304                                 uint8_t     iProduct
; /**< String index for the product name/details. 
 306                                                        *  \see ManufacturerStrIndex structure entry. 
 308                                 uint8_t     iSerialNumber
; /**< String index for the product's globally unique hexadecimal 
 309                                                             *   serial number, in uppercase Unicode ASCII. 
 311                                                             *  \note On some AVR models, there is an embedded serial number 
 312                                                             *        in the chip which can be used for the device serial number. 
 313                                                             *        To use this serial number, set this to USE_INTERNAL_SERIAL. 
 314                                                             *        On unsupported devices, this will evaluate to 0 and will cause 
 315                                                             *        the host to generate a pseudo-unique value for the device upon 
 318                                                             *  \see ManufacturerStrIndex structure entry. 
 320                                 uint8_t     bNumConfigurations
; /**< Total number of configurations supported by 
 323                         } USB_StdDescriptor_Device_t
; 
 325                         /** Type define for a standard Configuration Descriptor header. This structure uses LUFA-specific element names 
 326                          *  to make each element's purpose clearer. 
 328                          *  \see \ref USB_StdDescriptor_Configuration_Header_t for the version of this define with standard element names 
 332                                 USB_Descriptor_Header_t Header
; /**< Descriptor header, including type and size. */ 
 334                                 uint16_t    TotalConfigurationSize
; /**< Size of the configuration descriptor header, 
 335                                                                      *   and all sub descriptors inside the configuration. 
 337                                 uint8_t     TotalInterfaces
; /**< Total number of interfaces in the configuration. */ 
 339                                 uint8_t     ConfigurationNumber
; /**< Configuration index of the current configuration. */ 
 340                                 uint8_t     ConfigurationStrIndex
; /**< Index of a string descriptor describing the configuration. */ 
 342                                 uint8_t     ConfigAttributes
; /**< Configuration attributes, comprised of a mask of zero or 
 343                                                                *   more USB_CONFIG_ATTR_* masks. 
 346                                 uint8_t     MaxPowerConsumption
; /**< Maximum power consumption of the device while in the 
 347                                                                   *   current configuration, calculated by the \ref USB_CONFIG_POWER_MA() 
 350                         } USB_Descriptor_Configuration_Header_t
; 
 352                         /** Type define for a standard Configuration Descriptor header. This structure uses the relevant standard's given element names 
 353                          *  to ensure compatibility with the standard. 
 355                          *  \see \ref USB_Descriptor_Device_t for the version of this define with non-standard LUFA specific element names 
 359                                 uint8_t     bLength
; /**< Size of the descriptor, in bytes. */ 
 360                                 uint8_t     bDescriptorType
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value 
 361                                                               *   given by the specific class. 
 363                                 uint16_t    wTotalLength
; /**< Size of the configuration descriptor header, 
 364                                                            *   and all sub descriptors inside the configuration. 
 366                                 uint8_t     bNumInterfaces
; /**< Total number of interfaces in the configuration. */ 
 367                                 uint8_t     bConfigurationValue
; /**< Configuration index of the current configuration. */ 
 368                                 uint8_t     iConfiguration
; /**< Index of a string descriptor describing the configuration. */ 
 369                                 uint8_t     bmAttributes
; /**< Configuration attributes, comprised of a mask of zero or 
 370                                                            *   more USB_CONFIG_ATTR_* masks. 
 372                                 uint8_t     bMaxPower
; /**< Maximum power consumption of the device while in the 
 373                                                         *   current configuration, calculated by the \ref USB_CONFIG_POWER_MA() 
 376                         } USB_StdDescriptor_Configuration_Header_t
; 
 378                         /** Type define for a standard Interface Descriptor. This structure uses LUFA-specific element names 
 379                          *  to make each element's purpose clearer. 
 381                          *  \see \ref USB_StdDescriptor_Interface_t for the version of this define with standard element names 
 385                                 USB_Descriptor_Header_t Header
; /**< Descriptor header, including type and size. */ 
 387                                 uint8_t     InterfaceNumber
; /**< Index of the interface in the current configuration. */ 
 388                                 uint8_t     AlternateSetting
; /**< Alternate setting for the interface number. The same 
 389                                                                *   interface number can have multiple alternate settings 
 390                                                                *   with different endpoint configurations, which can be 
 391                                                                *   selected by the host. 
 393                                 uint8_t     TotalEndpoints
; /**< Total number of endpoints in the interface. */ 
 395                                 uint8_t     Class
; /**< Interface class ID. */ 
 396                                 uint8_t     SubClass
; /**< Interface subclass ID. */ 
 397                                 uint8_t     Protocol
; /**< Interface protocol ID. */ 
 399                                 uint8_t     InterfaceStrIndex
; /**< Index of the string descriptor describing the 
 402                         } USB_Descriptor_Interface_t
; 
 404                         /** Type define for a standard Interface Descriptor. This structure uses the relevant standard's given element names 
 405                          *  to ensure compatibility with the standard. 
 407                          *  \see \ref USB_Descriptor_Interface_t for the version of this define with non-standard LUFA specific element names 
 411                                 uint8_t     bLength
; /**< Size of the descriptor, in bytes. */ 
 412                                 uint8_t     bDescriptorType
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value 
 413                                                               *   given by the specific class. 
 415                                 uint8_t     bInterfaceNumber
; /**< Index of the interface in the current configuration. */ 
 416                                 uint8_t     bAlternateSetting
; /**< Alternate setting for the interface number. The same 
 417                                                                 *   interface number can have multiple alternate settings 
 418                                                                 *   with different endpoint configurations, which can be 
 419                                                                 *   selected by the host. 
 421                                 uint8_t     bNumEndpoints
; /**< Total number of endpoints in the interface. */ 
 422                                 uint8_t     bInterfaceClass
; /**< Interface class ID. */ 
 423                                 uint8_t     bInterfaceSubClass
; /**< Interface subclass ID. */ 
 424                                 uint8_t     bInterfaceProtocol
; /**< Interface protocol ID. */ 
 425                                 uint8_t     iInterface
; /**< Index of the string descriptor describing the 
 428                         } USB_StdDescriptor_Interface_t
; 
 430                         /** Type define for a standard Interface Association Descriptor. This structure uses LUFA-specific element names 
 431                          *  to make each element's purpose clearer. 
 433                          *  This descriptor has been added as a supplement to the USB2.0 standard, in the ECN located at 
 434                          *  <a>http://www.usb.org/developers/docs/InterfaceAssociationDescriptor_ecn.pdf</a>. It allows compound 
 435                          *  devices with multiple interfaces related to the same function to have the multiple interfaces bound 
 436                          *  together at the point of enumeration, loading one generic driver for all the interfaces in the single 
 437                          *  function. Read the ECN for more information. 
 439                          *  \see \ref USB_StdDescriptor_Interface_Association_t for the version of this define with standard element names 
 443                                 USB_Descriptor_Header_t Header
; /**< Descriptor header, including type and size. */ 
 445                                 uint8_t     FirstInterfaceIndex
; /**< Index of the first associated interface. */ 
 446                                 uint8_t     TotalInterfaces
; /** Total number of associated interfaces. */ 
 448                                 uint8_t     Class
; /**< Interface class ID. */ 
 449                                 uint8_t     SubClass
; /**< Interface subclass ID. */ 
 450                                 uint8_t     Protocol
; /**< Interface protocol ID. */ 
 452                                 uint8_t     IADStrIndex
; /**< Index of the string descriptor describing the 
 453                                                           *   interface association. 
 455                         } USB_Descriptor_Interface_Association_t
; 
 457                         /** Type define for a standard Interface Association Descriptor. This structure uses the relevant standard's given 
 458                          *  element names to ensure compatibility with the standard. 
 460                          *  This descriptor has been added as a supplement to the USB2.0 standard, in the ECN located at 
 461                          *  <a>http://www.usb.org/developers/docs/InterfaceAssociationDescriptor_ecn.pdf</a>. It allows compound 
 462                          *  devices with multiple interfaces related to the same function to have the multiple interfaces bound 
 463                          *  together at the point of enumeration, loading one generic driver for all the interfaces in the single 
 464                          *  function. Read the ECN for more information. 
 466                          *  \see \ref USB_Descriptor_Interface_Association_t for the version of this define with non-standard LUFA specific 
 471                                 uint8_t     bLength
; /**< Size of the descriptor, in bytes. */ 
 472                                 uint8_t     bDescriptorType
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value 
 473                                                               *   given by the specific class. 
 475                                 uint8_t     bFirstInterface
; /**< Index of the first associated interface. */ 
 476                                 uint8_t     bInterfaceCount
; /** Total number of associated interfaces. */ 
 477                                 uint8_t     bFunctionClass
; /**< Interface class ID. */ 
 478                                 uint8_t     bFunctionSubClass
; /**< Interface subclass ID. */ 
 479                                 uint8_t     bFunctionProtocol
; /**< Interface protocol ID. */ 
 480                                 uint8_t     iFunction
; /**< Index of the string descriptor describing the 
 481                                                         *   interface association. 
 483                         } USB_StdDescriptor_Interface_Association_t
; 
 485                         /** Type define for a standard Endpoint Descriptor. This structure uses LUFA-specific element names 
 486                          *  to make each element's purpose clearer. 
 488                          *  \see \ref USB_StdDescriptor_Endpoint_t for the version of this define with standard element names 
 492                                 USB_Descriptor_Header_t Header
; /**< Descriptor header, including type and size. */ 
 494                                 uint8_t     EndpointAddress
; /**< Logical address of the endpoint within the device 
 495                                                               *   for the current configuration, including direction 
 498                                 uint8_t     Attributes
; /**< Endpoint attributes, comprised of a mask of the 
 499                                                          *   endpoint type (EP_TYPE_*) and attributes (ENDPOINT_ATTR_*) 
 502                                 uint16_t    EndpointSize
; /**< Size of the endpoint bank, in bytes. This indicates the 
 503                                                            *   maximum packet size that the endpoint can receive at a time. 
 506                                 uint8_t     PollingIntervalMS
; /**< Polling interval in milliseconds for the endpoint 
 507                                                                 *   if it is an INTERRUPT or ISOCHRONOUS type. 
 509                         } USB_Descriptor_Endpoint_t
; 
 511                         /** Type define for a standard Endpoint Descriptor. This structure uses the relevant standard's given 
 512                          *  element names to ensure compatibility with the standard. 
 514                          *  \see \ref USB_Descriptor_Endpoint_t for the version of this define with non-standard LUFA specific 
 519                                 uint8_t     bLength
; /**< Size of the descriptor, in bytes. */ 
 520                                 uint8_t     bDescriptorType
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value 
 521                                                               *   given by the specific class. 
 523                                 uint8_t     bEndpointAddress
; /**< Logical address of the endpoint within the device 
 524                                                                *   for the current configuration, including direction 
 527                                 uint8_t     bmAttributes
; /**< Endpoint attributes, comprised of a mask of the 
 528                                                            *   endpoint type (EP_TYPE_*) and attributes (ENDPOINT_ATTR_*) 
 531                                 uint16_t    wMaxPacketSize
; /**< Size of the endpoint bank, in bytes. This indicates the 
 532                                                              *   maximum packet size that the endpoint can receive at a time. 
 534                                 uint8_t     bInterval
; /**< Polling interval in milliseconds for the endpoint 
 535                                                         *   if it is an INTERRUPT or ISOCHRONOUS type. 
 537                         } USB_StdDescriptor_Endpoint_t
; 
 539                         /** Type define for a standard string descriptor. Unlike other standard descriptors, the length 
 540                          *  of the descriptor for placement in the descriptor header must be determined by the \ref USB_STRING_LEN() 
 541                          *  macro rather than by the size of the descriptor structure, as the length is not fixed. 
 543                          *  This structure should also be used for string index 0, which contains the supported language IDs for 
 544                          *  the device as an array. 
 546                          *  This structure uses LUFA-specific element names to make each element's purpose clearer. 
 548                          *  \see \ref USB_StdDescriptor_String_t for the version of this define with standard element names 
 552                                 USB_Descriptor_Header_t Header
; /**< Descriptor header, including type and size. */ 
 554                                 wchar_t UnicodeString
[];  /**< String data, as unicode characters (alternatively, 
 555                                                            *   string language IDs). If normal ASCII characters are 
 556                                                            *   to be used, they must be added as an array of characters 
 557                                                            *   rather than a normal C string so that they are widened to 
 560                                                            *   Under GCC, strings prefixed with the "L" character (before 
 561                                                            *   the opening string quotation mark) are considered to be 
 562                                                            *   Unicode strings, and may be used instead of an explicit 
 563                                                            *   array of ASCII characters. 
 565                         } USB_Descriptor_String_t
; 
 567                         /** Type define for a standard string descriptor. Unlike other standard descriptors, the length 
 568                          *  of the descriptor for placement in the descriptor header must be determined by the \ref USB_STRING_LEN() 
 569                          *  macro rather than by the size of the descriptor structure, as the length is not fixed. 
 571                          *  This structure should also be used for string index 0, which contains the supported language IDs for 
 572                          *  the device as an array. 
 574                          *  This structure uses the relevant standard's given element names to ensure compatibility with the standard. 
 576                          *  \see \ref USB_Descriptor_String_t for the version of this define with with non-standard LUFA specific 
 581                                         uint8_t                 bLength
; /**< Size of the descriptor, in bytes. */ 
 582                                         uint8_t                 bDescriptorType
; /**< Type of the descriptor, either a value in 
 583                                                                                   *   \ref USB_DescriptorTypes_t or a value 
 584                                                                               *   given by the specific class. 
 586                                         int16_t                 bString
[]; /**< String data, as unicode characters (alternatively, 
 587                                                                         *   string language IDs). If normal ASCII characters are 
 588                                                                         *   to be used, they must be added as an array of characters 
 589                                                                         *   rather than a normal C string so that they are widened to 
 592                                                                         *   Under GCC, strings prefixed with the "L" character (before 
 593                                                                         *   the opening string quotation mark) are considered to be 
 594                                                                         *   Unicode strings, and may be used instead of an explicit 
 595                                                                         *   array of ASCII characters. 
 597                         } USB_StdDescriptor_String_t
; 
 599         /* Private Interface - For use in library only: */ 
 600         #if !defined(__DOXYGEN__) 
 602                         #define VERSION_TENS(x)                   (int)((x) / 10) 
 603                         #define VERSION_ONES(x)                   (int)((x) - (10 * VERSION_TENS(x))) 
 604                         #define VERSION_TENTHS(x)                 (int)(((x) - (int)(x)) * 10) 
 605                         #define VERSION_HUNDREDTHS(x)             (int)((((x) - (int)(x)) * 100) - (10 * VERSION_TENTHS(x))) 
 608         /* Disable C linkage for C++ Compilers: */ 
 609                 #if defined(__cplusplus)