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

powered by: WebSVN 2.1.0

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