1 |
2 |
ZTEX |
/*%
|
2 |
|
|
ZTEX Firmware Kit for EZ-USB FX3 Microcontrollers
|
3 |
|
|
Copyright (C) 2009-2017 ZTEX GmbH.
|
4 |
|
|
http://www.ztex.de
|
5 |
|
|
|
6 |
|
|
This Source Code Form is subject to the terms of the Mozilla Public
|
7 |
|
|
License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
8 |
|
|
You can obtain one at http://mozilla.org/MPL/2.0/.
|
9 |
|
|
|
10 |
|
|
Alternatively, the contents of this file may be used under the terms
|
11 |
|
|
of the GNU General Public License Version 3, as described below:
|
12 |
|
|
|
13 |
|
|
This program is free software; you can redistribute it and/or modify
|
14 |
|
|
it under the terms of the GNU General Public License version 3 as
|
15 |
|
|
published by the Free Software Foundation.
|
16 |
|
|
|
17 |
|
|
This program is distributed in the hope that it will be useful, but
|
18 |
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
19 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
20 |
|
|
General Public License for more details.
|
21 |
|
|
|
22 |
|
|
You should have received a copy of the GNU General Public License
|
23 |
|
|
along with this program; if not, see http://www.gnu.org/licenses/.
|
24 |
|
|
%*/
|
25 |
|
|
/*
|
26 |
|
|
Descriptor definitions.
|
27 |
|
|
*/
|
28 |
|
|
#ifndef _ZTEX_CONF_H_
|
29 |
|
|
#error "Illegal use of `ztex-descriptors.c'. This file must be included in the main firmware source after including `ztex-conf.h' and after the configuration section"
|
30 |
|
|
#endif
|
31 |
|
|
#ifndef _ZTEX_DESCRIPTORS_C_
|
32 |
|
|
#define _ZTEX_DESCRIPTORS_C_
|
33 |
|
|
|
34 |
|
|
#define W2B(a) (a) & 255, (a) >> 8
|
35 |
|
|
#define DIR_IN 128
|
36 |
|
|
#define DIR_OUT 0
|
37 |
|
|
#define TYPE_ISO 1
|
38 |
|
|
#define TYPE_BULK 2
|
39 |
|
|
#define TYPE_INT 3
|
40 |
|
|
|
41 |
|
|
// device descriptor for USB 3.0
|
42 |
|
|
uint8_t ztex_usb3_device_descriptor[] __attribute__ ((aligned (32))) =
|
43 |
|
|
{
|
44 |
|
|
18, // 0, descriptor size
|
45 |
|
|
CY_U3P_USB_DEVICE_DESCR, // 1, Device descriptor type
|
46 |
|
|
0x00,0x03, // 2, USB 3.0
|
47 |
|
|
0x00, // 4, Device class
|
48 |
|
|
0x00, // 5, Device sub-class
|
49 |
|
|
0x00, // 6, Device protocol
|
50 |
|
|
0x09, // 7, Max packet size for EP0 : 2^9
|
51 |
|
|
W2B(ZTEX_USB_VENDOR_ID), // 8, Vendor ID
|
52 |
|
|
W2B(ZTEX_USB_PRODUCT_ID), // 10, Product ID
|
53 |
|
|
0x00,0x00, // 12, Device release number
|
54 |
|
|
0x01, // 14, Manufacture string index
|
55 |
|
|
0x02, // 15, Product string index
|
56 |
|
|
0x03, // 16, Serial number string index
|
57 |
|
|
0x01 // 17, Number of configurations
|
58 |
|
|
};
|
59 |
|
|
|
60 |
|
|
// device descriptor for USB 2.0
|
61 |
|
|
uint8_t ztex_usb2_device_descriptor[] __attribute__ ((aligned (32))) =
|
62 |
|
|
{
|
63 |
|
|
18, // 0, Descriptor size
|
64 |
|
|
CY_U3P_USB_DEVICE_DESCR, // 1, Device descriptor type
|
65 |
|
|
0x00,0x02, // 2, USB 2.00
|
66 |
|
|
0x00, // 4, Device class
|
67 |
|
|
0x00, // 5, Device sub-class
|
68 |
|
|
0x00, // 6, Device protocol
|
69 |
|
|
0x40, // 7, Max packet size for EP0 : 64 bytes
|
70 |
|
|
W2B(ZTEX_USB_VENDOR_ID), // 8, Vendor ID
|
71 |
|
|
W2B(ZTEX_USB_PRODUCT_ID), // 10, Product ID
|
72 |
|
|
0x00,0x00, // 12, Device release number
|
73 |
|
|
0x01, // 14, Manufacture string index
|
74 |
|
|
0x02, // 15, Product string index
|
75 |
|
|
0x03, // 16, Serial number string index
|
76 |
|
|
0x01 // 17, Number of configurations
|
77 |
|
|
};
|
78 |
|
|
|
79 |
|
|
// Binary device object store descriptor
|
80 |
|
|
const uint8_t ztex_bos_descriptor[] __attribute__ ((aligned (32))) =
|
81 |
|
|
{
|
82 |
|
|
5, // 0, Descriptor size
|
83 |
|
|
CY_U3P_BOS_DESCR, // 1, Device descriptor type
|
84 |
|
|
22,0, // 2, Length of this descriptor and all sub descriptors
|
85 |
|
|
0x02, // 4, Number of device capability descriptors
|
86 |
|
|
|
87 |
|
|
// USB 2.0 extension
|
88 |
|
|
7, // 0, Descriptor size
|
89 |
|
|
CY_U3P_DEVICE_CAPB_DESCR, // 1, Device capability type descriptor
|
90 |
|
|
CY_U3P_USB2_EXTN_CAPB_TYPE, // 2, USB 2.0 extension capability type
|
91 |
|
|
0x02,0x00,0x00,0x00, // 3, Supported device level features: LPM support
|
92 |
|
|
|
93 |
|
|
// SuperSpeed device capability
|
94 |
|
|
10, // 0, Descriptor size
|
95 |
|
|
CY_U3P_DEVICE_CAPB_DESCR, // 1, Device capability type descriptor
|
96 |
|
|
CY_U3P_SS_USB_CAPB_TYPE, // 2, SuperSpeed device capability type
|
97 |
|
|
0x00, // 3, Supported device level features
|
98 |
|
|
0x0E,0x00, // 4, Speeds supported by the device : SS, HS and FS
|
99 |
|
|
0x03, // 6, Functionality support
|
100 |
|
|
0x00, // 7, U1 Device Exit latency
|
101 |
|
|
0x00,0x00 // 8, U2 Device Exit latency
|
102 |
|
|
};
|
103 |
|
|
|
104 |
|
|
// Standard device qualifier descriptor
|
105 |
|
|
const uint8_t ztex_device_qualifier_descriptor[] __attribute__ ((aligned (32))) =
|
106 |
|
|
{
|
107 |
|
|
10, // 0, Descriptor size
|
108 |
|
|
CY_U3P_USB_DEVQUAL_DESCR, // 1, Device qualifier descriptor type
|
109 |
|
|
0x00,0x02, // 2, USB 2.0
|
110 |
|
|
0x00, // 4, Device class
|
111 |
|
|
0x00, // 5, Device sub-class
|
112 |
|
|
0x00, // 6, Device protocol
|
113 |
|
|
0x40, // 7, Max packet size for EP0 : 64 bytes
|
114 |
|
|
0x01, // 8, Number of configurations
|
115 |
|
|
0x00 // 9, Reserved
|
116 |
|
|
};
|
117 |
|
|
|
118 |
|
|
enum interface_eps {
|
119 |
|
|
interface_eps_dummy = 0
|
120 |
|
|
#define INTERFACE(a,b), interface_eps_##a = 0 b
|
121 |
|
|
#define EP(num,dir,type,size,burst,interval,settings) +1
|
122 |
|
|
EP_SETUP_ALL
|
123 |
|
|
};
|
124 |
|
|
#undef INTERFACE
|
125 |
|
|
#undef EP
|
126 |
|
|
|
127 |
|
|
// super speed configuration descriptor
|
128 |
|
|
const uint8_t ztex_usb3_config_descriptor[] __attribute__ ((aligned (32))) =
|
129 |
|
|
{
|
130 |
|
|
// Configuration descriptor
|
131 |
|
|
9, // 0, Descriptor size
|
132 |
|
|
CY_U3P_USB_CONFIG_DESCR, // 1, Configuration descriptor type
|
133 |
|
|
#define INTERFACE(a,b) +9 b
|
134 |
|
|
#define EP(num,dir,type,size,burst,interval,settings) +7+6
|
135 |
|
|
W2B(9 EP_SETUP_ALL), // 2, Length of this descriptor and all sub descriptors
|
136 |
|
|
#undef INTERFACE
|
137 |
|
|
#undef EP
|
138 |
|
|
#define INTERFACE(a,b) +1
|
139 |
|
|
|
140 |
|
|
#undef INTERFACE
|
141 |
|
|
0x01, // 5, Configuration number
|
142 |
|
|
0x00, // 6, Configuration string index
|
143 |
|
|
0x80, // 7, attributes: bus
|
144 |
|
|
25 // 8, Max power consumption of device (in 8mA units) : 200mA
|
145 |
|
|
|
146 |
|
|
// Interface descriptors
|
147 |
|
|
#define INTERFACE(num, body) , \
|
148 |
|
|
0x09, /* 0, Descriptor size */ \
|
149 |
|
|
CY_U3P_USB_INTRFC_DESCR, /* 1, Interface Descriptor type */ \
|
150 |
|
|
num, /* 2, Interface number */ \
|
151 |
|
|
0x00, /* 3, Alternate setting number */ \
|
152 |
|
|
interface_eps_##num, /* 4, Number of end points */ \
|
153 |
|
|
0xFF, /* 5, Interface class */ \
|
154 |
|
|
0x00, /* 5, Interface sub class */ \
|
155 |
|
|
0x00, /* 6, Interface protocol code */ \
|
156 |
|
|
num < 8 ? num+4 : 0 /* 7, Interface descriptor string index */ \
|
157 |
|
|
/* String can be set using ztex_interface_string[] */ \
|
158 |
|
|
body
|
159 |
|
|
|
160 |
|
|
// Endpoint descriptors
|
161 |
|
|
#define EP(num,dir,type,size,burst,interval,settings) , \
|
162 |
|
|
0x07, /* 0, Descriptor size */ \
|
163 |
|
|
CY_U3P_USB_ENDPNT_DESCR, /* 1, Endpoint descriptor type */ \
|
164 |
|
|
DIR_##dir | num, /* 2, Endpoint number + direction */ \
|
165 |
|
|
TYPE_##type, /* 3, endpoint type */ \
|
166 |
|
|
W2B(size), /* 4, Max packet size */ \
|
167 |
|
|
interval, /* 6, Service interval */ \
|
168 |
|
|
/* Super speed endpoint companion descriptor for producer EP */ \
|
169 |
|
|
0x06, /* 0, Descriptor size */ \
|
170 |
|
|
CY_U3P_SS_EP_COMPN_DESCR, /* 1, SS endpoint companion descriptor type */ \
|
171 |
|
|
burst-1, /* 2, bursts*/ \
|
172 |
|
|
0, /* 3, attributes */ \
|
173 |
|
|
W2B(TYPE_##type==2 ? 0 : size*burst) /* 4, Bytes per interval: 0 for bulk, size * burst for periodic transfers */
|
174 |
|
|
EP_SETUP_ALL
|
175 |
|
|
#undef INTERFACE
|
176 |
|
|
#undef EP
|
177 |
|
|
};
|
178 |
|
|
|
179 |
|
|
|
180 |
|
|
// high speed configuration descriptor
|
181 |
|
|
const uint8_t ztex_usb2_config_descriptor[] __attribute__ ((aligned (32))) =
|
182 |
|
|
{
|
183 |
|
|
// Configuration descriptor
|
184 |
|
|
9, // 0, Descriptor size
|
185 |
|
|
CY_U3P_USB_CONFIG_DESCR, // 1, Configuration descriptor type
|
186 |
|
|
#define INTERFACE(a,b) +9 b
|
187 |
|
|
#define EP(num,dir,type,size,burst,interval,settings) +7
|
188 |
|
|
W2B(9 EP_SETUP_ALL), // 2, Length of this descriptor and all sub descriptors
|
189 |
|
|
#undef INTERFACE
|
190 |
|
|
#undef EP
|
191 |
|
|
#define INTERFACE(a,b) +1
|
192 |
|
|
|
193 |
|
|
#undef INTERFACE
|
194 |
|
|
0x01, // 5, Configuration number
|
195 |
|
|
0x00, // 6, Configuration string index
|
196 |
|
|
0x80, // 7, attributes: bus
|
197 |
|
|
50 // 8, Max power consumption of device (in 2mA units) : 100mA
|
198 |
|
|
|
199 |
|
|
// Interface descriptors
|
200 |
|
|
#define INTERFACE(num, body) , \
|
201 |
|
|
0x09, /* 0, Descriptor size */ \
|
202 |
|
|
CY_U3P_USB_INTRFC_DESCR, /* 1, Interface Descriptor type */ \
|
203 |
|
|
num, /* 2, Interface number */ \
|
204 |
|
|
0x00, /* 3, Alternate setting number */ \
|
205 |
|
|
interface_eps_##num, /* 4, Number of end points */ \
|
206 |
|
|
0xFF, /* 5, Interface class */ \
|
207 |
|
|
0x00, /* 5, Interface sub class */ \
|
208 |
|
|
0x00, /* 6, Interface protocol code */ \
|
209 |
|
|
num < 8 ? num+4 : 0 /* 7, Interface descriptor string index */ \
|
210 |
|
|
/* String can be set using ztex_interface_string[] */ \
|
211 |
|
|
body
|
212 |
|
|
|
213 |
|
|
// Endpoint descriptors
|
214 |
|
|
#define EP(num,dir,type,size,burst,interval,settings) , \
|
215 |
|
|
0x07, /* 0, Descriptor size */ \
|
216 |
|
|
CY_U3P_USB_ENDPNT_DESCR, /* 1, Endpoint descriptor type */ \
|
217 |
|
|
DIR_##dir + num, /* 2, Endpoint number + direction */ \
|
218 |
|
|
TYPE_##type, /* 3, endpoint type */ \
|
219 |
|
|
W2B( (((TYPE_##type==2) && (size>512)) ? 512 : size) | (TYPE_##type==2 ? 0 : (((burst > 3 ? 3 : burst)-1) << 11) ) ), /* 4, Max packet for bulk transfers limited to 512 bytes */ \
|
220 |
|
|
interval /* 6, Service interval */
|
221 |
|
|
EP_SETUP_ALL
|
222 |
|
|
#undef INTERFACE
|
223 |
|
|
#undef EP
|
224 |
|
|
};
|
225 |
|
|
|
226 |
|
|
// full speed configuration descriptor
|
227 |
|
|
const uint8_t ztex_usb1_config_descriptor[] __attribute__ ((aligned (32))) =
|
228 |
|
|
{
|
229 |
|
|
// Configuration descriptor
|
230 |
|
|
9, // 0, Descriptor size
|
231 |
|
|
CY_U3P_USB_CONFIG_DESCR, // 1, Configuration descriptor type
|
232 |
|
|
#define INTERFACE(a,b) +9 b
|
233 |
|
|
#define EP(num,dir,type,size,burst,interval,settings) +7
|
234 |
|
|
W2B(9 EP_SETUP_ALL), // 2, Length of this descriptor and all sub descriptors
|
235 |
|
|
#undef INTERFACE
|
236 |
|
|
#undef EP
|
237 |
|
|
#define INTERFACE(a,b) +1
|
238 |
|
|
|
239 |
|
|
#undef INTERFACE
|
240 |
|
|
0x01, // 5, Configuration number
|
241 |
|
|
0x00, // 6, Configuration string index
|
242 |
|
|
0x80, // 7, attributes: bus
|
243 |
|
|
50 // 8, Max power consumption of device (in 2mA units) : 100mA
|
244 |
|
|
|
245 |
|
|
// Interface descriptors
|
246 |
|
|
#define INTERFACE(num, body) , \
|
247 |
|
|
0x09, /* 0, Descriptor size */ \
|
248 |
|
|
CY_U3P_USB_INTRFC_DESCR, /* 1, Interface Descriptor type */ \
|
249 |
|
|
num, /* 2, Interface number */ \
|
250 |
|
|
0x00, /* 3, Alternate setting number */ \
|
251 |
|
|
interface_eps_##num, /* 4, Number of end points */ \
|
252 |
|
|
0xFF, /* 5, Interface class */ \
|
253 |
|
|
0x00, /* 5, Interface sub class */ \
|
254 |
|
|
0x00, /* 6, Interface protocol code */ \
|
255 |
|
|
num < 8 ? num+4 : 0 /* 7, Interface descriptor string index */ \
|
256 |
|
|
/* String can be set using ztex_interface_string[] */ \
|
257 |
|
|
body
|
258 |
|
|
|
259 |
|
|
// Endpoint descriptors
|
260 |
|
|
#define EP(num,dir,type,size,burst,interval,settings) , \
|
261 |
|
|
0x07, /* 0, Descriptor size */ \
|
262 |
|
|
CY_U3P_USB_ENDPNT_DESCR, /* 1, Endpoint descriptor type */ \
|
263 |
|
|
DIR_##dir + num, /* 2, Endpoint number + direction */ \
|
264 |
|
|
TYPE_##type, /* 3, endpoint type */ \
|
265 |
|
|
W2B(64), /* 4, size ficed to 64 bytes */ \
|
266 |
|
|
1 /* 6, Service interval */
|
267 |
|
|
EP_SETUP_ALL
|
268 |
|
|
#undef INTERFACE
|
269 |
|
|
#undef EP
|
270 |
|
|
};
|
271 |
|
|
|
272 |
|
|
// language string descriptor */
|
273 |
|
|
const uint8_t ztex_lang_string_descriptor[] __attribute__ ((aligned (32))) =
|
274 |
|
|
{
|
275 |
|
|
0x04, // Descriptor size
|
276 |
|
|
CY_U3P_USB_STRING_DESCR, // Device descriptor type
|
277 |
|
|
0x04, 0x09
|
278 |
|
|
};
|
279 |
|
|
|
280 |
|
|
/* Place this buffer as the last buffer so that no other variable / code shares
|
281 |
|
|
the same cache line. Do not add any other variables / arrays in this file.
|
282 |
|
|
This will lead to variables sharing the same cache line. */
|
283 |
|
|
const uint8_t descriptor_allign_buffer[32] __attribute__ ((aligned (32)));
|
284 |
|
|
|
285 |
|
|
|
286 |
|
|
const uint8_t ztex_descriptor[] __attribute__ ((aligned (32))) =
|
287 |
|
|
{
|
288 |
|
|
40, // Descriptor size
|
289 |
|
|
0x01, // Descriptor version
|
290 |
|
|
'Z','T','E','X', // Signature "ZTEX"
|
291 |
|
|
|
292 |
|
|
ZTEX_PRODUCT_ID_0, // product ID's
|
293 |
|
|
ZTEX_PRODUCT_ID_1,
|
294 |
|
|
ZTEX_PRODUCT_ID_2,
|
295 |
|
|
ZTEX_PRODUCT_ID_3,
|
296 |
|
|
|
297 |
|
|
ZTEX_FWVER, // firmware version
|
298 |
|
|
|
299 |
|
|
1, // interface version
|
300 |
|
|
|
301 |
|
|
// interface capabilities
|
302 |
|
|
|
303 |
|
|
#ifdef _ZTEX_FPGA_
|
304 |
|
|
| 2 // FPGA configuration support
|
305 |
|
|
#endif
|
306 |
|
|
#ifdef ENABLE_SPI_FLASH
|
307 |
|
|
| 4 // SPI Flash support
|
308 |
|
|
#endif
|
309 |
|
|
#ifdef ZTEX_FPGA_CONF_FAST_EP
|
310 |
|
|
| 32 // fast FPGA configuration support
|
311 |
|
|
#endif
|
312 |
|
|
#ifdef ENABLE_I2C
|
313 |
|
|
| 64 // MAC EEPROM support
|
314 |
|
|
#endif
|
315 |
|
|
,
|
316 |
|
|
4 | 8 // FX3, debug2
|
317 |
|
|
#ifdef ENABLE_SD_FLASH
|
318 |
|
|
| 2 // SD Flash support
|
319 |
|
|
#endif
|
320 |
|
|
#ifdef _ZTEX_LSI_
|
321 |
|
|
| 16 // default firmware interface support
|
322 |
|
|
#endif
|
323 |
|
|
,
|
324 |
|
|
0,
|
325 |
|
|
0,
|
326 |
|
|
0,
|
327 |
|
|
0,
|
328 |
|
|
|
329 |
|
|
ZTEX_MODULE_RESERVED_00, // 11 bytes which can be used by application
|
330 |
|
|
ZTEX_MODULE_RESERVED_01,
|
331 |
|
|
ZTEX_MODULE_RESERVED_02,
|
332 |
|
|
ZTEX_MODULE_RESERVED_03,
|
333 |
|
|
ZTEX_MODULE_RESERVED_04,
|
334 |
|
|
ZTEX_MODULE_RESERVED_05,
|
335 |
|
|
ZTEX_MODULE_RESERVED_06,
|
336 |
|
|
ZTEX_MODULE_RESERVED_07,
|
337 |
|
|
ZTEX_MODULE_RESERVED_08,
|
338 |
|
|
ZTEX_MODULE_RESERVED_09,
|
339 |
|
|
ZTEX_MODULE_RESERVED_10,
|
340 |
|
|
|
341 |
|
|
207, // must be 207 for FX3 firmwares
|
342 |
|
|
|
343 |
|
|
'0','0','0','0', '0','0','0','0', '0','0' // 1 bytes serial number string
|
344 |
|
|
};
|
345 |
|
|
|
346 |
|
|
#undef W2B
|
347 |
|
|
#undef DIR_IN
|
348 |
|
|
#undef DIR_OUT
|
349 |
|
|
#undef TYPE_ISO
|
350 |
|
|
#undef TYPE_BULK
|
351 |
|
|
#undef TYPE_INT
|
352 |
|
|
|
353 |
|
|
uint8_t ztex_ep0buf[4096] __attribute__ ((aligned (32)));
|
354 |
|
|
|
355 |
|
|
const char ztex_manufacturer_string[] = ZTEX_MANUFACTURER_STRING;
|
356 |
|
|
|
357 |
|
|
char ztex_product_string[64] = ZTEX_PRODUCT_STRING;
|
358 |
|
|
|
359 |
|
|
char ztex_sn_string[] = "0000000000";
|
360 |
|
|
|
361 |
|
|
#endif // _ZTEX_DESCRIPTORS_C_
|