Statistics
| Branch: | Tag: | Revision:

root / LUFA / Drivers / USB / Core / StdDescriptors.h @ 978b99e5

History | View | Annotate | Download (39.3 KB)

1
/*
2
             LUFA Library
3
     Copyright (C) Dean Camera, 2011.
4

5
  dean [at] fourwalledcubicle [dot] com
6
           www.lufa-lib.org
7
*/
8

    
9
/*
10
  Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com)
11

12
  Permission to use, copy, modify, distribute, and sell this
13
  software and its documentation for any purpose is hereby granted
14
  without fee, provided that the above copyright notice appear in
15
  all copies and that both that the copyright notice and this
16
  permission notice and warranty disclaimer appear in supporting
17
  documentation, and that the name of the author not be used in
18
  advertising or publicity pertaining to distribution of the
19
  software without specific, written prior permission.
20

21
  The author disclaim all warranties with regard to this
22
  software, including all implied warranties of merchantability
23
  and fitness.  In no event shall the author be liable for any
24
  special, indirect or consequential damages or any damages
25
  whatsoever resulting from loss of use, data or profits, whether
26
  in an action of contract, negligence or other tortious action,
27
  arising out of or in connection with the use or performance of
28
  this software.
29
*/
30

    
31
/** \file
32
 *  \brief Common standard USB Descriptor definitions for all architectures.
33
 *  \copydetails Group_StdDescriptors
34
 *
35
 *  \note This file should not be included directly. It is automatically included as needed by the USB driver
36
 *        dispatch header located in LUFA/Drivers/USB/USB.h.
37
 */
38

    
39
/** \ingroup Group_USB
40
 *  \defgroup Group_StdDescriptors USB Descriptors
41
 *  \brief Standard USB Descriptor definitions.
42
 *
43
 *  Standard USB device descriptor defines and retrieval routines, for USB devices. This module contains
44
 *  structures and macros for the easy creation of standard USB descriptors in USB device projects.
45
 *
46
 *  @{
47
 */
48

    
49
#ifndef __USBDESCRIPTORS_H__
50
#define __USBDESCRIPTORS_H__
51

    
52
        /* Includes: */
53
                #include "../../../Common/Common.h"
54
                #include "USBMode.h"
55
                #include "Events.h"
56

    
57
        /* Enable C linkage for C++ Compilers: */
58
                #if defined(__cplusplus)
59
                        extern "C" {
60
                #endif
61

    
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.
65
                #endif
66

    
67
        /* Public Interface - May be used in end-application: */
68
                /* Macros: */
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.
72
                         */
73
                        #define NO_DESCRIPTOR                     0
74

    
75
                        /** Macro to calculate the power value for the configuration descriptor, from a given number of milliamperes.
76
                         *
77
                         *  \param[in] mA  Maximum number of milliamps the device consumes when the given configuration is selected.
78
                         */
79
                        #define USB_CONFIG_POWER_MA(mA)           ((mA) >> 1)
80

    
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.
83
                         *
84
                         *  \param[in] UnicodeChars  Number of Unicode characters in the string text.
85
                         */
86
                        #define USB_STRING_LEN(UnicodeChars)      (sizeof(USB_Descriptor_Header_t) + ((UnicodeChars) << 1))
87

    
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.
91
                         *
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.
94
                         *
95
                         *  \param[in]  x  Version number to encode as a 16-bit little-endian number, as a floating point number.
96
                         */
97
                        #define VERSION_BCD(x)                    CPU_TO_LE16((((VERSION_TENS(x) << 4) | VERSION_ONES(x)) << 8) | \
98
                                                                  ((VERSION_TENTHS(x) << 4) | VERSION_HUNDREDTHS(x)))
99

    
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.
102
                         */
103
                        #define LANGUAGE_ID_ENG                   0x0409
104

    
105
                        /** \name USB Configuration Descriptor Attribute Masks */
106
                        //@{
107
                        /** Can be masked with other configuration descriptor attributes for a \ref USB_Descriptor_Configuration_Header_t
108
                         *  descriptor's ConfigAttributes value to indicate that the specified configuration can draw its power
109
                         *  from the host's VBUS line.
110
                         */
111
                        #define USB_CONFIG_ATTR_BUSPOWERED        0x80
112

    
113
                        /** Can be masked with other configuration descriptor attributes for a \ref USB_Descriptor_Configuration_Header_t
114
                         *  descriptor's ConfigAttributes value to indicate that the specified configuration can draw its power
115
                         *  from the device's own power source.
116
                         */
117
                        #define USB_CONFIG_ATTR_SELFPOWERED       0x40
118

    
119
                        /** Can be masked with other configuration descriptor attributes for a \ref USB_Descriptor_Configuration_Header_t
120
                         *  descriptor's ConfigAttributes value to indicate that the specified configuration supports the
121
                         *  remote wakeup feature of the USB standard, allowing a suspended USB device to wake up the host upon
122
                         *  request.
123
                         */
124
                        #define USB_CONFIG_ATTR_REMOTEWAKEUP      0x20
125
                        //@}
126
                        
127
                        /** \name Endpoint Descriptor Attribute Masks */
128
                        //@{
129
                        /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
130
                         *  Attributes value to indicate that the specified endpoint is not synchronized.
131
                         *
132
                         *  \see The USB specification for more details on the possible Endpoint attributes.
133
                         */
134
                        #define ENDPOINT_ATTR_NO_SYNC             (0 << 2)
135

    
136
                        /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
137
                         *  Attributes value to indicate that the specified endpoint is asynchronous.
138
                         *
139
                         *  \see The USB specification for more details on the possible Endpoint attributes.
140
                         */
141
                        #define ENDPOINT_ATTR_ASYNC               (1 << 2)
142

    
143
                        /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
144
                         *  Attributes value to indicate that the specified endpoint is adaptive.
145
                         *
146
                         *  \see The USB specification for more details on the possible Endpoint attributes.
147
                         */
148
                        #define ENDPOINT_ATTR_ADAPTIVE            (2 << 2)
149

    
150
                        /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
151
                         *  Attributes value to indicate that the specified endpoint is synchronized.
152
                         *
153
                         *  \see The USB specification for more details on the possible Endpoint attributes.
154
                         */
155
                        #define ENDPOINT_ATTR_SYNC                (3 << 2)
156
                        //@}
157
                        
158
                        /** \name Endpoint Descriptor Usage Masks */
159
                        //@{
160
                        /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
161
                         *  Attributes value to indicate that the specified endpoint is used for data transfers.
162
                         *
163
                         *  \see The USB specification for more details on the possible Endpoint usage attributes.
164
                         */
165
                        #define ENDPOINT_USAGE_DATA               (0 << 4)
166

    
167
                        /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
168
                         *  Attributes value to indicate that the specified endpoint is used for feedback.
169
                         *
170
                         *  \see The USB specification for more details on the possible Endpoint usage attributes.
171
                         */
172
                        #define ENDPOINT_USAGE_FEEDBACK           (1 << 4)
173

    
174
                        /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's
175
                         *  Attributes value to indicate that the specified endpoint is used for implicit feedback.
176
                         *
177
                         *  \see The USB specification for more details on the possible Endpoint usage attributes.
178
                         */
179
                        #define ENDPOINT_USAGE_IMPLICIT_FEEDBACK  (2 << 4)
180
                        //@}
181
                        
182
                /* Enums: */
183
                        /** Enum for the possible standard descriptor types, as given in each descriptor's header. */
184
                        enum USB_DescriptorTypes_t
185
                        {
186
                                DTYPE_Device                    = 0x01, /**< Indicates that the descriptor is a device descriptor. */
187
                                DTYPE_Configuration             = 0x02, /**< Indicates that the descriptor is a configuration descriptor. */
188
                                DTYPE_String                    = 0x03, /**< Indicates that the descriptor is a string descriptor. */
189
                                DTYPE_Interface                 = 0x04, /**< Indicates that the descriptor is an interface descriptor. */
190
                                DTYPE_Endpoint                  = 0x05, /**< Indicates that the descriptor is an endpoint descriptor. */
191
                                DTYPE_DeviceQualifier           = 0x06, /**< Indicates that the descriptor is a device qualifier descriptor. */
192
                                DTYPE_Other                     = 0x07, /**< Indicates that the descriptor is of other type. */
193
                                DTYPE_InterfacePower            = 0x08, /**< Indicates that the descriptor is an interface power descriptor. */
194
                                DTYPE_InterfaceAssociation      = 0x0B, /**< Indicates that the descriptor is an interface association descriptor. */
195
                                DTYPE_CSInterface               = 0x24, /**< Indicates that the descriptor is a class specific interface descriptor. */
196
                                DTYPE_CSEndpoint                = 0x25, /**< Indicates that the descriptor is a class specific endpoint descriptor. */
197
                        };
198

    
199
                        /** Enum for possible Class, Subclass and Protocol values of device and interface descriptors. */
200
                        enum USB_Descriptor_ClassSubclassProtocol_t
201
                        {
202
                                USB_CSCP_NoDeviceClass          = 0x00, /**< Descriptor Class value indicating that the device does not belong
203
                                                                         *   to a particular class at the device level.
204
                                                                         */
205
                                USB_CSCP_NoDeviceSubclass       = 0x00, /**< Descriptor Subclass value indicating that the device does not belong
206
                                                                         *   to a particular subclass at the device level.
207
                                                                         */
208
                                USB_CSCP_NoDeviceProtocol       = 0x00, /**< Descriptor Protocol value indicating that the device does not belong
209
                                                                         *   to a particular protocol at the device level.
210
                                                                         */
211
                                USB_CSCP_VendorSpecificClass    = 0xFF, /**< Descriptor Class value indicating that the device/interface belongs
212
                                                                         *   to a vendor specific class.
213
                                                                         */
214
                                USB_CSCP_VendorSpecificSubclass = 0xFF, /**< Descriptor Subclass value indicating that the device/interface belongs
215
                                                                         *   to a vendor specific subclass.
216
                                                                         */
217
                                USB_CSCP_VendorSpecificProtocol = 0xFF, /**< Descriptor Protocol value indicating that the device/interface belongs
218
                                                                         *   to a vendor specific protocol.
219
                                                                         */
220
                                USB_CSCP_IADDeviceClass         = 0xEF, /**< Descriptor Class value indicating that the device belongs to the
221
                                                                         *   Interface Association Descriptor class.
222
                                                                         */
223
                                USB_CSCP_IADDeviceSubclass      = 0x02, /**< Descriptor Subclass value indicating that the device belongs to the
224
                                                                         *   Interface Association Descriptor subclass.
225
                                                                         */
226
                                USB_CSCP_IADDeviceProtocol      = 0x01, /**< Descriptor Protocol value indicating that the device belongs to the
227
                                                                         *   Interface Association Descriptor protocol.
228
                                                                         */
229
                        };
230

    
231
                /* Type Defines: */
232
                        /** \brief Standard USB Descriptor Header (LUFA naming conventions).
233
                         *
234
             *  Type define for all descriptors' standard header, indicating the descriptor's length and type. This structure
235
                         *  uses LUFA-specific element names to make each element's purpose clearer.
236
                         *
237
                         *  \see \ref USB_StdDescriptor_Header_t for the version of this type with standard element names.
238
                         *
239
                         *  \note Regardless of CPU architecture, these values should be stored as little endian.
240
                         */
241
                        typedef struct
242
                        {
243
                                uint8_t Size; /**< Size of the descriptor, in bytes. */
244
                                uint8_t Type; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
245
                                               *   given by the specific class.
246
                                               */
247
                        } ATTR_PACKED USB_Descriptor_Header_t;
248

    
249
                        /** \brief Standard USB Descriptor Header (USB-IF naming conventions).
250
                         *
251
                         *  Type define for all descriptors' standard header, indicating the descriptor's length and type. This structure
252
                         *  uses the relevant standard's given element names to ensure compatibility with the standard.
253
                         *
254
                         *  \see \ref USB_Descriptor_Header_t for the version of this type with non-standard LUFA specific element names.
255
                         *
256
                         *  \note Regardless of CPU architecture, these values should be stored as little endian.
257
                         */
258
                        typedef struct
259
                        {
260
                                uint8_t bLength; /**< Size of the descriptor, in bytes. */
261
                                uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
262
                                                          *   given by the specific class.
263
                                                          */
264
                        } ATTR_PACKED USB_StdDescriptor_Header_t;
265

    
266
                        /** \brief Standard USB Device Descriptor (LUFA naming conventions).
267
                         *
268
                         *  Type define for a standard Device Descriptor. This structure uses LUFA-specific element names to make each
269
                         *  element's purpose clearer.
270
                         *
271
                         *  \see \ref USB_StdDescriptor_Device_t for the version of this type with standard element names.
272
                         *
273
                         *  \note Regardless of CPU architecture, these values should be stored as little endian.
274
                         */
275
                        typedef struct
276
                        {
277
                                USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */
278

    
279
                                uint16_t USBSpecification; /**< BCD of the supported USB specification. */
280
                                uint8_t  Class; /**< USB device class. */
281
                                uint8_t  SubClass; /**< USB device subclass. */
282
                                uint8_t  Protocol; /**< USB device protocol. */
283

    
284
                                uint8_t  Endpoint0Size; /**< Size of the control (address 0) endpoint's bank in bytes. */
285

    
286
                                uint16_t VendorID; /**< Vendor ID for the USB product. */
287
                                uint16_t ProductID; /**< Unique product ID for the USB product. */
288
                                uint16_t ReleaseNumber; /**< Product release (version) number. */
289

    
290
                                uint8_t  ManufacturerStrIndex; /**< String index for the manufacturer's name. The
291
                                                                *   host will request this string via a separate
292
                                                                *   control request for the string descriptor.
293
                                                                *
294
                                                                *   \note If no string supplied, use \ref NO_DESCRIPTOR.
295
                                                                */
296
                                uint8_t  ProductStrIndex; /**< String index for the product name/details.
297
                                                           *
298
                                                           *  \see ManufacturerStrIndex structure entry.
299
                                                           */
300
                                uint8_t  SerialNumStrIndex; /**< String index for the product's globally unique hexadecimal
301
                                                             *   serial number, in uppercase Unicode ASCII.
302
                                                             *
303
                                                             *  \note On some microcontroller models, there is an embedded serial number
304
                                                             *        in the chip which can be used for the device serial number.
305
                                                             *        To use this serial number, set this to USE_INTERNAL_SERIAL.
306
                                                             *        On unsupported devices, this will evaluate to 0 and will cause
307
                                                             *        the host to generate a pseudo-unique value for the device upon
308
                                                             *        insertion.
309
                                                             *
310
                                                             *  \see ManufacturerStrIndex structure entry.
311
                                                             */
312
                                uint8_t  NumberOfConfigurations; /**< Total number of configurations supported by
313
                                                                  *   the device.
314
                                                                  */
315
                        } ATTR_PACKED USB_Descriptor_Device_t;
316

    
317
                        /** \brief Standard USB Device Descriptor (USB-IF naming conventions).
318
                         *
319
                         *  Type define for a standard Device Descriptor. This structure uses the relevant standard's given element names
320
                         *  to ensure compatibility with the standard.
321
                         *
322
                         *  \see \ref USB_Descriptor_Device_t for the version of this type with non-standard LUFA specific element names.
323
                         *
324
                         *  \note Regardless of CPU architecture, these values should be stored as little endian.
325
                         */
326
                        typedef struct
327
                        {
328
                                uint8_t  bLength; /**< Size of the descriptor, in bytes. */
329
                                uint8_t  bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
330
                                                              *   given by the specific class.
331
                                                              */
332
                                uint16_t bcdUSB; /**< BCD of the supported USB specification. */
333
                                uint8_t  bDeviceClass; /**< USB device class. */
334
                                uint8_t  bDeviceSubClass; /**< USB device subclass. */
335
                                uint8_t  bDeviceProtocol; /**< USB device protocol. */
336
                                uint8_t  bMaxPacketSize0; /**< Size of the control (address 0) endpoint's bank in bytes. */
337
                                uint16_t idVendor; /**< Vendor ID for the USB product. */
338
                                uint16_t idProduct; /**< Unique product ID for the USB product. */
339
                                uint16_t bcdDevice; /**< Product release (version) number. */
340
                                uint8_t  iManufacturer; /**< String index for the manufacturer's name. The
341
                                                         *   host will request this string via a separate
342
                                                         *   control request for the string descriptor.
343
                                                         *
344
                                                         *   \note If no string supplied, use \ref NO_DESCRIPTOR.
345
                                                         */
346
                                uint8_t  iProduct; /**< String index for the product name/details.
347
                                                    *
348
                                                    *  \see ManufacturerStrIndex structure entry.
349
                                                    */
350
                                uint8_t iSerialNumber; /**< String index for the product's globally unique hexadecimal
351
                                                        *   serial number, in uppercase Unicode ASCII.
352
                                                        *
353
                                                        *  \note On some microcontroller models, there is an embedded serial number
354
                                                        *        in the chip which can be used for the device serial number.
355
                                                        *        To use this serial number, set this to USE_INTERNAL_SERIAL.
356
                                                        *        On unsupported devices, this will evaluate to 0 and will cause
357
                                                        *        the host to generate a pseudo-unique value for the device upon
358
                                                        *        insertion.
359
                                                        *
360
                                                        *  \see ManufacturerStrIndex structure entry.
361
                                                        */
362
                                uint8_t  bNumConfigurations; /**< Total number of configurations supported by
363
                                                              *   the device.
364
                                                              */
365
                        } ATTR_PACKED USB_StdDescriptor_Device_t;
366

    
367
                        /** \brief Standard USB Device Qualifier Descriptor (LUFA naming conventions).
368
                         *
369
                         *  Type define for a standard Device Qualifier Descriptor. This structure uses LUFA-specific element names
370
                         *  to make each element's purpose clearer.
371
                         *
372
                         *  \see \ref USB_StdDescriptor_DeviceQualifier_t for the version of this type with standard element names.
373
                         */
374
                        typedef struct
375
                        {
376
                                USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */
377

    
378
                                uint16_t USBSpecification; /**< BCD of the supported USB specification. */
379
                                uint8_t  Class; /**< USB device class. */
380
                                uint8_t  SubClass; /**< USB device subclass. */
381
                                uint8_t  Protocol; /**< USB device protocol. */
382

    
383
                                uint8_t  Endpoint0Size; /**< Size of the control (address 0) endpoint's bank in bytes. */
384
                                uint8_t  NumberOfConfigurations; /**< Total number of configurations supported by
385
                                                                  *   the device.
386
                                                                  */
387
                                uint8_t  Reserved; /**< Reserved for future use, must be 0. */
388
                        } ATTR_PACKED USB_Descriptor_DeviceQualifier_t;
389

    
390
                        /** \brief Standard USB Device Qualifier Descriptor (USB-IF naming conventions).
391
                         *
392
                         *  Type define for a standard Device Qualifier Descriptor. This structure uses the relevant standard's given element names
393
                         *  to ensure compatibility with the standard.
394
                         *
395
                         *  \see \ref USB_Descriptor_DeviceQualifier_t for the version of this type with non-standard LUFA specific element names.
396
                         */
397
                        typedef struct
398
                        {
399
                                uint8_t  bLength; /**< Size of the descriptor, in bytes. */
400
                                uint8_t  bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
401
                                                              *   given by the specific class.
402
                                                              */
403
                                uint16_t bcdUSB; /**< BCD of the supported USB specification. */
404
                                uint8_t  bDeviceClass; /**< USB device class. */
405
                                uint8_t  bDeviceSubClass; /**< USB device subclass. */
406
                                uint8_t  bDeviceProtocol; /**< USB device protocol. */
407
                                uint8_t  bMaxPacketSize0; /**< Size of the control (address 0) endpoint's bank in bytes. */
408
                                uint8_t  bNumConfigurations; /**< Total number of configurations supported by
409
                                                              *   the device.
410
                                                              */
411
                                uint8_t  bReserved; /**< Reserved for future use, must be 0. */
412
                        } ATTR_PACKED USB_StdDescriptor_DeviceQualifier_t;
413

    
414
                        /** \brief Standard USB Configuration Descriptor (LUFA naming conventions).
415
                         *
416
                         *  Type define for a standard Configuration Descriptor header. This structure uses LUFA-specific element names
417
                         *  to make each element's purpose clearer.
418
                         *
419
                         *  \see \ref USB_StdDescriptor_Configuration_Header_t for the version of this type with standard element names.
420
                         *
421
                         *  \note Regardless of CPU architecture, these values should be stored as little endian.
422
                         */
423
                        typedef struct
424
                        {
425
                                USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */
426

    
427
                                uint16_t TotalConfigurationSize; /**< Size of the configuration descriptor header,
428
                                                                  *   and all sub descriptors inside the configuration.
429
                                                                  */
430
                                uint8_t  TotalInterfaces; /**< Total number of interfaces in the configuration. */
431

    
432
                                uint8_t  ConfigurationNumber; /**< Configuration index of the current configuration. */
433
                                uint8_t  ConfigurationStrIndex; /**< Index of a string descriptor describing the configuration. */
434

    
435
                                uint8_t  ConfigAttributes; /**< Configuration attributes, comprised of a mask of zero or
436
                                                            *   more USB_CONFIG_ATTR_* masks.
437
                                                            */
438

    
439
                                uint8_t  MaxPowerConsumption; /**< Maximum power consumption of the device while in the
440
                                                               *   current configuration, calculated by the \ref USB_CONFIG_POWER_MA()
441
                                                               *   macro.
442
                                                               */
443
                        } ATTR_PACKED USB_Descriptor_Configuration_Header_t;
444

    
445
                        /** \brief Standard USB Configuration Descriptor (USB-IF naming conventions).
446
                         *
447
                         *  Type define for a standard Configuration Descriptor header. This structure uses the relevant standard's given element names
448
                         *  to ensure compatibility with the standard.
449
                         *
450
                         *  \see \ref USB_Descriptor_Device_t for the version of this type with non-standard LUFA specific element names.
451
                         *
452
                         *  \note Regardless of CPU architecture, these values should be stored as little endian.
453
                         */
454
                        typedef struct
455
                        {
456
                                uint8_t  bLength; /**< Size of the descriptor, in bytes. */
457
                                uint8_t  bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
458
                                                              *   given by the specific class.
459
                                                              */
460
                                uint16_t wTotalLength; /**< Size of the configuration descriptor header,
461
                                                           *   and all sub descriptors inside the configuration.
462
                                                           */
463
                                uint8_t  bNumInterfaces; /**< Total number of interfaces in the configuration. */
464
                                uint8_t  bConfigurationValue; /**< Configuration index of the current configuration. */
465
                                uint8_t  iConfiguration; /**< Index of a string descriptor describing the configuration. */
466
                                uint8_t  bmAttributes; /**< Configuration attributes, comprised of a mask of zero or
467
                                                        *   more USB_CONFIG_ATTR_* masks.
468
                                                        */
469
                                uint8_t  bMaxPower; /**< Maximum power consumption of the device while in the
470
                                                     *   current configuration, calculated by the \ref USB_CONFIG_POWER_MA()
471
                                                     *   macro.
472
                                                     */
473
                        } ATTR_PACKED USB_StdDescriptor_Configuration_Header_t;
474

    
475
                        /** \brief Standard USB Interface Descriptor (LUFA naming conventions).
476
                         *
477
                         *  Type define for a standard Interface Descriptor. This structure uses LUFA-specific element names
478
                         *  to make each element's purpose clearer.
479
                         *
480
                         *  \see \ref USB_StdDescriptor_Interface_t for the version of this type with standard element names.
481
                         *
482
                         *  \note Regardless of CPU architecture, these values should be stored as little endian.
483
                         */
484
                        typedef struct
485
                        {
486
                                USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */
487

    
488
                                uint8_t InterfaceNumber; /**< Index of the interface in the current configuration. */
489
                                uint8_t AlternateSetting; /**< Alternate setting for the interface number. The same
490
                                                           *   interface number can have multiple alternate settings
491
                                                           *   with different endpoint configurations, which can be
492
                                                           *   selected by the host.
493
                                                           */
494
                                uint8_t TotalEndpoints; /**< Total number of endpoints in the interface. */
495

    
496
                                uint8_t Class; /**< Interface class ID. */
497
                                uint8_t SubClass; /**< Interface subclass ID. */
498
                                uint8_t Protocol; /**< Interface protocol ID. */
499

    
500
                                uint8_t InterfaceStrIndex; /**< Index of the string descriptor describing the interface. */
501
                        } ATTR_PACKED USB_Descriptor_Interface_t;
502

    
503
                        /** \brief Standard USB Interface Descriptor (USB-IF naming conventions).
504
                         *
505
                         *  Type define for a standard Interface Descriptor. This structure uses the relevant standard's given element names
506
                         *  to ensure compatibility with the standard.
507
                         *
508
                         *  \see \ref USB_Descriptor_Interface_t for the version of this type with non-standard LUFA specific element names.
509
                         *
510
                         *  \note Regardless of CPU architecture, these values should be stored as little endian.
511
                         */
512
                        typedef struct
513
                        {
514
                                uint8_t bLength; /**< Size of the descriptor, in bytes. */
515
                                uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
516
                                                          *   given by the specific class.
517
                                                          */
518
                                uint8_t bInterfaceNumber; /**< Index of the interface in the current configuration. */
519
                                uint8_t bAlternateSetting; /**< Alternate setting for the interface number. The same
520
                                                            *   interface number can have multiple alternate settings
521
                                                            *   with different endpoint configurations, which can be
522
                                                            *   selected by the host.
523
                                                            */
524
                                uint8_t bNumEndpoints; /**< Total number of endpoints in the interface. */
525
                                uint8_t bInterfaceClass; /**< Interface class ID. */
526
                                uint8_t bInterfaceSubClass; /**< Interface subclass ID. */
527
                                uint8_t bInterfaceProtocol; /**< Interface protocol ID. */
528
                                uint8_t iInterface; /**< Index of the string descriptor describing the
529
                                                     *   interface.
530
                                                     */
531
                        } ATTR_PACKED USB_StdDescriptor_Interface_t;
532

    
533
                        /** \brief Standard USB Interface Association Descriptor (LUFA naming conventions).
534
                         *
535
                         *  Type define for a standard Interface Association Descriptor. This structure uses LUFA-specific element names
536
                         *  to make each element's purpose clearer.
537
                         *
538
                         *  This descriptor has been added as a supplement to the USB2.0 standard, in the ECN located at
539
                         *  <a>http://www.usb.org/developers/docs/InterfaceAssociationDescriptor_ecn.pdf</a>. It allows composite
540
                         *  devices with multiple interfaces related to the same function to have the multiple interfaces bound
541
                         *  together at the point of enumeration, loading one generic driver for all the interfaces in the single
542
                         *  function. Read the ECN for more information.
543
                         *
544
                         *  \see \ref USB_StdDescriptor_Interface_Association_t for the version of this type with standard element names.
545
                         *
546
                         *  \note Regardless of CPU architecture, these values should be stored as little endian.
547
                         */
548
                        typedef struct
549
                        {
550
                                USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */
551

    
552
                                uint8_t FirstInterfaceIndex; /**< Index of the first associated interface. */
553
                                uint8_t TotalInterfaces; /**< Total number of associated interfaces. */
554

    
555
                                uint8_t Class; /**< Interface class ID. */
556
                                uint8_t SubClass; /**< Interface subclass ID. */
557
                                uint8_t Protocol; /**< Interface protocol ID. */
558

    
559
                                uint8_t IADStrIndex; /**< Index of the string descriptor describing the
560
                                                      *   interface association.
561
                                                      */
562
                        } ATTR_PACKED USB_Descriptor_Interface_Association_t;
563

    
564
                        /** \brief Standard USB Interface Association Descriptor (USB-IF naming conventions).
565
                         *
566
                         *  Type define for a standard Interface Association Descriptor. This structure uses the relevant standard's given
567
                         *  element names to ensure compatibility with the standard.
568
                         *
569
                         *  This descriptor has been added as a supplement to the USB2.0 standard, in the ECN located at
570
                         *  <a>http://www.usb.org/developers/docs/InterfaceAssociationDescriptor_ecn.pdf</a>. It allows composite
571
                         *  devices with multiple interfaces related to the same function to have the multiple interfaces bound
572
                         *  together at the point of enumeration, loading one generic driver for all the interfaces in the single
573
                         *  function. Read the ECN for more information.
574
                         *
575
                         *  \see \ref USB_Descriptor_Interface_Association_t for the version of this type with non-standard LUFA specific
576
                         *       element names.
577
                         *
578
                         *  \note Regardless of CPU architecture, these values should be stored as little endian.
579
                         */
580
                        typedef struct
581
                        {
582
                                uint8_t bLength; /**< Size of the descriptor, in bytes. */
583
                                uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
584
                                                          *   given by the specific class.
585
                                                          */
586
                                uint8_t bFirstInterface; /**< Index of the first associated interface. */
587
                                uint8_t bInterfaceCount; /**< Total number of associated interfaces. */
588
                                uint8_t bFunctionClass; /**< Interface class ID. */
589
                                uint8_t bFunctionSubClass; /**< Interface subclass ID. */
590
                                uint8_t bFunctionProtocol; /**< Interface protocol ID. */
591
                                uint8_t iFunction; /**< Index of the string descriptor describing the
592
                                                    *   interface association.
593
                                                    */
594
                        } ATTR_PACKED USB_StdDescriptor_Interface_Association_t;
595

    
596
                        /** \brief Standard USB Endpoint Descriptor (LUFA naming conventions).
597
                         *
598
                         *  Type define for a standard Endpoint Descriptor. This structure uses LUFA-specific element names
599
                         *  to make each element's purpose clearer.
600
                         *
601
                         *  \see \ref USB_StdDescriptor_Endpoint_t for the version of this type with standard element names.
602
                         *
603
                         *  \note Regardless of CPU architecture, these values should be stored as little endian.
604
                         */
605
                        typedef struct
606
                        {
607
                                USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */
608

    
609
                                uint8_t  EndpointAddress; /**< Logical address of the endpoint within the device for the current
610
                                                           *   configuration, including direction mask.
611
                                                           */
612
                                uint8_t  Attributes; /**< Endpoint attributes, comprised of a mask of the endpoint type (EP_TYPE_*)
613
                                                      *   and attributes (ENDPOINT_ATTR_*) masks.
614
                                                      */
615
                                uint16_t EndpointSize; /**< Size of the endpoint bank, in bytes. This indicates the maximum packet
616
                                                        *   size that the endpoint can receive at a time.
617
                                                        */
618
                                uint8_t  PollingIntervalMS; /**< Polling interval in milliseconds for the endpoint if it is an INTERRUPT
619
                                                             *   or ISOCHRONOUS type.
620
                                                             */
621
                        } ATTR_PACKED USB_Descriptor_Endpoint_t;
622

    
623
                        /** \brief Standard USB Endpoint Descriptor (USB-IF naming conventions).
624
                         *
625
                         *  Type define for a standard Endpoint Descriptor. This structure uses the relevant standard's given
626
                         *  element names to ensure compatibility with the standard.
627
                         *
628
                         *  \see \ref USB_Descriptor_Endpoint_t for the version of this type with non-standard LUFA specific
629
                         *       element names.
630
                         *
631
                         *  \note Regardless of CPU architecture, these values should be stored as little endian.
632
                         */
633
                        typedef struct
634
                        {
635
                                uint8_t  bLength; /**< Size of the descriptor, in bytes. */
636
                                uint8_t  bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a
637
                                                           *   value given by the specific class.
638
                                                           */
639
                                uint8_t  bEndpointAddress; /**< Logical address of the endpoint within the device for the current
640
                                                            *   configuration, including direction mask.
641
                                                            */
642
                                uint8_t  bmAttributes; /**< Endpoint attributes, comprised of a mask of the endpoint type (EP_TYPE_*)
643
                                                        *   and attributes (ENDPOINT_ATTR_*) masks.
644
                                                        */
645
                                uint16_t wMaxPacketSize; /**< Size of the endpoint bank, in bytes. This indicates the maximum packet size
646
                                                          *   that the endpoint can receive at a time.
647
                                                          */
648
                                uint8_t  bInterval; /**< Polling interval in milliseconds for the endpoint if it is an INTERRUPT or
649
                                                     *   ISOCHRONOUS type.
650
                                                     */
651
                        } ATTR_PACKED USB_StdDescriptor_Endpoint_t;
652

    
653
                        /** \brief Standard USB String Descriptor (LUFA naming conventions).
654
                         *
655
                         *  Type define for a standard string descriptor. Unlike other standard descriptors, the length
656
                         *  of the descriptor for placement in the descriptor header must be determined by the \ref USB_STRING_LEN()
657
                         *  macro rather than by the size of the descriptor structure, as the length is not fixed.
658
                         *
659
                         *  This structure should also be used for string index 0, which contains the supported language IDs for
660
                         *  the device as an array.
661
                         *
662
                         *  This structure uses LUFA-specific element names to make each element's purpose clearer.
663
                         *
664
                         *  \see \ref USB_StdDescriptor_String_t for the version of this type with standard element names.
665
                         *
666
                         *  \note Regardless of CPU architecture, these values should be stored as little endian.
667
                         */
668
                        typedef struct
669
                        {
670
                                USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */
671

    
672
                                #if (((ARCH == ARCH_AVR8) || (ARCH == ARCH_XMEGA)) && !defined(__DOXYGEN__))
673
                                wchar_t  UnicodeString[];
674
                                #else
675
                                uint16_t UnicodeString[]; /**< String data, as unicode characters (alternatively,
676
                                                           *   string language IDs). If normal ASCII characters are
677
                                                           *   to be used, they must be added as an array of characters
678
                                                           *   rather than a normal C string so that they are widened to
679
                                                           *   Unicode size.
680
                                                           *
681
                                                           *   Under GCC, strings prefixed with the "L" character (before
682
                                                           *   the opening string quotation mark) are considered to be
683
                                                           *   Unicode strings, and may be used instead of an explicit
684
                                                           *   array of ASCII characters on little endian devices with
685
                                                           *   UTF-16-LE \c wchar_t encoding.
686
                                                           */
687
                                #endif
688
                        } ATTR_PACKED USB_Descriptor_String_t;
689

    
690
                        /** \brief Standard USB String Descriptor (USB-IF naming conventions).
691
                         *
692
                         *  Type define for a standard string descriptor. Unlike other standard descriptors, the length
693
                         *  of the descriptor for placement in the descriptor header must be determined by the \ref USB_STRING_LEN()
694
                         *  macro rather than by the size of the descriptor structure, as the length is not fixed.
695
                         *
696
                         *  This structure should also be used for string index 0, which contains the supported language IDs for
697
                         *  the device as an array.
698
                         *
699
                         *  This structure uses the relevant standard's given element names to ensure compatibility with the standard.
700
                         *
701
                         *  \see \ref USB_Descriptor_String_t for the version of this type with with non-standard LUFA specific
702
                         *       element names.
703
                         *
704
                         *  \note Regardless of CPU architecture, these values should be stored as little endian.
705
                         */
706
                        typedef struct
707
                        {
708
                                uint8_t bLength; /**< Size of the descriptor, in bytes. */
709
                                uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t
710
                                                          *   or a value given by the specific class.
711
                                                          */
712
                                uint16_t bString[]; /**< String data, as unicode characters (alternatively, string language IDs).
713
                                                     *   If normal ASCII characters are to be used, they must be added as an array
714
                                                     *   of characters rather than a normal C string so that they are widened to
715
                                                     *   Unicode size.
716
                                                     *
717
                                                     *   Under GCC, strings prefixed with the "L" character (before the opening string
718
                                                     *   quotation mark) are considered to be Unicode strings, and may be used instead
719
                                                     *   of an explicit array of ASCII characters.
720
                                                     */
721
                        } ATTR_PACKED USB_StdDescriptor_String_t;
722

    
723
        /* Private Interface - For use in library only: */
724
        #if !defined(__DOXYGEN__)
725
                /* Macros: */
726
                        #define VERSION_TENS(x)                   (int)((x) / 10)
727
                        #define VERSION_ONES(x)                   (int)((x) - (10 * VERSION_TENS(x)))
728
                        #define VERSION_TENTHS(x)                 (int)(((x) - (int)(x)) * 10)
729
                        #define VERSION_HUNDREDTHS(x)             (int)((((x) - (int)(x)) * 100) - (10 * VERSION_TENTHS(x)))
730
        #endif
731

    
732
        /* Disable C linkage for C++ Compilers: */
733
                #if defined(__cplusplus)
734
                        }
735
                #endif
736

    
737
#endif
738

    
739
/** @} */
740