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