OpenCores
URL https://opencores.org/ocsvn/usb_fpga_2_14/usb_fpga_2_14/trunk

Subversion Repositories usb_fpga_2_14

[/] [usb_fpga_2_14/] [trunk/] [fx2/] [ztex-descriptors.h] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 ZTEX
/*%
2
   ZTEX Firmware Kit for EZ-USB FX2 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
/*
27
   Defines the USB descriptors
28
*/
29
 
30
#ifndef[ZTEX_DESCRIPTORS_H]
31
#define[ZTEX_DESCRIPTORS_H]
32
 
33
#define[ZTEX_DESCRIPTOR_OFFS][0x06c]
34
#define[ZTEX_DESCRIPTOR_LEN][40]
35
 
36
__xdata __at ZTEX_DESCRIPTOR_OFFS BYTE ZTEX_DESCRIPTOR;
37
 
38
/* ZTEX descriptor version. Must be 1. */
39
__xdata __at ZTEX_DESCRIPTOR_OFFS+1 BYTE ZTEX_DESCRIPTOR_VERSION;
40
 
41
/* Must not be modified, ID="ZTEX" */
42
__xdata __at ZTEX_DESCRIPTOR_OFFS+2 BYTE ZTEXID[4];
43
 
44
/*
45
   Product ID and firmware compatibility information.
46
 
47
   A firmware can overwrite an installed one if
48
   if ( INSTALLED.PRODUCTID[0]==0 || PRODUCTID[0]==0 || INSTALLED.PRODUCTID[0]==PRODUCTID[0] ) &&
49
      ( INSTALLED.PRODUCTID[1]==0 || PRODUCTID[1]==0 || INSTALLED.PRODUCTID[1]==PRODUCTID[1] ) &&
50
      ( INSTALLED.PRODUCTID[2]==0 || PRODUCTID[2]==0 || INSTALLED.PRODUCTID[2]==PRODUCTID[2] ) &&
51
      ( INSTALLED.PRODUCTID[3]==0 || PRODUCTID[3]==0 || INSTALLED.PRODUCTID[3]==PRODUCTID[3] )
52
 
53
   Reserved Product ID's:
54
 
55
   0.0.0.0              // default Product ID (no product specified)
56
   1.*.*.*              // may be used for experimental purposes
57
   10.*.*.*             // used for ZTEX products
58
   10.11.*.*            // ZTEX USB-FPGA-Module 1.2
59
   10.12.*.*            // ZTEX USB-FPGA-Module 1.11
60
   10.12.2.1..4         // NIT (http://www.niteurope.com/)
61
   10.13.*.*            // ZTEX USB-FPGA-Module 1.15 (not 1.15y)
62
   10.14.*.*            // ZTEX USB-FPGA-Module 1.15x
63
   10.15.*.*            // ZTEX USB-FPGA-Module 1.15y
64
   10.16.*.*            // ZTEX USB-FPGA-Module 2.16
65
   10.17.*.*            // ZTEX USB-FPGA-Module 2.13
66
   10.18.*.*            // ZTEX USB-FPGA-Module 2.01
67
   10.19.*.*            // ZTEX USB-FPGA-Module 2.04
68
   10.20.*.*            // ZTEX USB-Module 1.0
69
   10.30.*.*            // ZTEX USB-XMEGA-Module 1.0
70
   10.40.*.*            // ZTEX USB-FPGA-Module 2.02
71
   10.41.*.*            // ZTEX USB-FPGA-Module 2.14
72
   10.42.*.*            // ZTEX USB-FPGA-Module 2.18
73
   10.0.1.1             // ZTEX bitminer firmware
74
 
75
   Please contact us (http://www.ztex.de/contact.e.html) if you want to register/reserve a Product ID (range).
76
*/
77
__xdata __at ZTEX_DESCRIPTOR_OFFS+6 BYTE PRODUCT_ID[4];
78
 
79
/* Firmware version, may be used to distinguish seveveral firmware versions */
80
__xdata __at ZTEX_DESCRIPTOR_OFFS+10 BYTE FW_VERSION;
81
 
82
/* Interface version. Must be 1. */
83
__xdata __at ZTEX_DESCRIPTOR_OFFS+11 BYTE INTERFACE_VERSION;
84
 
85
/*
86
    Standard interface capabilities:
87
        0.0  : EEPROM read/write, see ztex-eeprom.h
88
        0.1  : FPGA configuration, see ztex-fpga.h
89
        0.2  : Flash memory support, see ztex-flash1.h
90
        0.3  : Debug helper, see ztex-debug.h
91
        0.4  : AVR XMEGA support, see ztex-xmega.h
92
        0.5  : High speed FPGA configuration support
93
        0.6  : MAC EEPROM support
94
        0.7  : Multi-FPGA support
95
        1.0  : Temperature sensor support
96
*/
97
__xdata __at ZTEX_DESCRIPTOR_OFFS+12 BYTE INTERFACE_CAPABILITIES[6];
98
 
99
/* Space for settings which depends on PRODUCT_ID, e.g extra capabilities */
100
__xdata __at ZTEX_DESCRIPTOR_OFFS+18 BYTE MODULE_RESERVED[12];
101
 
102
/*
103
   Serial number string
104
   default: "0000000000"
105
   Should only be modified by the the firmware upload software
106
*/
107
__xdata __at ZTEX_DESCRIPTOR_OFFS+30 BYTE SN_STRING[10];
108
 
109
/* Are Vendor ID and Product ID defined? */
110
#ifndef[USB_VENDOR_ID]
111
#error[No USB Vendor ID defined]
112
#endif
113
 
114
#ifndef[USB_PRODUCT_ID]
115
#error[No USB Product ID defined]
116
#endif
117
 
118
/* Prepare the Interfaces, i.e. check which interfaces are defined */
119
#define[CONFIGURE_INTERFACE(][);][
120
#define[CONFIG_INTERFACE$0]
121
#ifeq[EP1IN_INTERFACE][$0]
122
#elifeq[EP1OUT_INTERFACE][$0]
123
#elifeq[EP2_INTERFACE][$0]
124
#elifeq[EP4_INTERFACE][$0]
125
#elifeq[EP6_INTERFACE][$0]
126
#elifneq[EP8_INTERFACE][$0]
127
#udefine[CONFIG_INTERFACE$0]
128
#endif
129
#ifdef[CONFIG_INTERFACE$0]
130
//Interface $0: YES
131
#else
132
//Interface $0: NO
133
#endif]
134
 
135
CONFIGURE_INTERFACE(0);
136
CONFIGURE_INTERFACE(1);
137
CONFIGURE_INTERFACE(2);
138
CONFIGURE_INTERFACE(3);
139
 
140
/* define the ZTEX descriptor */
141
void abscode_identity()// _naked
142
{
143
    __asm
144
    .area ABSCODE (ABS,CODE)
145
 
146
    .org ZTEX_DESCRIPTOR_OFFS
147
    .db ZTEX_DESCRIPTOR_LEN
148
 
149
    .org _ZTEX_DESCRIPTOR_VERSION
150
    .db 1
151
 
152
    .org _ZTEXID
153
    .ascii "ZTEX"
154
 
155
    .org _PRODUCT_ID
156
    .db PRODUCT_ID_0
157
    .db PRODUCT_ID_1
158
    .db PRODUCT_ID_2
159
    .db PRODUCT_ID_3
160
 
161
    .org _FW_VERSION
162
    .db FWVER
163
 
164
    .org _INTERFACE_VERSION
165
    .db 1
166
 
167
    .org _INTERFACE_CAPABILITIES
168
    .db 0
169
#ifdef[@CAPABILITY_EEPROM;]
170
#nolf
171
 + 1
172
#endif
173
#ifdef[@CAPABILITY_FPGA;]
174
#nolf
175
 + 2
176
#endif
177
#ifdef[@CAPABILITY_FLASH;]
178
#nolf
179
 + 4
180
#endif
181
#ifdef[@CAPABILITY_DEBUG;]
182
#nolf
183
 + 8
184
#endif
185
#ifdef[@CAPABILITY_XMEGA;]
186
#nolf
187
 + 16
188
#endif
189
#ifdef[@CAPABILITY_HS_FPGA;]
190
#nolf
191
 + 32
192
#endif
193
#ifdef[@CAPABILITY_MAC_EEPROM;]
194
#nolf
195
 + 64
196
#endif
197
#ifdef[@CAPABILITY_MULTI_FPGA;]
198
#nolf
199
 + 128
200
#endif
201
    .db 0
202
#ifdef[@CAPABILITY_FLASH2;]
203
#nolf
204
 + 2
205
#endif
206
#ifdef[@CAPABILITY_LSI;]
207
#nolf
208
 + 16
209
#endif
210
    .db 0
211
    .db 0
212
    .db 0
213
    .db 0
214
 
215
    .org _MODULE_RESERVED
216
    .db MODULE_RESERVED_00
217
    .db MODULE_RESERVED_01
218
    .db MODULE_RESERVED_02
219
    .db MODULE_RESERVED_03
220
    .db MODULE_RESERVED_04
221
    .db MODULE_RESERVED_05
222
    .db MODULE_RESERVED_06
223
    .db MODULE_RESERVED_07
224
    .db MODULE_RESERVED_08
225
    .db MODULE_RESERVED_09
226
    .db MODULE_RESERVED_10
227
    .db MODULE_RESERVED_11
228
 
229
    .org _SN_STRING
230
    .ascii "0000000000"
231
 
232
    .area CSEG    (CODE)
233
    __endasm;
234
}
235
 
236
/* *********************************************************************
237
   ***** strings *******************************************************
238
   ********************************************************************* */
239
__code char manufacturerString[] = MANUFACTURER_STRING;
240
__code char productString[33] = PRODUCT_STRING"\0";
241
__code char configurationString[] = CONFIGURATION_STRING;
242
 
243
/* *********************************************************************
244
   ***** descriptors ***************************************************
245
   ********************************************************************* */
246
#define[EP_DESCRIPTOR(][);][
247
                                // Endpoint $0 descriptor
248
        ,7                      // 0, Descriptor length
249
        ,5                      // 1, Descriptor type
250
#ifeq[$0][1IN]
251
        ,0x81                   // 2, direction=output, address=1
252
#elifeq[$0][1OUT]
253
        ,0x01                   // 2, direction=output, address=1
254
#elifeq[EP$0_DIR][IN]           
255
        ,0x80+$0                 // 2, direction=output, address=$0
256
#elifeq[EP$0_DIR][OUT]
257
        ,$0                      // 2, direction=input, address=$0
258
#else
259
#error[Invalid direction for endpoint $0 (`IN' or `OUT' expected)]
260
#endif
261
#ifeq[EP$0_TYPE][ISO]
262
        ,1                      // 3, ISO transferns
263
#elifeq[EP$0_TYPE][BULK]
264
        ,2                      // 3, BULK transferns
265
#elifeq[EP$0_TYPE][INT]
266
        ,3                      // 3, INT transferns
267
#else
268
#error[Invalid type for endpoint $0: `EP$0_TYPE' (`ISO', 'BULK' or `INT' expected)]
269
#endif 
270
#ifdef[HIGH_SPEED]
271
        ,EP$0_SIZE & 0xff        // 4, max. packet size (L) 
272
        ,EP$0_SIZE >> 8  // 5, max. packet size (H) 
273
#ifneq[EP$0_TYPE][BULK]
274
            | ( (EP$0_PPMF-1) << 3 )
275
#endif
276
#else
277
        ,64                     // 4, max. packet size (L) 
278
        ,0                       // 5, max. packet size (H) 
279
#endif  
280
#ifeq[EP$0_TYPE][BULK]
281
        ,0                       // 6, Polling interval
282
#elifeq[EP$0_TYPE][ISO]
283
        ,1                      // 6, Polling interval (1ms if Full Speed mode, 125µs in High Speed Mode)
284
#else
285
        ,EP$0_POLL               // 6, Polling interval (1ms if Full Speed mode, 125µs in High Speed Mode)
286
#endif  
287
]
288
 
289
#define[INTERFACE_DESCRIPTOR(][);][
290
                // Interface $0 descriptor
291
        ,9      // 0, Descriptor length
292
        ,0x04   // 1, Descriptor type
293
        ,0       // 2, Zero-based index of this interface
294
#ifneq[$0][0]
295
#ifdef[CONFIG_INTERFACE0]
296
          +1
297
#endif
298
#ifneq[$0][1]
299
#ifdef[CONFIG_INTERFACE1]
300
          +1
301
#endif
302
#ifneq[$0][2]
303
#ifdef[CONFIG_INTERFACE2]
304
          +1
305
#endif
306
#endif
307
#endif
308
#endif
309
        ,0       // 3, Alternate setting 0
310
        ,0       // 4, Number of end points 
311
#ifeq[EP1IN_INTERFACE][$0]
312
          +1
313
#endif    
314
#ifeq[EP1OUT_INTERFACE][$0]
315
          +1
316
#endif    
317
#ifeq[EP2_INTERFACE][$0]
318
          +1
319
#endif    
320
#ifeq[EP4_INTERFACE][$0]
321
          +1
322
#endif    
323
#ifeq[EP6_INTERFACE][$0]
324
          +1
325
#endif    
326
#ifeq[EP8_INTERFACE][$0]
327
          +1
328
#endif    
329
        ,0xff   // 5, Interface class
330
        ,0xff   // 6, Interface sub class
331
        ,0xff   // 7, Interface protocol
332
        ,0       // 8, Index of interface string descriptor
333
#ifeq[EP1IN_INTERFACE][$0]
334
         EP_DESCRIPTOR(1IN);
335
#endif    
336
#ifeq[EP1OUT_INTERFACE][$0]
337
         EP_DESCRIPTOR(1OUT);
338
#endif    
339
#ifeq[EP2_INTERFACE][$0]
340
         EP_DESCRIPTOR(2);
341
#endif    
342
#ifeq[EP4_INTERFACE][$0]
343
         EP_DESCRIPTOR(4);
344
#endif    
345
#ifeq[EP6_INTERFACE][$0]
346
         EP_DESCRIPTOR(6);
347
#endif    
348
#ifeq[EP8_INTERFACE][$0]
349
         EP_DESCRIPTOR(8);
350
#endif
351
]
352
 
353
#define[APPEND_PADBYTE(][);][__code BYTE $0_PadByte[2-(sizeof($0) & 1)] = { 0 };]
354
 
355
#ifdef[PAD_BYTE]                // to ensure word alignment of the descriptors; PAD_BYTE is defined automatically by bmpsdcc script
356
__code BYTE PadByte = 0;
357
#endif
358
 
359
__code BYTE DeviceDescriptor[] =
360
    {
361
        18,     // 0, Descriptor length
362
        0x01,   // 1, Descriptor type
363
        0x00,   // 2, Specification Version (L)
364
        0x02,   // 3, Specification Version (H)
365
        0xff,   // 4, Device class
366
        0xff,   // 5, Device sub-class
367
        0xff,   // 6, Device protocol
368
        64,     // 7, Maximum packet size for EP0
369
        (USB_VENDOR_ID) & 255,  // 8, VENDOR_ID (L)
370
        (USB_VENDOR_ID) >> 8,   // 9, VENDOR_ID (H)
371
        (USB_PRODUCT_ID) & 255, // 10, PRODUCT_ID (L)
372
        (USB_PRODUCT_ID) >> 8,  // 11, PRODUCT_ID (H)
373
        0x00,   // 12, device release number (BCD, L)
374
        0x00,   // 13, device release number (BCD, H)
375
        1,      // 14, Manufacturer string index
376
        2,      // 15, Product string index
377
        3,      // 16, Serial number string index
378
        1       // 17, Number of configurations
379
    };
380
 
381
__code BYTE DeviceQualifierDescriptor[] =
382
    {
383
        10,     // 0, Descriptor length
384
        0x06,   // 1, Decriptor type
385
        0x00,   // 2, Specification Version (L)
386
        0x02,   // 3, Specification Version (H)
387
        0xff,   // 4, Device class
388
        0xff,   // 5, Device sub-class
389
        0xff,   // 6, Device protocol
390
        64,     // 7, Maximum packet size (EP0?)
391
        1,      // 8, Number of configurations
392
        0,       // 9, Reserved, must be zero
393
    };
394
 
395
__code BYTE HighSpeedConfigDescriptor[] =
396
    {
397
#define[HIGH_SPEED]
398
        9       // 0, Descriptor length
399
        ,0x02   // 1, Decriptor type
400
        ,sizeof(HighSpeedConfigDescriptor) & 0xff       // 2, Total length (LSB)
401
//      ,sizeof(HighSpeedConfigDescriptor) >> 8         // 3, Total length (MB)
402
        ,0                                               // 3, To avoid warnings, descriptor length will never exceed 255 bytes
403
        ,0       // 4, Number of Interfaces
404
#ifdef[CONFIG_INTERFACE0]
405
          +1
406
#endif
407
#ifdef[CONFIG_INTERFACE1]
408
          +1
409
#endif
410
#ifdef[CONFIG_INTERFACE2]
411
          +1
412
#endif
413
#ifdef[CONFIG_INTERFACE3]
414
          +1
415
#endif
416
 
417
        ,1      // 5, Configuration number
418
        ,4      // 6, Configuration string
419
        ,0xc0   // 7, Attributes: bus and self powered
420
        ,50     // Maximum bus power 100 mA
421
#ifdef[CONFIG_INTERFACE0]
422
        INTERFACE_DESCRIPTOR(0);
423
#endif
424
#ifdef[CONFIG_INTERFACE1]
425
        INTERFACE_DESCRIPTOR(1);
426
#endif
427
#ifdef[CONFIG_INTERFACE2]
428
        INTERFACE_DESCRIPTOR(2);
429
#endif
430
#ifdef[CONFIG_INTERFACE3]
431
        INTERFACE_DESCRIPTOR(3);
432
#endif
433
#udefine[HIGH_SPEED]
434
    };
435
APPEND_PADBYTE(HighSpeedConfigDescriptor);
436
 
437
__code BYTE FullSpeedConfigDescriptor[] =
438
    {
439
        9       // 0, Descriptor length
440
        ,0x02   // 1, Decriptor type
441
        ,sizeof(FullSpeedConfigDescriptor) & 0xff       // 2, Total length (LSB)
442
//      ,sizeof(FullSpeedConfigDescriptor) >> 8         // 3, Total length (MSB)
443
        ,0                                               // 3, To avoid warnings, descriptor length will never exceed 255 bytes
444
        ,0       // 4, Number of Interfaces
445
#ifdef[CONFIG_INTERFACE0]
446
          +1
447
#endif
448
#ifdef[CONFIG_INTERFACE1]
449
          +1
450
#endif
451
#ifdef[CONFIG_INTERFACE2]
452
          +1
453
#endif
454
#ifdef[CONFIG_INTERFACE3]
455
          +1
456
#endif
457
 
458
        ,1      // 5, Configuration number
459
        ,4      // 6, Configuration string
460
        ,0xc0   // 7, Attributes: bus and self powered
461
        ,50     // Maximum bus power 100 mA
462
#ifdef[CONFIG_INTERFACE0]
463
        INTERFACE_DESCRIPTOR(0);
464
#endif
465
#ifdef[CONFIG_INTERFACE1]
466
        INTERFACE_DESCRIPTOR(1);
467
#endif
468
#ifdef[CONFIG_INTERFACE2]
469
        INTERFACE_DESCRIPTOR(2);
470
#endif
471
#ifdef[CONFIG_INTERFACE3]
472
        INTERFACE_DESCRIPTOR(3);
473
#endif
474
    };
475
APPEND_PADBYTE(FullSpeedConfigDescriptor);
476
 
477
__code BYTE LangStringDescriptor[] =
478
    {
479
        sizeof(LangStringDescriptor),           // Length
480
        0x03,                                   // Descriptor type
481
        0x04, 0x09
482
    };
483
 
484
#endif  /*ZTEX_DESCRIPTORS_H*/

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.