remove VIM swap file, and add it to .gitignore
[rapper.git] / new_cmsis / usb / usbdesc.c
1 /*----------------------------------------------------------------------------\r
2  *      U S B  -  K e r n e l\r
3  *----------------------------------------------------------------------------\r
4  * Name:    usbdesc.c\r
5  * Purpose: USB Descriptors\r
6  * Version: V1.20\r
7  *----------------------------------------------------------------------------\r
8  *      This software is supplied "AS IS" without any warranties, express,\r
9  *      implied or statutory, including but not limited to the implied\r
10  *      warranties of fitness for purpose, satisfactory quality and\r
11  *      noninfringement. Keil extends you a royalty-free right to reproduce\r
12  *      and distribute executable files created using this software for use\r
13  *      on NXP Semiconductors LPC microcontroller devices only. Nothing else\r
14  *      gives you the right to use this software.\r
15  *\r
16  * Copyright (c) 2009 Keil - An ARM Company. All rights reserved.\r
17  *----------------------------------------------------------------------------\r
18  * History:\r
19  *          V1.20 Changed string descriptor handling\r
20  *          V1.00 Initial Version\r
21  *---------------------------------------------------------------------------*/\r
22 #include "lpc_types.h"\r
23 #include "usb.h"\r
24 #include "cdc.h"\r
25 #include "usbcfg.h"\r
26 #include "usbdesc.h"\r
27 \r
28 \r
29 /* USB Standard Device Descriptor */\r
30 const uint8_t USB_DeviceDescriptor[] = {\r
31   USB_DEVICE_DESC_SIZE,              /* bLength */\r
32   USB_DEVICE_DESCRIPTOR_TYPE,        /* bDescriptorType */\r
33   WBVAL(0x0200), /* 2.0 */           /* bcdUSB */\r
34   USB_DEVICE_CLASS_COMMUNICATIONS,   /* bDeviceClass CDC*/\r
35   0x00,                              /* bDeviceSubClass */\r
36   0x00,                              /* bDeviceProtocol */\r
37   USB_MAX_PACKET0,                   /* bMaxPacketSize0 */\r
38   WBVAL(0x1FC9),                     /* idVendor */\r
39   WBVAL(0x2002),                     /* idProduct */\r
40   WBVAL(0x0100), /* 1.00 */          /* bcdDevice */\r
41   0x01,                              /* iManufacturer */\r
42   0x02,                              /* iProduct */\r
43   0x03,                              /* iSerialNumber */\r
44   0x01                               /* bNumConfigurations: one possible configuration*/\r
45 };\r
46 \r
47 /* USB Configuration Descriptor */\r
48 /*   All Descriptors (Configuration, Interface, Endpoint, Class, Vendor */\r
49 const uint8_t USB_ConfigDescriptor[] = {\r
50 /* Configuration 1 */\r
51   USB_CONFIGUARTION_DESC_SIZE,       /* bLength */\r
52   USB_CONFIGURATION_DESCRIPTOR_TYPE, /* bDescriptorType */\r
53   WBVAL(                             /* wTotalLength */\r
54     1*USB_CONFIGUARTION_DESC_SIZE +\r
55     1*USB_INTERFACE_DESC_SIZE     +  /* communication interface */\r
56     0x0013                        +  /* CDC functions */\r
57     1*USB_ENDPOINT_DESC_SIZE      +  /* interrupt endpoint */\r
58     1*USB_INTERFACE_DESC_SIZE     +  /* data interface */\r
59     2*USB_ENDPOINT_DESC_SIZE         /* bulk endpoints */\r
60       ),\r
61   0x02,                              /* bNumInterfaces */\r
62   0x01,                              /* bConfigurationValue: 0x01 is used to select this configuration */\r
63   0x00,                              /* iConfiguration: no string to describe this configuration */\r
64   USB_CONFIG_BUS_POWERED /*|*/       /* bmAttributes */\r
65 /*USB_CONFIG_REMOTE_WAKEUP*/,\r
66   USB_CONFIG_POWER_MA(100),          /* bMaxPower, device power consumption is 100 mA */\r
67 /* Interface 0, Alternate Setting 0, Communication class interface descriptor */\r
68   USB_INTERFACE_DESC_SIZE,           /* bLength */\r
69   USB_INTERFACE_DESCRIPTOR_TYPE,     /* bDescriptorType */\r
70   USB_CDC_CIF_NUM,                   /* bInterfaceNumber: Number of Interface */\r
71   0x00,                              /* bAlternateSetting: Alternate setting */\r
72   0x01,                              /* bNumEndpoints: One endpoint used */\r
73   CDC_COMMUNICATION_INTERFACE_CLASS, /* bInterfaceClass: Communication Interface Class */\r
74   CDC_ABSTRACT_CONTROL_MODEL,        /* bInterfaceSubClass: Abstract Control Model */\r
75   0x00,                              /* bInterfaceProtocol: no protocol used */\r
76   0x5E,                              /* iInterface: */\r
77 /*Header Functional Descriptor*/\r
78   0x05,                              /* bLength: Endpoint Descriptor size */\r
79   CDC_CS_INTERFACE,                  /* bDescriptorType: CS_INTERFACE */\r
80   CDC_HEADER,                        /* bDescriptorSubtype: Header Func Desc */\r
81   WBVAL(CDC_V1_10), /* 1.10 */       /* bcdCDC */\r
82 /*Call Management Functional Descriptor*/\r
83   0x05,                              /* bFunctionLength */\r
84   CDC_CS_INTERFACE,                  /* bDescriptorType: CS_INTERFACE */\r
85   CDC_CALL_MANAGEMENT,               /* bDescriptorSubtype: Call Management Func Desc */\r
86   0x01,                              /* bmCapabilities: device handles call management */\r
87   0x01,                              /* bDataInterface: CDC data IF ID */\r
88 /*Abstract Control Management Functional Descriptor*/\r
89   0x04,                              /* bFunctionLength */\r
90   CDC_CS_INTERFACE,                  /* bDescriptorType: CS_INTERFACE */\r
91   CDC_ABSTRACT_CONTROL_MANAGEMENT,   /* bDescriptorSubtype: Abstract Control Management desc */\r
92   0x02,                              /* bmCapabilities: SET_LINE_CODING, GET_LINE_CODING, SET_CONTROL_LINE_STATE supported */\r
93 /*Union Functional Descriptor*/\r
94   0x05,                              /* bFunctionLength */\r
95   CDC_CS_INTERFACE,                  /* bDescriptorType: CS_INTERFACE */\r
96   CDC_UNION,                         /* bDescriptorSubtype: Union func desc */\r
97   USB_CDC_CIF_NUM,                   /* bMasterInterface: Communication class interface is master */\r
98   USB_CDC_DIF_NUM,                   /* bSlaveInterface0: Data class interface is slave 0 */\r
99 /*Endpoint 1 Descriptor*/            /* event notification (optional) */\r
100   USB_ENDPOINT_DESC_SIZE,            /* bLength */\r
101   USB_ENDPOINT_DESCRIPTOR_TYPE,      /* bDescriptorType */\r
102   USB_ENDPOINT_IN(1),                /* bEndpointAddress */\r
103   USB_ENDPOINT_TYPE_INTERRUPT,       /* bmAttributes */\r
104   WBVAL(0x0010),                     /* wMaxPacketSize */\r
105   0x02,          /* 2ms */           /* bInterval */\r
106 /* Interface 1, Alternate Setting 0, Data class interface descriptor*/\r
107   USB_INTERFACE_DESC_SIZE,           /* bLength */\r
108   USB_INTERFACE_DESCRIPTOR_TYPE,     /* bDescriptorType */\r
109   USB_CDC_DIF_NUM,                   /* bInterfaceNumber: Number of Interface */\r
110   0x00,                              /* bAlternateSetting: no alternate setting */\r
111   0x02,                              /* bNumEndpoints: two endpoints used */\r
112   CDC_DATA_INTERFACE_CLASS,          /* bInterfaceClass: Data Interface Class */\r
113   0x00,                              /* bInterfaceSubClass: no subclass available */\r
114   0x00,                              /* bInterfaceProtocol: no protocol used */\r
115   0x5E,                              /* iInterface: */\r
116 /* Endpoint, EP2 Bulk Out */\r
117   USB_ENDPOINT_DESC_SIZE,            /* bLength */\r
118   USB_ENDPOINT_DESCRIPTOR_TYPE,      /* bDescriptorType */\r
119   USB_ENDPOINT_OUT(2),               /* bEndpointAddress */\r
120   USB_ENDPOINT_TYPE_BULK,            /* bmAttributes */\r
121   WBVAL(USB_CDC_BUFSIZE),            /* wMaxPacketSize */\r
122   0x00,                              /* bInterval: ignore for Bulk transfer */\r
123 /* Endpoint, EP2 Bulk In */\r
124   USB_ENDPOINT_DESC_SIZE,            /* bLength */\r
125   USB_ENDPOINT_DESCRIPTOR_TYPE,      /* bDescriptorType */\r
126   USB_ENDPOINT_IN(2),                /* bEndpointAddress */\r
127   USB_ENDPOINT_TYPE_BULK,            /* bmAttributes */\r
128   WBVAL(USB_CDC_BUFSIZE),            /* wMaxPacketSize */\r
129   0x00,                              /* bInterval: ignore for Bulk transfer */\r
130 /* Terminator */\r
131   0                                  /* bLength */\r
132 };\r
133 \r
134 \r
135 \r
136 \r
137 /* USB String Descriptor (optional) */\r
138 const uint8_t USB_StringDescriptor[] = {\r
139 /* Index 0x00: LANGID Codes */\r
140   0x04,                              /* bLength */\r
141   USB_STRING_DESCRIPTOR_TYPE,        /* bDescriptorType */\r
142   WBVAL(0x0409), /* US English */    /* wLANGID */\r
143 /* Index 0x01: Manufacturer */\r
144   (13*2 + 2),                        /* bLength (13 Char + Type + lenght) */\r
145   USB_STRING_DESCRIPTOR_TYPE,        /* bDescriptorType */\r
146   'N',0,\r
147   'X',0,\r
148   'P',0,\r
149   ' ',0,\r
150   'S',0,\r
151   'E',0,\r
152   'M',0,\r
153   'I',0,\r
154   'C',0,\r
155   'O',0,\r
156   'N',0,\r
157   'D',0,\r
158   ' ',0,\r
159 /* Index 0x02: Product */\r
160   (17*2 + 2),                        /* bLength ( 17 Char + Type + lenght) */\r
161   USB_STRING_DESCRIPTOR_TYPE,        /* bDescriptorType */\r
162   'N',0,\r
163   'X',0,\r
164   'P',0,\r
165   ' ',0,\r
166   'L',0,\r
167   'P',0,\r
168   'C',0,\r
169   '1',0,\r
170   '7',0,\r
171   'x',0,\r
172   'x',0,\r
173   ' ',0,\r
174   'V',0,\r
175   'C',0,\r
176   'O',0,\r
177   'M',0,\r
178   ' ',0,\r
179 /* Index 0x03: Serial Number */\r
180   (12*2 + 2),                        /* bLength (12 Char + Type + lenght) */\r
181   USB_STRING_DESCRIPTOR_TYPE,        /* bDescriptorType */\r
182   'D',0,\r
183   'E',0,\r
184   'M',0,\r
185   'O',0,\r
186   '0',0,\r
187   '0',0,\r
188   '0',0,\r
189   '0',0,\r
190   '0',0,\r
191   '0',0,\r
192   '0',0,\r
193   '0',0,\r
194 /* Index 0x04: Interface 0, Alternate Setting 0 */\r
195   ( 4*2 + 2),                        /* bLength (4 Char + Type + lenght) */\r
196   USB_STRING_DESCRIPTOR_TYPE,        /* bDescriptorType */\r
197   'V',0,\r
198   'C',0,\r
199   'O',0,\r
200   'M',0,\r
201 };\r