3      Copyright (C) Dean Camera, 2013. 
   5   dean [at] fourwalledcubicle [dot] com 
  10   Copyright 2013  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 disclaims all warranties with regard to this 
  22   software, including all implied warranties of merchantability 
  23   and fitness.  In no event shall the author be liable for any 
  24   special, indirect or consequential damages or any damages 
  25   whatsoever resulting from loss of use, data or profits, whether 
  26   in an action of contract, negligence or other tortious action, 
  27   arising out of or in connection with the use or performance of 
  32  *  \brief Common standard USB Descriptor definitions for all architectures. 
  33  *  \copydetails Group_StdDescriptors 
  35  *  \note This file should not be included directly. It is automatically included as needed by the USB driver 
  36  *        dispatch header located in LUFA/Drivers/USB/USB.h. 
  39 /** \ingroup Group_USB 
  40  *  \defgroup Group_StdDescriptors USB Descriptors 
  41  *  \brief Standard USB Descriptor definitions. 
  43  *  Standard USB device descriptor defines and retrieval routines, for USB devices. This module contains 
  44  *  structures and macros for the easy creation of standard USB descriptors in USB device projects. 
  49 #ifndef __USBDESCRIPTORS_H__ 
  50 #define __USBDESCRIPTORS_H__ 
  53                 #include "../../../Common/Common.h" 
  57         /* Enable C linkage for C++ Compilers: */ 
  58                 #if defined(__cplusplus) 
  62         /* Preprocessor Checks: */ 
  63                 #if !defined(__INCLUDE_FROM_USB_DRIVER) 
  64                         #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. 
  67         /* Public Interface - May be used in end-application: */ 
  69                         /** Indicates that a given descriptor does not exist in the device. This can be used inside descriptors 
  70                          *  for string descriptor indexes, or may be use as a return value for GetDescriptor when the specified 
  71                          *  descriptor does not exist. 
  73                         #define NO_DESCRIPTOR                     0 
  75                         /** Macro to calculate the power value for the configuration descriptor, from a given number of milliamperes. 
  77                          *  \param[in] mA  Maximum number of milliamps the device consumes when the given configuration is selected. 
  79                         #define USB_CONFIG_POWER_MA(mA)           ((mA) >> 1) 
  81                         /** Macro to calculate the Unicode length of a string with a given number of Unicode characters. 
  82                          *  Should be used in string descriptor's headers for giving the string descriptor's byte length. 
  84                          *  \param[in] UnicodeChars  Number of Unicode characters in the string text. 
  86                         #define USB_STRING_LEN(UnicodeChars)      (sizeof(USB_Descriptor_Header_t) + ((UnicodeChars) << 1)) 
  88                         /** Macro to encode a given four digit floating point version number (e.g. 01.23) into Binary Coded 
  89                          *  Decimal format for descriptor fields requiring BCD encoding, such as the USB version number in the 
  90                          *  standard device descriptor. 
  92                          *  \note This value is automatically converted into Little Endian, suitable for direct use inside device 
  93                          *        descriptors on all architectures without endianness conversion macros. 
  95                          *  \param[in]  x  Version number to encode as a 16-bit little-endian number, as a floating point number. 
  97                         #define VERSION_BCD(x)                    CPU_TO_LE16((VERSION_TENS(x) << 12)  | (VERSION_ONES(x) << 8) | \ 
  98                                                                               (VERSION_TENTHS(x) << 4) | (VERSION_HUNDREDTHS(x) << 0) ) 
 100                         /** String language ID for the English language. Should be used in \ref USB_Descriptor_String_t descriptors 
 101                          *  to indicate that the English language is supported by the device in its string descriptors. 
 103                         #define LANGUAGE_ID_ENG                   0x0409 
 105                         /** \name USB Configuration Descriptor Attribute Masks */ 
 107                         /** Mask for the reserved bit in the Configuration Descriptor's \c ConfigAttributes field, which must be set on all 
 108                          *  devices for historical purposes. 
 110                         #define USB_CONFIG_ATTR_RESERVED          0x80 
 112                         /** Can be masked with other configuration descriptor attributes for a \ref USB_Descriptor_Configuration_Header_t 
 113                          *  descriptor's \c ConfigAttributes value to indicate that the specified configuration can draw its power 
 114                          *  from the device's own power source. 
 116                         #define USB_CONFIG_ATTR_SELFPOWERED       0x40 
 118                         /** Can be masked with other configuration descriptor attributes for a \ref USB_Descriptor_Configuration_Header_t 
 119                          *  descriptor's \c ConfigAttributes value to indicate that the specified configuration supports the 
 120                          *  remote wakeup feature of the USB standard, allowing a suspended USB device to wake up the host upon 
 123                         #define USB_CONFIG_ATTR_REMOTEWAKEUP      0x20 
 126                         /** \name Endpoint Descriptor Attribute Masks */ 
 128                         /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's 
 129                          *  \c Attributes value to indicate that the specified endpoint is not synchronized. 
 131                          *  \see The USB specification for more details on the possible Endpoint attributes. 
 133                         #define ENDPOINT_ATTR_NO_SYNC             (0 << 2) 
 135                         /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's 
 136                          *  \c Attributes value to indicate that the specified endpoint is asynchronous. 
 138                          *  \see The USB specification for more details on the possible Endpoint attributes. 
 140                         #define ENDPOINT_ATTR_ASYNC               (1 << 2) 
 142                         /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's 
 143                          *  \c Attributes value to indicate that the specified endpoint is adaptive. 
 145                          *  \see The USB specification for more details on the possible Endpoint attributes. 
 147                         #define ENDPOINT_ATTR_ADAPTIVE            (2 << 2) 
 149                         /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's 
 150                          *  \c Attributes value to indicate that the specified endpoint is synchronized. 
 152                          *  \see The USB specification for more details on the possible Endpoint attributes. 
 154                         #define ENDPOINT_ATTR_SYNC                (3 << 2) 
 157                         /** \name Endpoint Descriptor Usage Masks */ 
 159                         /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's 
 160                          *  \c Attributes value to indicate that the specified endpoint is used for data transfers. 
 162                          *  \see The USB specification for more details on the possible Endpoint usage attributes. 
 164                         #define ENDPOINT_USAGE_DATA               (0 << 4) 
 166                         /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's 
 167                          *  \c Attributes value to indicate that the specified endpoint is used for feedback. 
 169                          *  \see The USB specification for more details on the possible Endpoint usage attributes. 
 171                         #define ENDPOINT_USAGE_FEEDBACK           (1 << 4) 
 173                         /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's 
 174                          *  \c Attributes value to indicate that the specified endpoint is used for implicit feedback. 
 176                          *  \see The USB specification for more details on the possible Endpoint usage attributes. 
 178                         #define ENDPOINT_USAGE_IMPLICIT_FEEDBACK  (2 << 4) 
 182                         /** Enum for the possible standard descriptor types, as given in each descriptor's header. */ 
 183                         enum USB_DescriptorTypes_t
 
 185                                 DTYPE_Device                    
= 0x01, /**< Indicates that the descriptor is a device descriptor. */ 
 186                                 DTYPE_Configuration             
= 0x02, /**< Indicates that the descriptor is a configuration descriptor. */ 
 187                                 DTYPE_String                    
= 0x03, /**< Indicates that the descriptor is a string descriptor. */ 
 188                                 DTYPE_Interface                 
= 0x04, /**< Indicates that the descriptor is an interface descriptor. */ 
 189                                 DTYPE_Endpoint                  
= 0x05, /**< Indicates that the descriptor is an endpoint descriptor. */ 
 190                                 DTYPE_DeviceQualifier           
= 0x06, /**< Indicates that the descriptor is a device qualifier descriptor. */ 
 191                                 DTYPE_Other                     
= 0x07, /**< Indicates that the descriptor is of other type. */ 
 192                                 DTYPE_InterfacePower            
= 0x08, /**< Indicates that the descriptor is an interface power descriptor. */ 
 193                                 DTYPE_InterfaceAssociation      
= 0x0B, /**< Indicates that the descriptor is an interface association descriptor. */ 
 194                                 DTYPE_CSInterface               
= 0x24, /**< Indicates that the descriptor is a class specific interface descriptor. */ 
 195                                 DTYPE_CSEndpoint                
= 0x25, /**< Indicates that the descriptor is a class specific endpoint descriptor. */ 
 198                         /** Enum for possible Class, Subclass and Protocol values of device and interface descriptors. */ 
 199                         enum USB_Descriptor_ClassSubclassProtocol_t
 
 201                                 USB_CSCP_NoDeviceClass          
= 0x00, /**< Descriptor Class value indicating that the device does not belong 
 202                                                                          *   to a particular class at the device level. 
 204                                 USB_CSCP_NoDeviceSubclass       
= 0x00, /**< Descriptor Subclass value indicating that the device does not belong 
 205                                                                          *   to a particular subclass at the device level. 
 207                                 USB_CSCP_NoDeviceProtocol       
= 0x00, /**< Descriptor Protocol value indicating that the device does not belong 
 208                                                                          *   to a particular protocol at the device level. 
 210                                 USB_CSCP_VendorSpecificClass    
= 0xFF, /**< Descriptor Class value indicating that the device/interface belongs 
 211                                                                          *   to a vendor specific class. 
 213                                 USB_CSCP_VendorSpecificSubclass 
= 0xFF, /**< Descriptor Subclass value indicating that the device/interface belongs 
 214                                                                          *   to a vendor specific subclass. 
 216                                 USB_CSCP_VendorSpecificProtocol 
= 0xFF, /**< Descriptor Protocol value indicating that the device/interface belongs 
 217                                                                          *   to a vendor specific protocol. 
 219                                 USB_CSCP_IADDeviceClass         
= 0xEF, /**< Descriptor Class value indicating that the device belongs to the 
 220                                                                          *   Interface Association Descriptor class. 
 222                                 USB_CSCP_IADDeviceSubclass      
= 0x02, /**< Descriptor Subclass value indicating that the device belongs to the 
 223                                                                          *   Interface Association Descriptor subclass. 
 225                                 USB_CSCP_IADDeviceProtocol      
= 0x01, /**< Descriptor Protocol value indicating that the device belongs to the 
 226                                                                          *   Interface Association Descriptor protocol. 
 231                         /** \brief Standard USB Descriptor Header (LUFA naming conventions). 
 233              *  Type define for all descriptors' standard header, indicating the descriptor's length and type. This structure 
 234                          *  uses LUFA-specific element names to make each element's purpose clearer. 
 236                          *  \see \ref USB_StdDescriptor_Header_t for the version of this type with standard element names. 
 238                          *  \note Regardless of CPU architecture, these values should be stored as little endian. 
 242                                 uint8_t Size
; /**< Size of the descriptor, in bytes. */ 
 243                                 uint8_t Type
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value 
 244                                                *   given by the specific class. 
 246                         } ATTR_PACKED USB_Descriptor_Header_t
; 
 248                         /** \brief Standard USB Descriptor Header (USB-IF naming conventions). 
 250                          *  Type define for all descriptors' standard header, indicating the descriptor's length and type. This structure 
 251                          *  uses the relevant standard's given element names to ensure compatibility with the standard. 
 253                          *  \see \ref USB_Descriptor_Header_t for the version of this type with non-standard LUFA specific element names. 
 255                          *  \note Regardless of CPU architecture, these values should be stored as little endian. 
 259                                 uint8_t bLength
; /**< Size of the descriptor, in bytes. */ 
 260                                 uint8_t bDescriptorType
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value 
 261                                                           *   given by the specific class. 
 263                         } ATTR_PACKED USB_StdDescriptor_Header_t
; 
 265                         /** \brief Standard USB Device Descriptor (LUFA naming conventions). 
 267                          *  Type define for a standard Device Descriptor. This structure uses LUFA-specific element names to make each 
 268                          *  element's purpose clearer. 
 270                          *  \see \ref USB_StdDescriptor_Device_t for the version of this type with standard element names. 
 272                          *  \note Regardless of CPU architecture, these values should be stored as little endian. 
 276                                 USB_Descriptor_Header_t Header
; /**< Descriptor header, including type and size. */ 
 278                                 uint16_t USBSpecification
; /**< BCD of the supported USB specification. */ 
 279                                 uint8_t  Class
; /**< USB device class. */ 
 280                                 uint8_t  SubClass
; /**< USB device subclass. */ 
 281                                 uint8_t  Protocol
; /**< USB device protocol. */ 
 283                                 uint8_t  Endpoint0Size
; /**< Size of the control (address 0) endpoint's bank in bytes. */ 
 285                                 uint16_t VendorID
; /**< Vendor ID for the USB product. */ 
 286                                 uint16_t ProductID
; /**< Unique product ID for the USB product. */ 
 287                                 uint16_t ReleaseNumber
; /**< Product release (version) number. */ 
 289                                 uint8_t  ManufacturerStrIndex
; /**< String index for the manufacturer's name. The 
 290                                                                 *   host will request this string via a separate 
 291                                                                 *   control request for the string descriptor. 
 293                                                                 *   \note If no string supplied, use \ref NO_DESCRIPTOR. 
 295                                 uint8_t  ProductStrIndex
; /**< String index for the product name/details. 
 297                                                            *  \see ManufacturerStrIndex structure entry. 
 299                                 uint8_t  SerialNumStrIndex
; /**< String index for the product's globally unique hexadecimal 
 300                                                              *   serial number, in uppercase Unicode ASCII. 
 302                                                              *  \note On some microcontroller models, there is an embedded serial number 
 303                                                              *        in the chip which can be used for the device serial number. 
 304                                                              *        To use this serial number, set this to USE_INTERNAL_SERIAL. 
 305                                                              *        On unsupported devices, this will evaluate to 0 and will cause 
 306                                                              *        the host to generate a pseudo-unique value for the device upon 
 309                                                              *  \see ManufacturerStrIndex structure entry. 
 311                                 uint8_t  NumberOfConfigurations
; /**< Total number of configurations supported by 
 314                         } ATTR_PACKED USB_Descriptor_Device_t
; 
 316                         /** \brief Standard USB Device Descriptor (USB-IF naming conventions). 
 318                          *  Type define for a standard Device Descriptor. This structure uses the relevant standard's given element names 
 319                          *  to ensure compatibility with the standard. 
 321                          *  \see \ref USB_Descriptor_Device_t for the version of this type with non-standard LUFA specific element names. 
 323                          *  \note Regardless of CPU architecture, these values should be stored as little endian. 
 327                                 uint8_t  bLength
; /**< Size of the descriptor, in bytes. */ 
 328                                 uint8_t  bDescriptorType
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value 
 329                                                               *   given by the specific class. 
 331                                 uint16_t bcdUSB
; /**< BCD of the supported USB specification. */ 
 332                                 uint8_t  bDeviceClass
; /**< USB device class. */ 
 333                                 uint8_t  bDeviceSubClass
; /**< USB device subclass. */ 
 334                                 uint8_t  bDeviceProtocol
; /**< USB device protocol. */ 
 335                                 uint8_t  bMaxPacketSize0
; /**< Size of the control (address 0) endpoint's bank in bytes. */ 
 336                                 uint16_t idVendor
; /**< Vendor ID for the USB product. */ 
 337                                 uint16_t idProduct
; /**< Unique product ID for the USB product. */ 
 338                                 uint16_t bcdDevice
; /**< Product release (version) number. */ 
 339                                 uint8_t  iManufacturer
; /**< String index for the manufacturer's name. The 
 340                                                          *   host will request this string via a separate 
 341                                                          *   control request for the string descriptor. 
 343                                                          *   \note If no string supplied, use \ref NO_DESCRIPTOR. 
 345                                 uint8_t  iProduct
; /**< String index for the product name/details. 
 347                                                     *  \see ManufacturerStrIndex structure entry. 
 349                                 uint8_t iSerialNumber
; /**< String index for the product's globally unique hexadecimal 
 350                                                         *   serial number, in uppercase Unicode ASCII. 
 352                                                         *  \note On some microcontroller models, there is an embedded serial number 
 353                                                         *        in the chip which can be used for the device serial number. 
 354                                                         *        To use this serial number, set this to USE_INTERNAL_SERIAL. 
 355                                                         *        On unsupported devices, this will evaluate to 0 and will cause 
 356                                                         *        the host to generate a pseudo-unique value for the device upon 
 359                                                         *  \see ManufacturerStrIndex structure entry. 
 361                                 uint8_t  bNumConfigurations
; /**< Total number of configurations supported by 
 364                         } ATTR_PACKED USB_StdDescriptor_Device_t
; 
 366                         /** \brief Standard USB Device Qualifier Descriptor (LUFA naming conventions). 
 368                          *  Type define for a standard Device Qualifier Descriptor. This structure uses LUFA-specific element names 
 369                          *  to make each element's purpose clearer. 
 371                          *  \see \ref USB_StdDescriptor_DeviceQualifier_t for the version of this type with standard element names. 
 375                                 USB_Descriptor_Header_t Header
; /**< Descriptor header, including type and size. */ 
 377                                 uint16_t USBSpecification
; /**< BCD of the supported USB specification. */ 
 378                                 uint8_t  Class
; /**< USB device class. */ 
 379                                 uint8_t  SubClass
; /**< USB device subclass. */ 
 380                                 uint8_t  Protocol
; /**< USB device protocol. */ 
 382                                 uint8_t  Endpoint0Size
; /**< Size of the control (address 0) endpoint's bank in bytes. */ 
 383                                 uint8_t  NumberOfConfigurations
; /**< Total number of configurations supported by 
 386                                 uint8_t  Reserved
; /**< Reserved for future use, must be 0. */ 
 387                         } ATTR_PACKED USB_Descriptor_DeviceQualifier_t
; 
 389                         /** \brief Standard USB Device Qualifier Descriptor (USB-IF naming conventions). 
 391                          *  Type define for a standard Device Qualifier Descriptor. This structure uses the relevant standard's given element names 
 392                          *  to ensure compatibility with the standard. 
 394                          *  \see \ref USB_Descriptor_DeviceQualifier_t for the version of this type with non-standard LUFA specific element names. 
 398                                 uint8_t  bLength
; /**< Size of the descriptor, in bytes. */ 
 399                                 uint8_t  bDescriptorType
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value 
 400                                                               *   given by the specific class. 
 402                                 uint16_t bcdUSB
; /**< BCD of the supported USB specification. */ 
 403                                 uint8_t  bDeviceClass
; /**< USB device class. */ 
 404                                 uint8_t  bDeviceSubClass
; /**< USB device subclass. */ 
 405                                 uint8_t  bDeviceProtocol
; /**< USB device protocol. */ 
 406                                 uint8_t  bMaxPacketSize0
; /**< Size of the control (address 0) endpoint's bank in bytes. */ 
 407                                 uint8_t  bNumConfigurations
; /**< Total number of configurations supported by 
 410                                 uint8_t  bReserved
; /**< Reserved for future use, must be 0. */ 
 411                         } ATTR_PACKED USB_StdDescriptor_DeviceQualifier_t
; 
 413                         /** \brief Standard USB Configuration Descriptor (LUFA naming conventions). 
 415                          *  Type define for a standard Configuration Descriptor header. This structure uses LUFA-specific element names 
 416                          *  to make each element's purpose clearer. 
 418                          *  \see \ref USB_StdDescriptor_Configuration_Header_t for the version of this type with standard element names. 
 420                          *  \note Regardless of CPU architecture, these values should be stored as little endian. 
 424                                 USB_Descriptor_Header_t Header
; /**< Descriptor header, including type and size. */ 
 426                                 uint16_t TotalConfigurationSize
; /**< Size of the configuration descriptor header, 
 427                                                                   *   and all sub descriptors inside the configuration. 
 429                                 uint8_t  TotalInterfaces
; /**< Total number of interfaces in the configuration. */ 
 431                                 uint8_t  ConfigurationNumber
; /**< Configuration index of the current configuration. */ 
 432                                 uint8_t  ConfigurationStrIndex
; /**< Index of a string descriptor describing the configuration. */ 
 434                                 uint8_t  ConfigAttributes
; /**< Configuration attributes, comprised of a mask of \c USB_CONFIG_ATTR_* masks. 
 435                                                             *   On all devices, this should include USB_CONFIG_ATTR_RESERVED at a minimum. 
 438                                 uint8_t  MaxPowerConsumption
; /**< Maximum power consumption of the device while in the 
 439                                                                *   current configuration, calculated by the \ref USB_CONFIG_POWER_MA() 
 442                         } ATTR_PACKED USB_Descriptor_Configuration_Header_t
; 
 444                         /** \brief Standard USB Configuration Descriptor (USB-IF naming conventions). 
 446                          *  Type define for a standard Configuration Descriptor header. This structure uses the relevant standard's given element names 
 447                          *  to ensure compatibility with the standard. 
 449                          *  \see \ref USB_Descriptor_Device_t for the version of this type with non-standard LUFA specific element names. 
 451                          *  \note Regardless of CPU architecture, these values should be stored as little endian. 
 455                                 uint8_t  bLength
; /**< Size of the descriptor, in bytes. */ 
 456                                 uint8_t  bDescriptorType
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value 
 457                                                               *   given by the specific class. 
 459                                 uint16_t wTotalLength
; /**< Size of the configuration descriptor header, 
 460                                                            *   and all sub descriptors inside the configuration. 
 462                                 uint8_t  bNumInterfaces
; /**< Total number of interfaces in the configuration. */ 
 463                                 uint8_t  bConfigurationValue
; /**< Configuration index of the current configuration. */ 
 464                                 uint8_t  iConfiguration
; /**< Index of a string descriptor describing the configuration. */ 
 465                                 uint8_t  bmAttributes
; /**< Configuration attributes, comprised of a mask of \c USB_CONFIG_ATTR_* masks. 
 466                                                         *   On all devices, this should include USB_CONFIG_ATTR_RESERVED at a minimum. 
 468                                 uint8_t  bMaxPower
; /**< Maximum power consumption of the device while in the 
 469                                                      *   current configuration, calculated by the \ref USB_CONFIG_POWER_MA() 
 472                         } ATTR_PACKED USB_StdDescriptor_Configuration_Header_t
; 
 474                         /** \brief Standard USB Interface Descriptor (LUFA naming conventions). 
 476                          *  Type define for a standard Interface Descriptor. This structure uses LUFA-specific element names 
 477                          *  to make each element's purpose clearer. 
 479                          *  \see \ref USB_StdDescriptor_Interface_t for the version of this type with standard element names. 
 481                          *  \note Regardless of CPU architecture, these values should be stored as little endian. 
 485                                 USB_Descriptor_Header_t Header
; /**< Descriptor header, including type and size. */ 
 487                                 uint8_t InterfaceNumber
; /**< Index of the interface in the current configuration. */ 
 488                                 uint8_t AlternateSetting
; /**< Alternate setting for the interface number. The same 
 489                                                            *   interface number can have multiple alternate settings 
 490                                                            *   with different endpoint configurations, which can be 
 491                                                            *   selected by the host. 
 493                                 uint8_t TotalEndpoints
; /**< Total number of endpoints in the interface. */ 
 495                                 uint8_t Class
; /**< Interface class ID. */ 
 496                                 uint8_t SubClass
; /**< Interface subclass ID. */ 
 497                                 uint8_t Protocol
; /**< Interface protocol ID. */ 
 499                                 uint8_t InterfaceStrIndex
; /**< Index of the string descriptor describing the interface. */ 
 500                         } ATTR_PACKED USB_Descriptor_Interface_t
; 
 502                         /** \brief Standard USB Interface Descriptor (USB-IF naming conventions). 
 504                          *  Type define for a standard Interface Descriptor. This structure uses the relevant standard's given element names 
 505                          *  to ensure compatibility with the standard. 
 507                          *  \see \ref USB_Descriptor_Interface_t for the version of this type with non-standard LUFA specific element names. 
 509                          *  \note Regardless of CPU architecture, these values should be stored as little endian. 
 513                                 uint8_t bLength
; /**< Size of the descriptor, in bytes. */ 
 514                                 uint8_t bDescriptorType
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value 
 515                                                           *   given by the specific class. 
 517                                 uint8_t bInterfaceNumber
; /**< Index of the interface in the current configuration. */ 
 518                                 uint8_t bAlternateSetting
; /**< Alternate setting for the interface number. The same 
 519                                                             *   interface number can have multiple alternate settings 
 520                                                             *   with different endpoint configurations, which can be 
 521                                                             *   selected by the host. 
 523                                 uint8_t bNumEndpoints
; /**< Total number of endpoints in the interface. */ 
 524                                 uint8_t bInterfaceClass
; /**< Interface class ID. */ 
 525                                 uint8_t bInterfaceSubClass
; /**< Interface subclass ID. */ 
 526                                 uint8_t bInterfaceProtocol
; /**< Interface protocol ID. */ 
 527                                 uint8_t iInterface
; /**< Index of the string descriptor describing the 
 530                         } ATTR_PACKED USB_StdDescriptor_Interface_t
; 
 532                         /** \brief Standard USB Interface Association Descriptor (LUFA naming conventions). 
 534                          *  Type define for a standard Interface Association Descriptor. This structure uses LUFA-specific element names 
 535                          *  to make each element's purpose clearer. 
 537                          *  This descriptor has been added as a supplement to the USB2.0 standard, in the ECN located at 
 538                          *  <a>http://www.usb.org/developers/docs/InterfaceAssociationDescriptor_ecn.pdf</a>. It allows composite 
 539                          *  devices with multiple interfaces related to the same function to have the multiple interfaces bound 
 540                          *  together at the point of enumeration, loading one generic driver for all the interfaces in the single 
 541                          *  function. Read the ECN for more information. 
 543                          *  \see \ref USB_StdDescriptor_Interface_Association_t for the version of this type with standard element names. 
 545                          *  \note Regardless of CPU architecture, these values should be stored as little endian. 
 549                                 USB_Descriptor_Header_t Header
; /**< Descriptor header, including type and size. */ 
 551                                 uint8_t FirstInterfaceIndex
; /**< Index of the first associated interface. */ 
 552                                 uint8_t TotalInterfaces
; /**< Total number of associated interfaces. */ 
 554                                 uint8_t Class
; /**< Interface class ID. */ 
 555                                 uint8_t SubClass
; /**< Interface subclass ID. */ 
 556                                 uint8_t Protocol
; /**< Interface protocol ID. */ 
 558                                 uint8_t IADStrIndex
; /**< Index of the string descriptor describing the 
 559                                                       *   interface association. 
 561                         } ATTR_PACKED USB_Descriptor_Interface_Association_t
; 
 563                         /** \brief Standard USB Interface Association Descriptor (USB-IF naming conventions). 
 565                          *  Type define for a standard Interface Association Descriptor. This structure uses the relevant standard's given 
 566                          *  element names to ensure compatibility with the standard. 
 568                          *  This descriptor has been added as a supplement to the USB2.0 standard, in the ECN located at 
 569                          *  <a>http://www.usb.org/developers/docs/InterfaceAssociationDescriptor_ecn.pdf</a>. It allows composite 
 570                          *  devices with multiple interfaces related to the same function to have the multiple interfaces bound 
 571                          *  together at the point of enumeration, loading one generic driver for all the interfaces in the single 
 572                          *  function. Read the ECN for more information. 
 574                          *  \see \ref USB_Descriptor_Interface_Association_t for the version of this type with non-standard LUFA specific 
 577                          *  \note Regardless of CPU architecture, these values should be stored as little endian. 
 581                                 uint8_t bLength
; /**< Size of the descriptor, in bytes. */ 
 582                                 uint8_t bDescriptorType
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value 
 583                                                           *   given by the specific class. 
 585                                 uint8_t bFirstInterface
; /**< Index of the first associated interface. */ 
 586                                 uint8_t bInterfaceCount
; /**< Total number of associated interfaces. */ 
 587                                 uint8_t bFunctionClass
; /**< Interface class ID. */ 
 588                                 uint8_t bFunctionSubClass
; /**< Interface subclass ID. */ 
 589                                 uint8_t bFunctionProtocol
; /**< Interface protocol ID. */ 
 590                                 uint8_t iFunction
; /**< Index of the string descriptor describing the 
 591                                                     *   interface association. 
 593                         } ATTR_PACKED USB_StdDescriptor_Interface_Association_t
; 
 595                         /** \brief Standard USB Endpoint Descriptor (LUFA naming conventions). 
 597                          *  Type define for a standard Endpoint Descriptor. This structure uses LUFA-specific element names 
 598                          *  to make each element's purpose clearer. 
 600                          *  \see \ref USB_StdDescriptor_Endpoint_t for the version of this type with standard element names. 
 602                          *  \note Regardless of CPU architecture, these values should be stored as little endian. 
 606                                 USB_Descriptor_Header_t Header
; /**< Descriptor header, including type and size. */ 
 608                                 uint8_t  EndpointAddress
; /**< Logical address of the endpoint within the device for the current 
 609                                                            *   configuration, including direction mask. 
 611                                 uint8_t  Attributes
; /**< Endpoint attributes, comprised of a mask of the endpoint type (EP_TYPE_*) 
 612                                                       *   and attributes (ENDPOINT_ATTR_*) masks. 
 614                                 uint16_t EndpointSize
; /**< Size of the endpoint bank, in bytes. This indicates the maximum packet 
 615                                                         *   size that the endpoint can receive at a time. 
 617                                 uint8_t  PollingIntervalMS
; /**< Polling interval in milliseconds for the endpoint if it is an INTERRUPT 
 618                                                              *   or ISOCHRONOUS type. 
 620                         } ATTR_PACKED USB_Descriptor_Endpoint_t
; 
 622                         /** \brief Standard USB Endpoint Descriptor (USB-IF naming conventions). 
 624                          *  Type define for a standard Endpoint Descriptor. This structure uses the relevant standard's given 
 625                          *  element names to ensure compatibility with the standard. 
 627                          *  \see \ref USB_Descriptor_Endpoint_t for the version of this type with non-standard LUFA specific 
 630                          *  \note Regardless of CPU architecture, these values should be stored as little endian. 
 634                                 uint8_t  bLength
; /**< Size of the descriptor, in bytes. */ 
 635                                 uint8_t  bDescriptorType
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a 
 636                                                            *   value given by the specific class. 
 638                                 uint8_t  bEndpointAddress
; /**< Logical address of the endpoint within the device for the current 
 639                                                             *   configuration, including direction mask. 
 641                                 uint8_t  bmAttributes
; /**< Endpoint attributes, comprised of a mask of the endpoint type (EP_TYPE_*) 
 642                                                         *   and attributes (ENDPOINT_ATTR_*) masks. 
 644                                 uint16_t wMaxPacketSize
; /**< Size of the endpoint bank, in bytes. This indicates the maximum packet size 
 645                                                           *   that the endpoint can receive at a time. 
 647                                 uint8_t  bInterval
; /**< Polling interval in milliseconds for the endpoint if it is an INTERRUPT or 
 650                         } ATTR_PACKED USB_StdDescriptor_Endpoint_t
; 
 652                         /** \brief Standard USB String Descriptor (LUFA naming conventions). 
 654                          *  Type define for a standard string descriptor. Unlike other standard descriptors, the length 
 655                          *  of the descriptor for placement in the descriptor header must be determined by the \ref USB_STRING_LEN() 
 656                          *  macro rather than by the size of the descriptor structure, as the length is not fixed. 
 658                          *  This structure should also be used for string index 0, which contains the supported language IDs for 
 659                          *  the device as an array. 
 661                          *  This structure uses LUFA-specific element names to make each element's purpose clearer. 
 663                          *  \see \ref USB_StdDescriptor_String_t for the version of this type with standard element names. 
 665                          *  \note Regardless of CPU architecture, these values should be stored as little endian. 
 669                                 USB_Descriptor_Header_t Header
; /**< Descriptor header, including type and size. */ 
 671                                 #if (((ARCH == ARCH_AVR8) || (ARCH == ARCH_XMEGA)) && !defined(__DOXYGEN__)) 
 672                                 wchar_t  UnicodeString
[]; 
 674                                 uint16_t UnicodeString
[]; /**< String data, as unicode characters (alternatively, 
 675                                                            *   string language IDs). If normal ASCII characters are 
 676                                                            *   to be used, they must be added as an array of characters 
 677                                                            *   rather than a normal C string so that they are widened to 
 680                                                            *   Under GCC, strings prefixed with the "L" character (before 
 681                                                            *   the opening string quotation mark) are considered to be 
 682                                                            *   Unicode strings, and may be used instead of an explicit 
 683                                                            *   array of ASCII characters on little endian devices with 
 684                                                            *   UTF-16-LE \c wchar_t encoding. 
 687                         } ATTR_PACKED USB_Descriptor_String_t
; 
 689                         /** \brief Standard USB String Descriptor (USB-IF naming conventions). 
 691                          *  Type define for a standard string descriptor. Unlike other standard descriptors, the length 
 692                          *  of the descriptor for placement in the descriptor header must be determined by the \ref USB_STRING_LEN() 
 693                          *  macro rather than by the size of the descriptor structure, as the length is not fixed. 
 695                          *  This structure should also be used for string index 0, which contains the supported language IDs for 
 696                          *  the device as an array. 
 698                          *  This structure uses the relevant standard's given element names to ensure compatibility with the standard. 
 700                          *  \see \ref USB_Descriptor_String_t for the version of this type with with non-standard LUFA specific 
 703                          *  \note Regardless of CPU architecture, these values should be stored as little endian. 
 707                                 uint8_t bLength
; /**< Size of the descriptor, in bytes. */ 
 708                                 uint8_t bDescriptorType
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t 
 709                                                           *   or a value given by the specific class. 
 711                                 uint16_t bString
[]; /**< String data, as unicode characters (alternatively, string language IDs). 
 712                                                      *   If normal ASCII characters are to be used, they must be added as an array 
 713                                                      *   of characters rather than a normal C string so that they are widened to 
 716                                                      *   Under GCC, strings prefixed with the "L" character (before the opening string 
 717                                                      *   quotation mark) are considered to be Unicode strings, and may be used instead 
 718                                                      *   of an explicit array of ASCII characters. 
 720                         } ATTR_PACKED USB_StdDescriptor_String_t
; 
 722         /* Private Interface - For use in library only: */ 
 723         #if !defined(__DOXYGEN__) 
 725                         #define VERSION_TENS(x)                   (int)((int)(x) / 10) 
 726                         #define VERSION_ONES(x)                   (int)((int)(x) % 10) 
 727                         #define VERSION_TENTHS(x)                 (int)((x - (int)x) * 10) 
 728                         #define VERSION_HUNDREDTHS(x)             (int)((x * 100) - ((int)(x * 10) * 10)) 
 731         /* Disable C linkage for C++ Compilers: */ 
 732                 #if defined(__cplusplus)