LPCOpen Platform
LPCOpen Platform for NXP LPC Microcontrollers
 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: */
185  {
186  DTYPE_Device = 0x01,
188  DTYPE_String = 0x03,
190  DTYPE_Endpoint = 0x05,
192  DTYPE_Other = 0x07,
197  };
198 
201  {
229  };
230 
231  /* Type Defines: */
241  typedef ATTR_IAR_PACKED struct
242  {
243  uint8_t Size;
244  uint8_t Type;
248 
258  typedef ATTR_IAR_PACKED struct
259  {
260  uint8_t bLength;
261  uint8_t bDescriptorType;
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;
296  uint8_t ProductStrIndex;
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;
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;
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;
413 
423  typedef ATTR_IAR_PACKED struct
424  {
425  USB_Descriptor_Header_t Header;
430  uint8_t TotalInterfaces;
444 
454  typedef ATTR_IAR_PACKED struct
455  {
456  uint8_t bLength;
457  uint8_t bDescriptorType;
460  uint16_t wTotalLength;
463  uint8_t bNumInterfaces;
465  uint8_t iConfiguration;
466  uint8_t bmAttributes;
469  uint8_t bMaxPower;
474 
484  typedef ATTR_IAR_PACKED struct
485  {
486  USB_Descriptor_Header_t Header;
488  uint8_t InterfaceNumber;
494  uint8_t TotalEndpoints;
496  uint8_t Class;
497  uint8_t SubClass;
498  uint8_t Protocol;
502 
512  typedef ATTR_IAR_PACKED struct
513  {
514  uint8_t bLength;
515  uint8_t bDescriptorType;
524  uint8_t bNumEndpoints;
525  uint8_t bInterfaceClass;
528  uint8_t iInterface;
532 
548  typedef ATTR_IAR_PACKED struct
549  {
550  USB_Descriptor_Header_t Header;
553  uint8_t TotalInterfaces;
555  uint8_t Class;
556  uint8_t SubClass;
557  uint8_t Protocol;
559  uint8_t IADStrIndex;
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;
591  uint8_t iFunction;
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;
622 
633  typedef ATTR_IAR_PACKED struct
634  {
635  uint8_t bLength;
636  uint8_t bDescriptorType;
642  uint8_t bmAttributes;
645  uint16_t wMaxPacketSize;
648  uint8_t bInterval;
652 
668  typedef ATTR_IAR_PACKED struct
669  {
670  USB_Descriptor_Header_t Header;
672  #if ((ARCH == ARCH_AVR8) || (ARCH == ARCH_XMEGA))
673  wchar_t UnicodeString[];
674  #else
675  uint16_t UnicodeString[];
687  #endif
689 
706  typedef ATTR_IAR_PACKED struct
707  {
708  uint8_t bLength;
709  uint8_t bDescriptorType;
712  uint16_t bString[];
722 
723  /* Private Interface - For use in library only: */
724  #if !defined(__DOXYGEN__)
725  /* Macros: */
726  #define VERSION_TENS(x) (int)((x) / 10)
727  #define VERSION_ONES(x) (int)((x) - (10 * VERSION_TENS(x)))
728  #define VERSION_TENTHS(x) (int)(((x) - (int)(x)) * 10)
729  #define VERSION_HUNDREDTHS(x) (int)((((x) - (int)(x)) * 100) - (10 * VERSION_TENTHS(x)))
730  #endif
731 
732  /* Disable C linkage for C++ Compilers: */
733  #if defined(__cplusplus)
734  }
735  #endif
736 
737 #endif
738