| LPCOpen Platform v1.03 LPCOpen Platform for NXP LPC Microcontrollers

- Main Page
- Modules
- Data Structures
- Files
- Related Pages

- File List
- Globals

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
StdDescriptors.h
Go to the documentation of this file.
1 /*
2 * @brief Common standard USB Descriptor definitions for all architectures
3 *
4 * @note
5 * Copyright(C) NXP Semiconductors, 2012
6 * Copyright(C) Dean Camera, 2011, 2012
7 * All rights reserved.
8 *
9 * @par
10 * Software that is described herein is for illustrative purposes only
11 * which provides customers with programming information regarding the
12 * LPC products. This software is supplied "AS IS" without any warranties of
13 * any kind, and NXP Semiconductors and its licensor disclaim any and
14 * all warranties, express or implied, including all implied warranties of
15 * merchantability, fitness for a particular purpose and non-infringement of
16 * intellectual property rights. NXP Semiconductors assumes no responsibility
17 * or liability for the use of the software, conveys no license or rights under any
18 * patent, copyright, mask work right, or any other intellectual property rights in
19 * or to any products. NXP Semiconductors reserves the right to make changes
20 * in the software without notification. NXP Semiconductors also makes no
21 * representation or warranty that such application will be suitable for the
22 * specified use without further testing or modification.
23 *
24 * @par
25 * Permission to use, copy, modify, and distribute this software and its
26 * documentation is hereby granted, under NXP Semiconductors' and its
27 * licensor's relevant copyrights in the software, without fee, provided that it
28 * is used in conjunction with NXP Semiconductors microcontrollers. This
29 * copyright, permission, and disclaimer notice must appear in all copies of
30 * this code.
31 */
32
33
44 #ifndef __USBDESCRIPTORS_H__
45 #define __USBDESCRIPTORS_H__
46
47 /* Includes: */
48 #include "../../../Common/Common.h"
49 #include "USBMode.h"
50 #include "Events.h"
51
52 /* Enable C linkage for C++ Compilers: */
53 #if defined(__cplusplus)
54 extern "C" {
55 #endif
56
57 /* Preprocessor Checks: */
58 #if !defined(__INCLUDE_FROM_USB_DRIVER)
59 #error Do not include this file directly. Include lpcroot/libraries/LPCUSBlib/Drivers/USB/USB.h instead.
60 #endif
61
62 /* Public Interface - May be used in end-application: */
63 /* Macros: */
64
67 #define WBVAL(x) ((x) & 0xFF),(((x) >> 8) & 0xFF)
68
73 #define NO_DESCRIPTOR 0
74
79 #define USB_CONFIG_POWER_MA(mA) ((mA) >> 1)
80
86 #define USB_STRING_LEN(UnicodeChars) (sizeof(USB_Descriptor_Header_t) + ((UnicodeChars) << 1))
87
97 #define VERSION_BCD(x) CPU_TO_LE16((((VERSION_TENS(x) << 4) | VERSION_ONES(x)) << 8) | \
98 ((VERSION_TENTHS(x) << 4) | VERSION_HUNDREDTHS(x)))
99
103 #define LANGUAGE_ID_ENG 0x0409
104
111 #define USB_CONFIG_ATTR_BUSPOWERED 0x80
112
117 #define USB_CONFIG_ATTR_SELFPOWERED 0x40
118
124 #define USB_CONFIG_ATTR_REMOTEWAKEUP 0x20
125
126
134 #define ENDPOINT_ATTR_NO_SYNC (0 << 2)
135
141 #define ENDPOINT_ATTR_ASYNC (1 << 2)
142
148 #define ENDPOINT_ATTR_ADAPTIVE (2 << 2)
149
155 #define ENDPOINT_ATTR_SYNC (3 << 2)
156
157
165 #define ENDPOINT_USAGE_DATA (0 << 4)
166
172 #define ENDPOINT_USAGE_FEEDBACK (1 << 4)
173
179 #define ENDPOINT_USAGE_IMPLICIT_FEEDBACK (2 << 4)
180
181
182 /* Enums: */
184 enum USB_DescriptorTypes_t
185 {
186 DTYPE_Device = 0x01,
187 DTYPE_Configuration = 0x02,
188 DTYPE_String = 0x03,
189 DTYPE_Interface = 0x04,
190 DTYPE_Endpoint = 0x05,
191 DTYPE_DeviceQualifier = 0x06,
192 DTYPE_Other = 0x07,
193 DTYPE_InterfacePower = 0x08,
194 DTYPE_InterfaceAssociation = 0x0B,
195 DTYPE_CSInterface = 0x24,
196 DTYPE_CSEndpoint = 0x25,
197 };
198
200 enum USB_Descriptor_ClassSubclassProtocol_t
201 {
202 USB_CSCP_NoDeviceClass = 0x00,
205 USB_CSCP_NoDeviceSubclass = 0x00,
208 USB_CSCP_NoDeviceProtocol = 0x00,
211 USB_CSCP_VendorSpecificClass = 0xFF,
214 USB_CSCP_VendorSpecificSubclass = 0xFF,
217 USB_CSCP_VendorSpecificProtocol = 0xFF,
220 USB_CSCP_IADDeviceClass = 0xEF,
223 USB_CSCP_IADDeviceSubclass = 0x02,
226 USB_CSCP_IADDeviceProtocol = 0x01,
229 };
230
231 /* Type Defines: */
241 typedef ATTR_IAR_PACKED struct
242 {
243 uint8_t Size;
244 uint8_t Type;
247 } ATTR_PACKED USB_Descriptor_Header_t;
248
258 typedef ATTR_IAR_PACKED struct
259 {
260 uint8_t bLength;
261 uint8_t bDescriptorType;
264 } ATTR_PACKED USB_StdDescriptor_Header_t;
265
275 typedef ATTR_IAR_PACKED struct
276 {
277 USB_Descriptor_Header_t Header;
279 uint16_t USBSpecification;
280 uint8_t Class;
281 uint8_t SubClass;
282 uint8_t Protocol;
284 uint8_t Endpoint0Size;
286 uint16_t VendorID;
287 uint16_t ProductID;
288 uint16_t ReleaseNumber;
290 uint8_t ManufacturerStrIndex;
296 uint8_t ProductStrIndex;
300 uint8_t SerialNumStrIndex;
312 uint8_t NumberOfConfigurations;
315 } ATTR_PACKED USB_Descriptor_Device_t;
316
326 typedef ATTR_IAR_PACKED struct
327 {
328 uint8_t bLength;
329 uint8_t bDescriptorType;
332 uint16_t bcdUSB;
333 uint8_t bDeviceClass;
334 uint8_t bDeviceSubClass;
335 uint8_t bDeviceProtocol;
336 uint8_t bMaxPacketSize0;
337 uint16_t idVendor;
338 uint16_t idProduct;
339 uint16_t bcdDevice;
340 uint8_t iManufacturer;
346 uint8_t iProduct;
350 uint8_t iSerialNumber;
362 uint8_t bNumConfigurations;
365 } ATTR_PACKED USB_StdDescriptor_Device_t;
366
374 typedef ATTR_IAR_PACKED struct
375 {
376 USB_Descriptor_Header_t Header;
378 uint16_t USBSpecification;
379 uint8_t Class;
380 uint8_t SubClass;
381 uint8_t Protocol;
383 uint8_t Endpoint0Size;
384 uint8_t NumberOfConfigurations;
387 uint8_t Reserved;
388 } ATTR_PACKED USB_Descriptor_DeviceQualifier_t;
389
397 typedef ATTR_IAR_PACKED struct
398 {
399 uint8_t bLength;
400 uint8_t bDescriptorType;
403 uint16_t bcdUSB;
404 uint8_t bDeviceClass;
405 uint8_t bDeviceSubClass;
406 uint8_t bDeviceProtocol;
407 uint8_t bMaxPacketSize0;
408 uint8_t bNumConfigurations;
411 uint8_t bReserved;
412 } ATTR_PACKED USB_StdDescriptor_DeviceQualifier_t;
413
423 typedef ATTR_IAR_PACKED struct
424 {
425 USB_Descriptor_Header_t Header;
427 uint16_t TotalConfigurationSize;
430 uint8_t TotalInterfaces;
432 uint8_t ConfigurationNumber;
433 uint8_t ConfigurationStrIndex;
435 uint8_t ConfigAttributes;
439 uint8_t MaxPowerConsumption;
443 } ATTR_PACKED USB_Descriptor_Configuration_Header_t;
444
454 typedef ATTR_IAR_PACKED struct
455 {
456 uint8_t bLength;
457 uint8_t bDescriptorType;
460 uint16_t wTotalLength;
463 uint8_t bNumInterfaces;
464 uint8_t bConfigurationValue;
465 uint8_t iConfiguration;
466 uint8_t bmAttributes;
469 uint8_t bMaxPower;
473 } ATTR_PACKED USB_StdDescriptor_Configuration_Header_t;
474
484 typedef ATTR_IAR_PACKED struct
485 {
486 USB_Descriptor_Header_t Header;
488 uint8_t InterfaceNumber;
489 uint8_t AlternateSetting;
494 uint8_t TotalEndpoints;
496 uint8_t Class;
497 uint8_t SubClass;
498 uint8_t Protocol;
500 uint8_t InterfaceStrIndex;
501 } ATTR_PACKED USB_Descriptor_Interface_t;
502
512 typedef ATTR_IAR_PACKED struct
513 {
514 uint8_t bLength;
515 uint8_t bDescriptorType;
518 uint8_t bInterfaceNumber;
519 uint8_t bAlternateSetting;
524 uint8_t bNumEndpoints;
525 uint8_t bInterfaceClass;
526 uint8_t bInterfaceSubClass;
527 uint8_t bInterfaceProtocol;
528 uint8_t iInterface;
531 } ATTR_PACKED USB_StdDescriptor_Interface_t;
532
548 typedef ATTR_IAR_PACKED struct
549 {
550 USB_Descriptor_Header_t Header;
552 uint8_t FirstInterfaceIndex;
553 uint8_t TotalInterfaces;
555 uint8_t Class;
556 uint8_t SubClass;
557 uint8_t Protocol;
559 uint8_t IADStrIndex;
562 } ATTR_PACKED USB_Descriptor_Interface_Association_t;
563
580 typedef ATTR_IAR_PACKED struct
581 {
582 uint8_t bLength;
583 uint8_t bDescriptorType;
586 uint8_t bFirstInterface;
587 uint8_t bInterfaceCount;
588 uint8_t bFunctionClass;
589 uint8_t bFunctionSubClass;
590 uint8_t bFunctionProtocol;
591 uint8_t iFunction;
594 } ATTR_PACKED USB_StdDescriptor_Interface_Association_t;
595
605 typedef ATTR_IAR_PACKED struct
606 {
607 USB_Descriptor_Header_t Header;
609 uint8_t EndpointAddress;
612 uint8_t Attributes;
615 uint16_t EndpointSize;
618 uint8_t PollingIntervalMS;
621 } ATTR_PACKED USB_Descriptor_Endpoint_t;
622
633 typedef ATTR_IAR_PACKED struct
634 {
635 uint8_t bLength;
636 uint8_t bDescriptorType;
639 uint8_t bEndpointAddress;
642 uint8_t bmAttributes;
645 uint16_t wMaxPacketSize;
648 uint8_t bInterval;
651 } ATTR_PACKED USB_StdDescriptor_Endpoint_t;
652
668 typedef ATTR_IAR_PACKED struct
669 {
670 USB_Descriptor_Header_t Header;
672 uint16_t UnicodeString[];
684 } ATTR_PACKED USB_Descriptor_String_t;
685
702 typedef ATTR_IAR_PACKED struct
703 {
704 uint8_t bLength;
705 uint8_t bDescriptorType;
708 uint16_t bString[];
717 } ATTR_PACKED USB_StdDescriptor_String_t;
718
719 /* Private Interface - For use in library only: */
720 #if !defined(__DOXYGEN__)
721 /* Macros: */
722 #define VERSION_TENS(x) (int)((x) / 10)
723 #define VERSION_ONES(x) (int)((x) - (10 * VERSION_TENS(x)))
724 #define VERSION_TENTHS(x) (int)(((x) - (int)(x)) * 10)
725 #define VERSION_HUNDREDTHS(x) (int)((((x) - (int)(x)) * 100) - (10 * VERSION_TENTHS(x)))
726 #endif
727
728 /* Disable C linkage for C++ Compilers: */
729 #if defined(__cplusplus)
730 }
731 #endif
732
733 #endif
734