2 * @brief Common standard USB Descriptor definitions for all architectures
\r
5 * Copyright(C) NXP Semiconductors, 2012
\r
6 * Copyright(C) Dean Camera, 2011, 2012
\r
7 * All rights reserved.
\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
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
34 /** @ingroup Group_USB
\r
35 * @defgroup Group_StdDescriptors USB Descriptors
\r
36 * @brief Standard USB Descriptor definitions.
\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
44 #ifndef __USBDESCRIPTORS_H__
\r
45 #define __USBDESCRIPTORS_H__
\r
48 #include "../../../Common/Common.h"
\r
49 #include "USBMode.h"
\r
52 /* Enable C linkage for C++ Compilers: */
\r
53 #if defined(__cplusplus)
\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
62 /* Public Interface - May be used in end-application: */
\r
65 /** Utility macro used in the formation of descriptors
\r
67 #define WBVAL(x) ((x) & 0xFF),(((x) >> 8) & 0xFF)
\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
73 #define NO_DESCRIPTOR 0
\r
75 /** Macro to calculate the power value for the configuration descriptor, from a given number of milliamperes.
\r
77 * @param mA Maximum number of milliamps the device consumes when the given configuration is selected.
\r
79 #define USB_CONFIG_POWER_MA(mA) ((mA) >> 1)
\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
84 * @param UnicodeChars Number of Unicode characters in the string text.
\r
86 #define USB_STRING_LEN(UnicodeChars) (sizeof(USB_Descriptor_Header_t) + ((UnicodeChars) << 1))
\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
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
95 * @param x Version number to encode as a 16-bit little-endian number, as a floating point number.
\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
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
103 #define LANGUAGE_ID_ENG 0x0409
\r
105 /** \name USB Configuration Descriptor Attribute Masks */
\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
111 #define USB_CONFIG_ATTR_BUSPOWERED 0x80
\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
117 #define USB_CONFIG_ATTR_SELFPOWERED 0x40
\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
124 #define USB_CONFIG_ATTR_REMOTEWAKEUP 0x20
\r
127 /** \name Endpoint Descriptor Attribute Masks */
\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
132 * @see The USB specification for more details on the possible Endpoint attributes.
\r
134 #define ENDPOINT_ATTR_NO_SYNC (0 << 2)
\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
139 * @see The USB specification for more details on the possible Endpoint attributes.
\r
141 #define ENDPOINT_ATTR_ASYNC (1 << 2)
\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
146 * @see The USB specification for more details on the possible Endpoint attributes.
\r
148 #define ENDPOINT_ATTR_ADAPTIVE (2 << 2)
\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
153 * @see The USB specification for more details on the possible Endpoint attributes.
\r
155 #define ENDPOINT_ATTR_SYNC (3 << 2)
\r
158 /** \name Endpoint Descriptor Usage Masks */
\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
163 * @see The USB specification for more details on the possible Endpoint usage attributes.
\r
165 #define ENDPOINT_USAGE_DATA (0 << 4)
\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
170 * @see The USB specification for more details on the possible Endpoint usage attributes.
\r
172 #define ENDPOINT_USAGE_FEEDBACK (1 << 4)
\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
177 * @see The USB specification for more details on the possible Endpoint usage attributes.
\r
179 #define ENDPOINT_USAGE_IMPLICIT_FEEDBACK (2 << 4)
\r
183 /** Enum for the possible standard descriptor types, as given in each descriptor's header. */
\r
184 enum USB_DescriptorTypes_t
\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
199 /** Enum for possible Class, Subclass and Protocol values of device and interface descriptors. */
\r
200 enum USB_Descriptor_ClassSubclassProtocol_t
\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
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
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
211 USB_CSCP_VendorSpecificClass = 0xFF, /**< Descriptor Class value indicating that the device/interface belongs
\r
212 * to a vendor specific class.
\r
214 USB_CSCP_VendorSpecificSubclass = 0xFF, /**< Descriptor Subclass value indicating that the device/interface belongs
\r
215 * to a vendor specific subclass.
\r
217 USB_CSCP_VendorSpecificProtocol = 0xFF, /**< Descriptor Protocol value indicating that the device/interface belongs
\r
218 * to a vendor specific protocol.
\r
220 USB_CSCP_IADDeviceClass = 0xEF, /**< Descriptor Class value indicating that the device belongs to the
\r
221 * Interface Association Descriptor class.
\r
223 USB_CSCP_IADDeviceSubclass = 0x02, /**< Descriptor Subclass value indicating that the device belongs to the
\r
224 * Interface Association Descriptor subclass.
\r
226 USB_CSCP_IADDeviceProtocol = 0x01, /**< Descriptor Protocol value indicating that the device belongs to the
\r
227 * Interface Association Descriptor protocol.
\r
231 /* Type Defines: */
\r
232 /** @brief Standard USB Descriptor Header (LPCUSBlib naming conventions).
\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
237 * @see @ref USB_StdDescriptor_Header_t for the version of this type with standard element names.
\r
239 * @note Regardless of CPU architecture, these values should be stored as little endian.
\r
241 typedef ATTR_IAR_PACKED struct
\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
247 } ATTR_PACKED USB_Descriptor_Header_t;
\r
249 /** @brief Standard USB Descriptor Header (USB-IF naming conventions).
\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
254 * @see @ref USB_Descriptor_Header_t for the version of this type with non-standard LPCUSBlib specific element names.
\r
256 * @note Regardless of CPU architecture, these values should be stored as little endian.
\r
258 typedef ATTR_IAR_PACKED struct
\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
264 } ATTR_PACKED USB_StdDescriptor_Header_t;
\r
266 /** @brief Standard USB Device Descriptor (LPCUSBlib naming conventions).
\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
271 * @see @ref USB_StdDescriptor_Device_t for the version of this type with standard element names.
\r
273 * @note Regardless of CPU architecture, these values should be stored as little endian.
\r
275 typedef ATTR_IAR_PACKED struct
\r
277 USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */
\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
284 uint8_t Endpoint0Size; /**< Size of the control (address 0) endpoint's bank in bytes. */
\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
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
294 * @note If no string supplied, use @ref NO_DESCRIPTOR.
\r
296 uint8_t ProductStrIndex; /**< String index for the product name/details.
\r
298 * @see ManufacturerStrIndex structure entry.
\r
300 uint8_t SerialNumStrIndex; /**< String index for the product's globally unique hexadecimal
\r
301 * serial number, in uppercase Unicode ASCII.
\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
310 * @see ManufacturerStrIndex structure entry.
\r
312 uint8_t NumberOfConfigurations; /**< Total number of configurations supported by
\r
315 } ATTR_PACKED USB_Descriptor_Device_t;
\r
317 /** @brief Standard USB Device Descriptor (USB-IF naming conventions).
\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
322 * @see @ref USB_Descriptor_Device_t for the version of this type with non-standard LPCUSBlib specific element names.
\r
324 * @note Regardless of CPU architecture, these values should be stored as little endian.
\r
326 typedef ATTR_IAR_PACKED struct
\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
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
344 * @note If no string supplied, use @ref NO_DESCRIPTOR.
\r
346 uint8_t iProduct; /**< String index for the product name/details.
\r
348 * @see ManufacturerStrIndex structure entry.
\r
350 uint8_t iSerialNumber; /**< String index for the product's globally unique hexadecimal
\r
351 * serial number, in uppercase Unicode ASCII.
\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
360 * @see ManufacturerStrIndex structure entry.
\r
362 uint8_t bNumConfigurations; /**< Total number of configurations supported by
\r
365 } ATTR_PACKED USB_StdDescriptor_Device_t;
\r
367 /** @brief Standard USB Device Qualifier Descriptor (LPCUSBlib naming conventions).
\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
372 * @see @ref USB_StdDescriptor_DeviceQualifier_t for the version of this type with standard element names.
\r
374 typedef ATTR_IAR_PACKED struct
\r
376 USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */
\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
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
387 uint8_t Reserved; /**< Reserved for future use, must be 0. */
\r
388 } ATTR_PACKED USB_Descriptor_DeviceQualifier_t;
\r
390 /** @brief Standard USB Device Qualifier Descriptor (USB-IF naming conventions).
\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
395 * @see @ref USB_Descriptor_DeviceQualifier_t for the version of this type with non-standard LPCUSBlib specific element names.
\r
397 typedef ATTR_IAR_PACKED struct
\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
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
411 uint8_t bReserved; /**< Reserved for future use, must be 0. */
\r
412 } ATTR_PACKED USB_StdDescriptor_DeviceQualifier_t;
\r
414 /** @brief Standard USB Configuration Descriptor (LPCUSBlib naming conventions).
\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
419 * @see @ref USB_StdDescriptor_Configuration_Header_t for the version of this type with standard element names.
\r
421 * @note Regardless of CPU architecture, these values should be stored as little endian.
\r
423 typedef ATTR_IAR_PACKED struct
\r
425 USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */
\r
427 uint16_t TotalConfigurationSize; /**< Size of the configuration descriptor header,
\r
428 * and all sub descriptors inside the configuration.
\r
430 uint8_t TotalInterfaces; /**< Total number of interfaces in the configuration. */
\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
435 uint8_t ConfigAttributes; /**< Configuration attributes, comprised of a mask of zero or
\r
436 * more USB_CONFIG_ATTR_* masks.
\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
443 } ATTR_PACKED USB_Descriptor_Configuration_Header_t;
\r
445 /** @brief Standard USB Configuration Descriptor (USB-IF naming conventions).
\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
450 * @see @ref USB_Descriptor_Device_t for the version of this type with non-standard LPCUSBlib specific element names.
\r
452 * @note Regardless of CPU architecture, these values should be stored as little endian.
\r
454 typedef ATTR_IAR_PACKED struct
\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
460 uint16_t wTotalLength; /**< Size of the configuration descriptor header,
\r
461 * and all sub descriptors inside the configuration.
\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
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
473 } ATTR_PACKED USB_StdDescriptor_Configuration_Header_t;
\r
475 /** @brief Standard USB Interface Descriptor (LPCUSBlib naming conventions).
\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
480 * @see @ref USB_StdDescriptor_Interface_t for the version of this type with standard element names.
\r
482 * @note Regardless of CPU architecture, these values should be stored as little endian.
\r
484 typedef ATTR_IAR_PACKED struct
\r
486 USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */
\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
494 uint8_t TotalEndpoints; /**< Total number of endpoints in the interface. */
\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
500 uint8_t InterfaceStrIndex; /**< Index of the string descriptor describing the interface. */
\r
501 } ATTR_PACKED USB_Descriptor_Interface_t;
\r
503 /** @brief Standard USB Interface Descriptor (USB-IF naming conventions).
\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
508 * @see @ref USB_Descriptor_Interface_t for the version of this type with non-standard LPCUSBlib specific element names.
\r
510 * @note Regardless of CPU architecture, these values should be stored as little endian.
\r
512 typedef ATTR_IAR_PACKED struct
\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
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
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
531 } ATTR_PACKED USB_StdDescriptor_Interface_t;
\r
533 /** @brief Standard USB Interface Association Descriptor (LPCUSBlib naming conventions).
\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
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
544 * @see @ref USB_StdDescriptor_Interface_Association_t for the version of this type with standard element names.
\r
546 * @note Regardless of CPU architecture, these values should be stored as little endian.
\r
548 typedef ATTR_IAR_PACKED struct
\r
550 USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */
\r
552 uint8_t FirstInterfaceIndex; /**< Index of the first associated interface. */
\r
553 uint8_t TotalInterfaces; /**< Total number of associated interfaces. */
\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
559 uint8_t IADStrIndex; /**< Index of the string descriptor describing the
\r
560 * interface association.
\r
562 } ATTR_PACKED USB_Descriptor_Interface_Association_t;
\r
564 /** @brief Standard USB Interface Association Descriptor (USB-IF naming conventions).
\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
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
575 * @see @ref USB_Descriptor_Interface_Association_t for the version of this type with non-standard LPCUSBlib specific
\r
578 * @note Regardless of CPU architecture, these values should be stored as little endian.
\r
580 typedef ATTR_IAR_PACKED struct
\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
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
594 } ATTR_PACKED USB_StdDescriptor_Interface_Association_t;
\r
596 /** @brief Standard USB Endpoint Descriptor (LPCUSBlib naming conventions).
\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
601 * @see @ref USB_StdDescriptor_Endpoint_t for the version of this type with standard element names.
\r
603 * @note Regardless of CPU architecture, these values should be stored as little endian.
\r
605 typedef ATTR_IAR_PACKED struct
\r
607 USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */
\r
609 uint8_t EndpointAddress; /**< Logical address of the endpoint within the device for the current
\r
610 * configuration, including direction mask.
\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
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
618 uint8_t PollingIntervalMS; /**< Polling interval in milliseconds for the endpoint if it is an INTERRUPT
\r
619 * or ISOCHRONOUS type.
\r
621 } ATTR_PACKED USB_Descriptor_Endpoint_t;
\r
623 /** @brief Standard USB Endpoint Descriptor (USB-IF naming conventions).
\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
628 * @see @ref USB_Descriptor_Endpoint_t for the version of this type with non-standard LPCUSBlib specific
\r
631 * @note Regardless of CPU architecture, these values should be stored as little endian.
\r
633 typedef ATTR_IAR_PACKED struct
\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
639 uint8_t bEndpointAddress; /**< Logical address of the endpoint within the device for the current
\r
640 * configuration, including direction mask.
\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
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
648 uint8_t bInterval; /**< Polling interval in milliseconds for the endpoint if it is an INTERRUPT or
\r
649 * ISOCHRONOUS type.
\r
651 } ATTR_PACKED USB_StdDescriptor_Endpoint_t;
\r
653 /** @brief Standard USB String Descriptor (LPCUSBlib naming conventions).
\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
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
662 * This structure uses LPCUSBlib-specific element names to make each element's purpose clearer.
\r
664 * @see @ref USB_StdDescriptor_String_t for the version of this type with standard element names.
\r
666 * @note Regardless of CPU architecture, these values should be stored as little endian.
\r
668 typedef ATTR_IAR_PACKED struct
\r
670 USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */
\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
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
684 } ATTR_PACKED USB_Descriptor_String_t;
\r
686 /** @brief Standard USB String Descriptor (USB-IF naming conventions).
\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
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
695 * This structure uses the relevant standard's given element names to ensure compatibility with the standard.
\r
697 * @see @ref USB_Descriptor_String_t for the version of this type with with non-standard LPCUSBlib specific
\r
700 * @note Regardless of CPU architecture, these values should be stored as little endian.
\r
702 typedef ATTR_IAR_PACKED struct
\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
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
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
717 } ATTR_PACKED USB_StdDescriptor_String_t;
\r
719 /* Private Interface - For use in library only: */
\r
720 #if !defined(__DOXYGEN__)
\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
728 /* Disable C linkage for C++ Compilers: */
\r
729 #if defined(__cplusplus)
\r