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

Subversion Repositories usb_fpga_2_16

[/] [usb_fpga_2_16/] [trunk/] [include/] [ztex-descriptors.h] - Blame information for rev 3

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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