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

Subversion Repositories usb_fpga_1_11

[/] [usb_fpga_1_11/] [trunk/] [include/] [ztex-descriptors.h] - Blame information for rev 2

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

powered by: WebSVN 2.1.0

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