3      Copyright (C) Dean Camera, 2021. 
   5   dean [at] fourwalledcubicle [dot] com 
  10   Copyright 2021  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                         /** Convenience macro to easily create \ref USB_Descriptor_String_t instances from a wide character string. 
  90                          *  \note This macro is for little-endian systems only. 
  92                          *  \param[in] String  String to initialize a USB String Descriptor structure with. 
  94                         #define USB_STRING_DESCRIPTOR(String)     { .Header = {.Size = sizeof(USB_Descriptor_Header_t) + (sizeof(String) - 2), .Type = DTYPE_String}, .UnicodeString = String } 
  96                         /** Convenience macro to easily create \ref USB_Descriptor_String_t instances from an array of characters. 
  98                          *  \param[in] ...  Characters to initialize a USB String Descriptor structure with. 
 100                         #define USB_STRING_DESCRIPTOR_ARRAY(...)  { .Header = {.Size = sizeof(USB_Descriptor_Header_t) + sizeof((uint16_t[]){__VA_ARGS__}), .Type = DTYPE_String}, .UnicodeString = {__VA_ARGS__} } 
 102                         /** Macro to encode a given major/minor/revision version number into Binary Coded Decimal format for descriptor 
 103                          *  fields requiring BCD encoding, such as the USB version number in the standard device descriptor. 
 105                          *  \note This value is automatically converted into Little Endian, suitable for direct use inside device 
 106                          *        descriptors on all architectures without endianness conversion macros. 
 108                          *  \param[in]  Major     Major version number to encode. 
 109                          *  \param[in]  Minor     Minor version number to encode. 
 110                          *  \param[in]  Revision  Revision version number to encode. 
 112                         #define VERSION_BCD(Major, Minor, Revision) \ 
 113                                                                   CPU_TO_LE16( ((Major & 0xFF) << 8) | \ 
 114                                                                                ((Minor & 0x0F) << 4) | \ 
 117                         /** String language ID for the English language. Should be used in \ref USB_Descriptor_String_t descriptors 
 118                          *  to indicate that the English language is supported by the device in its string descriptors. 
 120                         #define LANGUAGE_ID_ENG                   0x0409 
 122                         /** \name USB Configuration Descriptor Attribute Masks */ 
 124                         /** Mask for the reserved bit in the Configuration Descriptor's \c ConfigAttributes field, which must be always 
 125                          *  set on all USB devices for historical purposes. 
 127                         #define USB_CONFIG_ATTR_RESERVED          0x80 
 129                         /** Can be masked with other configuration descriptor attributes for a \ref USB_Descriptor_Configuration_Header_t 
 130                          *  descriptor's \c ConfigAttributes value to indicate that the specified configuration can draw its power 
 131                          *  from the device's own power source, instead of drawing it from the USB host. 
 133                          *  Note that the host will probe this dynamically - the device should report its current power state via the 
 134                          *  \ref USB_Device_CurrentlySelfPowered global variable. 
 136                         #define USB_CONFIG_ATTR_SELFPOWERED       0x40 
 138                         /** Can be masked with other configuration descriptor attributes for a \ref USB_Descriptor_Configuration_Header_t 
 139                          *  descriptor's \c ConfigAttributes value to indicate that the specified configuration supports the 
 140                          *  remote wakeup feature of the USB standard, allowing a suspended USB device to wake up the host upon 
 143                          *  If set, the host will dynamically enable and disable remote wakeup support, indicated via the 
 144                          *  \ref USB_Device_RemoteWakeupEnabled global variable. To initiate a remote wakeup of the host (when allowed) 
 145                          *  see \ref USB_Device_RemoteWakeupEnabled(). 
 147                         #define USB_CONFIG_ATTR_REMOTEWAKEUP      0x20 
 150                         /** \name Endpoint Descriptor Attribute Masks */ 
 152                         /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's 
 153                          *  \c Attributes value to indicate that the specified endpoint is not synchronized. 
 155                          *  \see The USB specification for more details on the possible Endpoint attributes. 
 157                         #define ENDPOINT_ATTR_NO_SYNC             (0 << 2) 
 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 asynchronous. 
 162                          *  \see The USB specification for more details on the possible Endpoint attributes. 
 164                         #define ENDPOINT_ATTR_ASYNC               (1 << 2) 
 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 adaptive. 
 169                          *  \see The USB specification for more details on the possible Endpoint attributes. 
 171                         #define ENDPOINT_ATTR_ADAPTIVE            (2 << 2) 
 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 synchronized. 
 176                          *  \see The USB specification for more details on the possible Endpoint attributes. 
 178                         #define ENDPOINT_ATTR_SYNC                (3 << 2) 
 181                         /** \name Endpoint Descriptor Usage Masks */ 
 183                         /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's 
 184                          *  \c Attributes value to indicate that the specified endpoint is used for data transfers. 
 186                          *  \see The USB specification for more details on the possible Endpoint usage attributes. 
 188                         #define ENDPOINT_USAGE_DATA               (0 << 4) 
 190                         /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's 
 191                          *  \c Attributes value to indicate that the specified endpoint is used for feedback. 
 193                          *  \see The USB specification for more details on the possible Endpoint usage attributes. 
 195                         #define ENDPOINT_USAGE_FEEDBACK           (1 << 4) 
 197                         /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's 
 198                          *  \c Attributes value to indicate that the specified endpoint is used for implicit feedback. 
 200                          *  \see The USB specification for more details on the possible Endpoint usage attributes. 
 202                         #define ENDPOINT_USAGE_IMPLICIT_FEEDBACK  (2 << 4) 
 206                         /** Enum for the possible standard descriptor types, as given in each descriptor's header. */ 
 207                         enum USB_DescriptorTypes_t
 
 209                                 DTYPE_Device                    
= 0x01, /**< Indicates that the descriptor is a device descriptor. */ 
 210                                 DTYPE_Configuration             
= 0x02, /**< Indicates that the descriptor is a configuration descriptor. */ 
 211                                 DTYPE_String                    
= 0x03, /**< Indicates that the descriptor is a string descriptor. */ 
 212                                 DTYPE_Interface                 
= 0x04, /**< Indicates that the descriptor is an interface descriptor. */ 
 213                                 DTYPE_Endpoint                  
= 0x05, /**< Indicates that the descriptor is an endpoint descriptor. */ 
 214                                 DTYPE_DeviceQualifier           
= 0x06, /**< Indicates that the descriptor is a device qualifier descriptor. */ 
 215                                 DTYPE_Other                     
= 0x07, /**< Indicates that the descriptor is of other type. */ 
 216                                 DTYPE_InterfacePower            
= 0x08, /**< Indicates that the descriptor is an interface power descriptor. */ 
 217                                 DTYPE_InterfaceAssociation      
= 0x0B, /**< Indicates that the descriptor is an interface association descriptor. */ 
 220                         /** Enum for possible Class, Subclass and Protocol values of device and interface descriptors. */ 
 221                         enum USB_Descriptor_ClassSubclassProtocol_t
 
 223                                 USB_CSCP_NoDeviceClass          
= 0x00, /**< Descriptor Class value indicating that the device does not belong 
 224                                                                          *   to a particular class at the device level. 
 226                                 USB_CSCP_NoDeviceSubclass       
= 0x00, /**< Descriptor Subclass value indicating that the device does not belong 
 227                                                                          *   to a particular subclass at the device level. 
 229                                 USB_CSCP_NoDeviceProtocol       
= 0x00, /**< Descriptor Protocol value indicating that the device does not belong 
 230                                                                          *   to a particular protocol at the device level. 
 232                                 USB_CSCP_VendorSpecificClass    
= 0xFF, /**< Descriptor Class value indicating that the device/interface belongs 
 233                                                                          *   to a vendor specific class. 
 235                                 USB_CSCP_VendorSpecificSubclass 
= 0xFF, /**< Descriptor Subclass value indicating that the device/interface belongs 
 236                                                                          *   to a vendor specific subclass. 
 238                                 USB_CSCP_VendorSpecificProtocol 
= 0xFF, /**< Descriptor Protocol value indicating that the device/interface belongs 
 239                                                                          *   to a vendor specific protocol. 
 241                                 USB_CSCP_IADDeviceClass         
= 0xEF, /**< Descriptor Class value indicating that the device belongs to the 
 242                                                                          *   Interface Association Descriptor class. 
 244                                 USB_CSCP_IADDeviceSubclass      
= 0x02, /**< Descriptor Subclass value indicating that the device belongs to the 
 245                                                                          *   Interface Association Descriptor subclass. 
 247                                 USB_CSCP_IADDeviceProtocol      
= 0x01, /**< Descriptor Protocol value indicating that the device belongs to the 
 248                                                                          *   Interface Association Descriptor protocol. 
 253                         /** \brief Standard USB Descriptor Header (LUFA naming conventions). 
 255              *  Type define for all descriptors' standard header, indicating the descriptor's length and type. This structure 
 256                          *  uses LUFA-specific element names to make each element's purpose clearer. 
 258                          *  \see \ref USB_StdDescriptor_Header_t for the version of this type with standard element names. 
 260                          *  \note Regardless of CPU architecture, these values should be stored as little endian. 
 264                                 uint8_t Size
; /**< Size of the descriptor, in bytes. */ 
 265                                 uint8_t Type
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value 
 266                                                *   given by the specific class. 
 268                         } ATTR_PACKED USB_Descriptor_Header_t
; 
 270                         /** \brief Standard USB Descriptor Header (USB-IF naming conventions). 
 272                          *  Type define for all descriptors' standard header, indicating the descriptor's length and type. This structure 
 273                          *  uses the relevant standard's given element names to ensure compatibility with the standard. 
 275                          *  \see \ref USB_Descriptor_Header_t for the version of this type with non-standard LUFA specific element names. 
 277                          *  \note Regardless of CPU architecture, these values should be stored as little endian. 
 281                                 uint8_t bLength
; /**< Size of the descriptor, in bytes. */ 
 282                                 uint8_t bDescriptorType
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value 
 283                                                           *   given by the specific class. 
 285                         } ATTR_PACKED USB_StdDescriptor_Header_t
; 
 287                         /** \brief Standard USB Device Descriptor (LUFA naming conventions). 
 289                          *  Type define for a standard Device Descriptor. This structure uses LUFA-specific element names to make each 
 290                          *  element's purpose clearer. 
 292                          *  \see \ref USB_StdDescriptor_Device_t for the version of this type with standard element names. 
 294                          *  \note Regardless of CPU architecture, these values should be stored as little endian. 
 298                                 USB_Descriptor_Header_t Header
; /**< Descriptor header, including type and size. */ 
 300                                 uint16_t USBSpecification
; /**< BCD of the supported USB specification. 
 302                                                             *   \see \ref VERSION_BCD() utility macro. 
 304                                 uint8_t  Class
; /**< USB device class. */ 
 305                                 uint8_t  SubClass
; /**< USB device subclass. */ 
 306                                 uint8_t  Protocol
; /**< USB device protocol. */ 
 308                                 uint8_t  Endpoint0Size
; /**< Size of the control (address 0) endpoint's bank in bytes. */ 
 310                                 uint16_t VendorID
; /**< Vendor ID for the USB product. */ 
 311                                 uint16_t ProductID
; /**< Unique product ID for the USB product. */ 
 312                                 uint16_t ReleaseNumber
; /**< Product release (version) number. 
 314                                                          *   \see \ref VERSION_BCD() utility macro. 
 316                                 uint8_t  ManufacturerStrIndex
; /**< String index for the manufacturer's name. The 
 317                                                                 *   host will request this string via a separate 
 318                                                                 *   control request for the string descriptor. 
 320                                                                 *   \note If no string supplied, use \ref NO_DESCRIPTOR. 
 322                                 uint8_t  ProductStrIndex
; /**< String index for the product name/details. 
 324                                                            *  \see ManufacturerStrIndex structure entry. 
 326                                 uint8_t  SerialNumStrIndex
; /**< String index for the product's globally unique hexadecimal 
 327                                                              *   serial number, in uppercase Unicode ASCII. 
 329                                                              *  \note On some microcontroller models, there is an embedded serial number 
 330                                                              *        in the chip which can be used for the device serial number. 
 331                                                              *        To use this serial number, set this to \c USE_INTERNAL_SERIAL. 
 332                                                              *        On unsupported devices, this will evaluate to \ref NO_DESCRIPTOR 
 333                                                              *        and will cause the host to generate a pseudo-unique value for the 
 334                                                              *        device upon insertion. 
 336                                                              *  \see \c ManufacturerStrIndex structure entry. 
 338                                 uint8_t  NumberOfConfigurations
; /**< Total number of configurations supported by 
 341                         } ATTR_PACKED USB_Descriptor_Device_t
; 
 343                         /** \brief Standard USB Device Descriptor (USB-IF naming conventions). 
 345                          *  Type define for a standard Device Descriptor. This structure uses the relevant standard's given element names 
 346                          *  to ensure compatibility with the standard. 
 348                          *  \see \ref USB_Descriptor_Device_t for the version of this type with non-standard LUFA specific element names. 
 350                          *  \note Regardless of CPU architecture, these values should be stored as little endian. 
 354                                 uint8_t  bLength
; /**< Size of the descriptor, in bytes. */ 
 355                                 uint8_t  bDescriptorType
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value 
 356                                                               *   given by the specific class. 
 358                                 uint16_t bcdUSB
; /**< BCD of the supported USB specification. 
 360                                                   *   \see \ref VERSION_BCD() utility macro. 
 362                                 uint8_t  bDeviceClass
; /**< USB device class. */ 
 363                                 uint8_t  bDeviceSubClass
; /**< USB device subclass. */ 
 364                                 uint8_t  bDeviceProtocol
; /**< USB device protocol. */ 
 365                                 uint8_t  bMaxPacketSize0
; /**< Size of the control (address 0) endpoint's bank in bytes. */ 
 366                                 uint16_t idVendor
; /**< Vendor ID for the USB product. */ 
 367                                 uint16_t idProduct
; /**< Unique product ID for the USB product. */ 
 368                                 uint16_t bcdDevice
; /**< Product release (version) number. 
 370                                                      *   \see \ref VERSION_BCD() utility macro. 
 372                                 uint8_t  iManufacturer
; /**< String index for the manufacturer's name. The 
 373                                                          *   host will request this string via a separate 
 374                                                          *   control request for the string descriptor. 
 376                                                          *   \note If no string supplied, use \ref NO_DESCRIPTOR. 
 378                                 uint8_t  iProduct
; /**< String index for the product name/details. 
 380                                                     *  \see ManufacturerStrIndex structure entry. 
 382                                 uint8_t iSerialNumber
; /**< String index for the product's globally unique hexadecimal 
 383                                                         *   serial number, in uppercase Unicode ASCII. 
 385                                                         *  \note On some microcontroller models, there is an embedded serial number 
 386                                                         *        in the chip which can be used for the device serial number. 
 387                                                         *        To use this serial number, set this to \c USE_INTERNAL_SERIAL. 
 388                                                         *        On unsupported devices, this will evaluate to \ref NO_DESCRIPTOR 
 389                                                         *        and will cause the host to generate a pseudo-unique value for the 
 390                                                         *        device upon insertion. 
 392                                                         *  \see \c ManufacturerStrIndex structure entry. 
 394                                 uint8_t  bNumConfigurations
; /**< Total number of configurations supported by 
 397                         } ATTR_PACKED USB_StdDescriptor_Device_t
; 
 399                         /** \brief Standard USB Device Qualifier Descriptor (LUFA naming conventions). 
 401                          *  Type define for a standard Device Qualifier Descriptor. This structure uses LUFA-specific element names 
 402                          *  to make each element's purpose clearer. 
 404                          *  \see \ref USB_StdDescriptor_DeviceQualifier_t for the version of this type with standard element names. 
 408                                 USB_Descriptor_Header_t Header
; /**< Descriptor header, including type and size. */ 
 410                                 uint16_t USBSpecification
; /**< BCD of the supported USB specification. 
 412                                                             *   \see \ref VERSION_BCD() utility macro. 
 414                                 uint8_t  Class
; /**< USB device class. */ 
 415                                 uint8_t  SubClass
; /**< USB device subclass. */ 
 416                                 uint8_t  Protocol
; /**< USB device protocol. */ 
 418                                 uint8_t  Endpoint0Size
; /**< Size of the control (address 0) endpoint's bank in bytes. */ 
 419                                 uint8_t  NumberOfConfigurations
; /**< Total number of configurations supported by 
 422                                 uint8_t  Reserved
; /**< Reserved for future use, must be 0. */ 
 423                         } ATTR_PACKED USB_Descriptor_DeviceQualifier_t
; 
 425                         /** \brief Standard USB Device Qualifier Descriptor (USB-IF naming conventions). 
 427                          *  Type define for a standard Device Qualifier Descriptor. This structure uses the relevant standard's given element names 
 428                          *  to ensure compatibility with the standard. 
 430                          *  \see \ref USB_Descriptor_DeviceQualifier_t for the version of this type with non-standard LUFA specific element names. 
 434                                 uint8_t  bLength
; /**< Size of the descriptor, in bytes. */ 
 435                                 uint8_t  bDescriptorType
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value 
 436                                                            *   given by the specific class. 
 438                                 uint16_t bcdUSB
; /**< BCD of the supported USB specification. 
 440                                                   *   \see \ref VERSION_BCD() utility macro. 
 442                                 uint8_t  bDeviceClass
; /**< USB device class. */ 
 443                                 uint8_t  bDeviceSubClass
; /**< USB device subclass. */ 
 444                                 uint8_t  bDeviceProtocol
; /**< USB device protocol. */ 
 445                                 uint8_t  bMaxPacketSize0
; /**< Size of the control (address 0) endpoint's bank in bytes. */ 
 446                                 uint8_t  bNumConfigurations
; /**< Total number of configurations supported by 
 449                                 uint8_t  bReserved
; /**< Reserved for future use, must be 0. */ 
 450                         } ATTR_PACKED USB_StdDescriptor_DeviceQualifier_t
; 
 452                         /** \brief Standard USB Configuration Descriptor (LUFA naming conventions). 
 454                          *  Type define for a standard Configuration Descriptor header. This structure uses LUFA-specific element names 
 455                          *  to make each element's purpose clearer. 
 457                          *  \see \ref USB_StdDescriptor_Configuration_Header_t for the version of this type with standard element names. 
 459                          *  \note Regardless of CPU architecture, these values should be stored as little endian. 
 463                                 USB_Descriptor_Header_t Header
; /**< Descriptor header, including type and size. */ 
 465                                 uint16_t TotalConfigurationSize
; /**< Size of the configuration descriptor header, 
 466                                                                   *   and all sub descriptors inside the configuration. 
 468                                 uint8_t  TotalInterfaces
; /**< Total number of interfaces in the configuration. */ 
 470                                 uint8_t  ConfigurationNumber
; /**< Configuration index of the current configuration. */ 
 471                                 uint8_t  ConfigurationStrIndex
; /**< Index of a string descriptor describing the configuration. */ 
 473                                 uint8_t  ConfigAttributes
; /**< Configuration attributes, comprised of a mask of \c USB_CONFIG_ATTR_* masks. 
 474                                                             *   On all devices, this should include USB_CONFIG_ATTR_RESERVED at a minimum. 
 477                                 uint8_t  MaxPowerConsumption
; /**< Maximum power consumption of the device while in the 
 478                                                                *   current configuration, calculated by the \ref USB_CONFIG_POWER_MA() 
 481                         } ATTR_PACKED USB_Descriptor_Configuration_Header_t
; 
 483                         /** \brief Standard USB Configuration Descriptor (USB-IF naming conventions). 
 485                          *  Type define for a standard Configuration Descriptor header. This structure uses the relevant standard's given element names 
 486                          *  to ensure compatibility with the standard. 
 488                          *  \see \ref USB_Descriptor_Device_t for the version of this type with non-standard LUFA specific element names. 
 490                          *  \note Regardless of CPU architecture, these values should be stored as little endian. 
 494                                 uint8_t  bLength
; /**< Size of the descriptor, in bytes. */ 
 495                                 uint8_t  bDescriptorType
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value 
 496                                                            *   given by the specific class. 
 498                                 uint16_t wTotalLength
; /**< Size of the configuration descriptor header, 
 499                                                            *   and all sub descriptors inside the configuration. 
 501                                 uint8_t  bNumInterfaces
; /**< Total number of interfaces in the configuration. */ 
 502                                 uint8_t  bConfigurationValue
; /**< Configuration index of the current configuration. */ 
 503                                 uint8_t  iConfiguration
; /**< Index of a string descriptor describing the configuration. */ 
 504                                 uint8_t  bmAttributes
; /**< Configuration attributes, comprised of a mask of \c USB_CONFIG_ATTR_* masks. 
 505                                                         *   On all devices, this should include USB_CONFIG_ATTR_RESERVED at a minimum. 
 507                                 uint8_t  bMaxPower
; /**< Maximum power consumption of the device while in the 
 508                                                      *   current configuration, calculated by the \ref USB_CONFIG_POWER_MA() 
 511                         } ATTR_PACKED USB_StdDescriptor_Configuration_Header_t
; 
 513                         /** \brief Standard USB Interface Descriptor (LUFA naming conventions). 
 515                          *  Type define for a standard Interface Descriptor. This structure uses LUFA-specific element names 
 516                          *  to make each element's purpose clearer. 
 518                          *  \see \ref USB_StdDescriptor_Interface_t for the version of this type with standard element names. 
 520                          *  \note Regardless of CPU architecture, these values should be stored as little endian. 
 524                                 USB_Descriptor_Header_t Header
; /**< Descriptor header, including type and size. */ 
 526                                 uint8_t InterfaceNumber
; /**< Index of the interface in the current configuration. */ 
 527                                 uint8_t AlternateSetting
; /**< Alternate setting for the interface number. The same 
 528                                                            *   interface number can have multiple alternate settings 
 529                                                            *   with different endpoint configurations, which can be 
 530                                                            *   selected by the host. 
 532                                 uint8_t TotalEndpoints
; /**< Total number of endpoints in the interface. */ 
 534                                 uint8_t Class
; /**< Interface class ID. */ 
 535                                 uint8_t SubClass
; /**< Interface subclass ID. */ 
 536                                 uint8_t Protocol
; /**< Interface protocol ID. */ 
 538                                 uint8_t InterfaceStrIndex
; /**< Index of the string descriptor describing the interface. */ 
 539                         } ATTR_PACKED USB_Descriptor_Interface_t
; 
 541                         /** \brief Standard USB Interface Descriptor (USB-IF naming conventions). 
 543                          *  Type define for a standard Interface Descriptor. This structure uses the relevant standard's given element names 
 544                          *  to ensure compatibility with the standard. 
 546                          *  \see \ref USB_Descriptor_Interface_t for the version of this type with non-standard LUFA specific element names. 
 548                          *  \note Regardless of CPU architecture, these values should be stored as little endian. 
 552                                 uint8_t bLength
; /**< Size of the descriptor, in bytes. */ 
 553                                 uint8_t bDescriptorType
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value 
 554                                                           *   given by the specific class. 
 556                                 uint8_t bInterfaceNumber
; /**< Index of the interface in the current configuration. */ 
 557                                 uint8_t bAlternateSetting
; /**< Alternate setting for the interface number. The same 
 558                                                             *   interface number can have multiple alternate settings 
 559                                                             *   with different endpoint configurations, which can be 
 560                                                             *   selected by the host. 
 562                                 uint8_t bNumEndpoints
; /**< Total number of endpoints in the interface. */ 
 563                                 uint8_t bInterfaceClass
; /**< Interface class ID. */ 
 564                                 uint8_t bInterfaceSubClass
; /**< Interface subclass ID. */ 
 565                                 uint8_t bInterfaceProtocol
; /**< Interface protocol ID. */ 
 566                                 uint8_t iInterface
; /**< Index of the string descriptor describing the 
 569                         } ATTR_PACKED USB_StdDescriptor_Interface_t
; 
 571                         /** \brief Standard USB Interface Association Descriptor (LUFA naming conventions). 
 573                          *  Type define for a standard Interface Association Descriptor. This structure uses LUFA-specific element names 
 574                          *  to make each element's purpose clearer. 
 576                          *  This descriptor has been added as a supplement to the USB2.0 standard, in the ECN located at 
 577                          *  <a>http://www.usb.org/developers/docs/InterfaceAssociationDescriptor_ecn.pdf</a>. It allows composite 
 578                          *  devices with multiple interfaces related to the same function to have the multiple interfaces bound 
 579                          *  together at the point of enumeration, loading one generic driver for all the interfaces in the single 
 580                          *  function. Read the ECN for more information. 
 582                          *  \see \ref USB_StdDescriptor_Interface_Association_t for the version of this type with standard element names. 
 584                          *  \note Regardless of CPU architecture, these values should be stored as little endian. 
 588                                 USB_Descriptor_Header_t Header
; /**< Descriptor header, including type and size. */ 
 590                                 uint8_t FirstInterfaceIndex
; /**< Index of the first associated interface. */ 
 591                                 uint8_t TotalInterfaces
; /**< Total number of associated interfaces. */ 
 593                                 uint8_t Class
; /**< Interface class ID. */ 
 594                                 uint8_t SubClass
; /**< Interface subclass ID. */ 
 595                                 uint8_t Protocol
; /**< Interface protocol ID. */ 
 597                                 uint8_t IADStrIndex
; /**< Index of the string descriptor describing the 
 598                                                       *   interface association. 
 600                         } ATTR_PACKED USB_Descriptor_Interface_Association_t
; 
 602                         /** \brief Standard USB Interface Association Descriptor (USB-IF naming conventions). 
 604                          *  Type define for a standard Interface Association Descriptor. This structure uses the relevant standard's given 
 605                          *  element names to ensure compatibility with the standard. 
 607                          *  This descriptor has been added as a supplement to the USB2.0 standard, in the ECN located at 
 608                          *  <a>http://www.usb.org/developers/docs/InterfaceAssociationDescriptor_ecn.pdf</a>. It allows composite 
 609                          *  devices with multiple interfaces related to the same function to have the multiple interfaces bound 
 610                          *  together at the point of enumeration, loading one generic driver for all the interfaces in the single 
 611                          *  function. Read the ECN for more information. 
 613                          *  \see \ref USB_Descriptor_Interface_Association_t for the version of this type with non-standard LUFA specific 
 616                          *  \note Regardless of CPU architecture, these values should be stored as little endian. 
 620                                 uint8_t bLength
; /**< Size of the descriptor, in bytes. */ 
 621                                 uint8_t bDescriptorType
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value 
 622                                                           *   given by the specific class. 
 624                                 uint8_t bFirstInterface
; /**< Index of the first associated interface. */ 
 625                                 uint8_t bInterfaceCount
; /**< Total number of associated interfaces. */ 
 626                                 uint8_t bFunctionClass
; /**< Interface class ID. */ 
 627                                 uint8_t bFunctionSubClass
; /**< Interface subclass ID. */ 
 628                                 uint8_t bFunctionProtocol
; /**< Interface protocol ID. */ 
 629                                 uint8_t iFunction
; /**< Index of the string descriptor describing the 
 630                                                     *   interface association. 
 632                         } ATTR_PACKED USB_StdDescriptor_Interface_Association_t
; 
 634                         /** \brief Standard USB Endpoint Descriptor (LUFA naming conventions). 
 636                          *  Type define for a standard Endpoint Descriptor. This structure uses LUFA-specific element names 
 637                          *  to make each element's purpose clearer. 
 639                          *  \see \ref USB_StdDescriptor_Endpoint_t for the version of this type with standard element names. 
 641                          *  \note Regardless of CPU architecture, these values should be stored as little endian. 
 645                                 USB_Descriptor_Header_t Header
; /**< Descriptor header, including type and size. */ 
 647                                 uint8_t  EndpointAddress
; /**< Logical address of the endpoint within the device for the current 
 648                                                            *   configuration, including direction mask. 
 650                                 uint8_t  Attributes
; /**< Endpoint attributes, comprised of a mask of the endpoint type (EP_TYPE_*) 
 651                                                       *   and attributes (ENDPOINT_ATTR_*) masks. 
 653                                 uint16_t EndpointSize
; /**< Size of the endpoint bank, in bytes. This indicates the maximum packet 
 654                                                         *   size that the endpoint can receive at a time. 
 656                                 uint8_t  PollingIntervalMS
; /**< Polling interval in milliseconds for the endpoint if it is an INTERRUPT 
 657                                                              *   or ISOCHRONOUS type. 
 659                         } ATTR_PACKED USB_Descriptor_Endpoint_t
; 
 661                         /** \brief Standard USB Endpoint Descriptor (USB-IF naming conventions). 
 663                          *  Type define for a standard Endpoint Descriptor. This structure uses the relevant standard's given 
 664                          *  element names to ensure compatibility with the standard. 
 666                          *  \see \ref USB_Descriptor_Endpoint_t for the version of this type with non-standard LUFA specific 
 669                          *  \note Regardless of CPU architecture, these values should be stored as little endian. 
 673                                 uint8_t  bLength
; /**< Size of the descriptor, in bytes. */ 
 674                                 uint8_t  bDescriptorType
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a 
 675                                                            *   value given by the specific class. 
 677                                 uint8_t  bEndpointAddress
; /**< Logical address of the endpoint within the device for the current 
 678                                                             *   configuration, including direction mask. 
 680                                 uint8_t  bmAttributes
; /**< Endpoint attributes, comprised of a mask of the endpoint type (EP_TYPE_*) 
 681                                                         *   and attributes (ENDPOINT_ATTR_*) masks. 
 683                                 uint16_t wMaxPacketSize
; /**< Size of the endpoint bank, in bytes. This indicates the maximum packet size 
 684                                                           *   that the endpoint can receive at a time. 
 686                                 uint8_t  bInterval
; /**< Polling interval in milliseconds for the endpoint if it is an INTERRUPT or 
 689                         } ATTR_PACKED USB_StdDescriptor_Endpoint_t
; 
 691                         /** \brief Standard USB String Descriptor (LUFA naming conventions). 
 693                          *  Type define for a standard string descriptor. Unlike other standard descriptors, the length 
 694                          *  of the descriptor for placement in the descriptor header must be determined by the \ref USB_STRING_LEN() 
 695                          *  macro rather than by the size of the descriptor structure, as the length is not fixed. 
 697                          *  This structure should also be used for string index 0, which contains the supported language IDs for 
 698                          *  the device as an array. 
 700                          *  This structure uses LUFA-specific element names to make each element's purpose clearer. 
 702                          *  \see \ref USB_StdDescriptor_String_t for the version of this type with standard element names. 
 704                          *  \note Regardless of CPU architecture, these values should be stored as little endian. 
 708                                 USB_Descriptor_Header_t Header
; /**< Descriptor header, including type and size. */ 
 710                                 #if (((ARCH == ARCH_AVR8) || (ARCH == ARCH_XMEGA)) && !defined(__DOXYGEN__)) 
 711                                 wchar_t  UnicodeString
[]; 
 713                                 uint16_t UnicodeString
[]; /**< String data, as unicode characters (alternatively, 
 714                                                            *   string language IDs). If normal ASCII characters are 
 715                                                            *   to be used, they must be added as an array of characters 
 716                                                            *   rather than a normal C string so that they are widened to 
 719                                                            *   Under GCC, strings prefixed with the "L" character (before 
 720                                                            *   the opening string quotation mark) are considered to be 
 721                                                            *   Unicode strings, and may be used instead of an explicit 
 722                                                            *   array of ASCII characters on little endian devices with 
 723                                                            *   UTF-16-LE \c wchar_t encoding. 
 726                         } ATTR_PACKED USB_Descriptor_String_t
; 
 728                         /** \brief Standard USB String Descriptor (USB-IF naming conventions). 
 730                          *  Type define for a standard string descriptor. Unlike other standard descriptors, the length 
 731                          *  of the descriptor for placement in the descriptor header must be determined by the \ref USB_STRING_LEN() 
 732                          *  macro rather than by the size of the descriptor structure, as the length is not fixed. 
 734                          *  This structure should also be used for string index 0, which contains the supported language IDs for 
 735                          *  the device as an array. 
 737                          *  This structure uses the relevant standard's given element names to ensure compatibility with the standard. 
 739                          *  \see \ref USB_Descriptor_String_t for the version of this type with with non-standard LUFA specific 
 742                          *  \note Regardless of CPU architecture, these values should be stored as little endian. 
 746                                 uint8_t bLength
; /**< Size of the descriptor, in bytes. */ 
 747                                 uint8_t bDescriptorType
; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t 
 748                                                           *   or a value given by the specific class. 
 750                                 uint16_t bString
[]; /**< String data, as unicode characters (alternatively, string language IDs). 
 751                                                      *   If normal ASCII characters are to be used, they must be added as an array 
 752                                                      *   of characters rather than a normal C string so that they are widened to 
 755                                                      *   Under GCC, strings prefixed with the "L" character (before the opening string 
 756                                                      *   quotation mark) are considered to be Unicode strings, and may be used instead 
 757                                                      *   of an explicit array of ASCII characters. 
 759                         } ATTR_PACKED USB_StdDescriptor_String_t
; 
 762         /* Disable C linkage for C++ Compilers: */ 
 763                 #if defined(__cplusplus)