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 3

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

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

powered by: WebSVN 2.1.0

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