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

Subversion Repositories usb_fpga_1_2

[/] [usb_fpga_1_2/] [trunk/] [include/] [ztex-descriptors.h] - Blame information for rev 8

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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