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