Subversion Repositories svn.mios

Rev

Rev 421 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
416 tk 1
// $Id: eeprom_content.c 980 2011-03-20 20:07:11Z tk $
2
//
3
//  Optional USB Descriptors for MBHP_USB_GM5 module, which can
4
//  be stored in an external IIC EEPROM to customize the PID/VID (and more)
5
//
6
//  The tables are statically located at 0x7000 to simplify the programming
7
//  of the EEPROM
8
//
9
// ==========================================================================
10
//
11
//  Copyright 2008 Thorsten Klose (tk@midibox.org)
12
//  Licensed for personal non-commercial use only.
13
//  All other rights reserved.
14
// 
15
// ==========================================================================
16
 
17
/////////////////////////////////////////////////////////////////////////////
18
// Include files
19
/////////////////////////////////////////////////////////////////////////////
20
 
21
#include <cmios.h>
22
#include <pic18fregs.h>
23
 
24
#include <iic_eeprom8.h>
25
#include "eeprom_content.h"
26
 
27
 
28
/////////////////////////////////////////////////////////////////////////////
29
// Local Definitions
30
/////////////////////////////////////////////////////////////////////////////
31
 
32
// 1 to stay compatible to USB MIDI spec, 0 as workaround for some windows versions...
33
#define USE_AC_INTERFACE        1
34
 
35
// allowed numbers: 1..5
36
#define NUMBER_MIDI_INTERFACES  3
37
 
38
 
39
// don't touch
40
#define DSCR_DEVICE 1   // Descriptor type: Device
41
#define DSCR_CONFIG 2   // Descriptor type: Configuration
42
#define DSCR_STRING 3   // Descriptor type: String
43
#define DSCR_INTRFC 4   // Descriptor type: Interface
44
#define DSCR_ENDPNT 5   // Descriptor type: Endpoint
45
 
46
#define CS_INTERFACE    0x24    // Class-specific type: Interface
47
#define CS_ENDPOINT 0x25    // Class-specific type: Endpoint
48
 
49
 
50
/////////////////////////////////////////////////////////////////////////////
51
// Local Variables
52
/////////////////////////////////////////////////////////////////////////////
53
 
54
// for debugging - reads back EEPROM content, so that it can be read into the MIOS Studio Debug Window
55
unsigned char eeprom_content[0x100];
56
 
57
 
58
/////////////////////////////////////////////////////////////////////////////
59
// String descriptors
60
/////////////////////////////////////////////////////////////////////////////
61
 
62
const unsigned char __at(0x7010) USBDSC_STR0[] = {
63
  4,                            // String descriptor length
64
  DSCR_STRING,          // Descriptor Type
65
  0x09, 0x04,           // Charset
66
};
67
 
68
const unsigned char __at(0x7014) USBDSC_STR1[] = {
69
  sizeof(USBDSC_STR1)*2-2,      // String descriptor length
70
  DSCR_STRING,          // Descriptor Type
71
  'w',                          // String (for GM5 in ASCII, not Unicode!)
72
  'w',
73
  'w',
74
  '.',
75
  'm',
76
  'i',
77
  'd',
78
  'i',
79
  'b',
80
  'o',
81
  'x',
82
  '.',
83
  'o',
84
  'r',
85
  'g',
86
};
87
 
88
const unsigned char __at(0x7028) USBDSC_STR2[] = {
89
  sizeof(USBDSC_STR2)*2-2,      // String descriptor length
90
  DSCR_STRING,          // Descriptor Type
91
  'M',                          // String (for GM5 in ASCII, not Unicode!)
92
  'B',
93
  'H',
94
  'P',
95
  ' ',
96
  'U',
97
  'S',
98
  'B',
99
  ' ',
100
  'G',
101
  'M',
102
  '5',
103
};
104
 
105
const unsigned char __at(0x7038) USBDSC_STR3[] = {
106
  sizeof(USBDSC_STR3)*2-2,      // String descriptor length
107
  DSCR_STRING,          // Descriptor Type
108
  'G',                          // String (for GM5 in ASCII, not Unicode!)
109
  'M',
110
  '5',
111
};
112
 
113
 
114
/////////////////////////////////////////////////////////////////////////////
115
// Device descriptor
116
/////////////////////////////////////////////////////////////////////////////
117
 
118
const unsigned char __at(0x7040) USBDSC_DEVICE[] = {
119
  // MIDI Adapter Device Descriptor
120
  sizeof(USBDSC_DEVICE),    // Descriptor length
121
  DSCR_DEVICE,          // Decriptor type
122
  0x0200 & 0xff,        // Specification Version (BCD, LSB)
123
  0x0200 >> 8,          // Specification Version (BCD, MSB)
124
  0x00,             // Device class
125
  0x00,             // Device sub-class
126
  0x00,             // Device sub-sub-class
127
  0x10,             // Maximum packet size for EP0
128
  0x16c0 & 0xff,        // Vendor ID 16C0 --- sponsored by voti.nl! see http://www.voti.nl/pids
129
  0x16c0 >> 8,          // Vendor ID (MSB)
130
  1022 & 0xff,          // Product ID (LSB)
131
  1022 >> 8,            // Product ID (MSB)
132
  0x0000 & 0xff,        // Product version ID (LSB)
133
  0x0001 >> 8,          // Product version ID (MSB)
134
  0x01,             // Manufacturer string index
135
  0x02,             // Product string index
136
  0x00,             // Serial number string index
137
  0x01,             // Number of configurations
138
};
139
 
140
 
141
/////////////////////////////////////////////////////////////////////////////
142
// Configuration descriptor
143
/////////////////////////////////////////////////////////////////////////////
144
 
145
const unsigned char __at(0x7052) USBDSC_CFG[] = {
146
  // Configuration Descriptor
147
  9,                // Descriptor length
148
  DSCR_CONFIG,          // Descriptor type
149
  sizeof(USBDSC_CFG)&0xff,  // Config + End Points length (LSB)
150
  sizeof(USBDSC_CFG)>>8,    // Config + End Points length (MSB)
151
#if USE_AC_INTERFACE
152
  0x02,             // Number of interfaces
153
#else
154
  0x01,             // Number of interfaces
155
#endif
156
  0x01,             // Interface number
157
  0x00,             // Configuration string
158
  0x80,             // Attributes (b7 - buspwr, b6 - selfpwr, b5 - rwu)
159
  0x10,             // Power requirement (div 2 ma)
160
#if USE_AC_INTERFACE
161
  // Standard AC Interface Descriptor
162
  9,                // Descriptor length
163
  DSCR_INTRFC,          // Descriptor type
164
  0x00,             // Zero-based index of this interface
165
  0x00,             // Alternate setting
166
  0x00,             // Number of end points 
167
  0x01,             // Interface class  (AUDIO)
168
  0x01,             // Interface sub class  (AUDIO_CONTROL)
169
  0x00,             // Interface sub sub class
170
  0x00,             // Interface descriptor string index
171
 
172
  // MIDI Adapter Class-specific AC Interface Descriptor
173
  9,                // Descriptor length
174
  CS_INTERFACE,         // Descriptor type
175
  0x01,             // Header subtype
176
  0x00,             // Revision of class specification - 1.0 (LSB)
177
  0x01,             // Revision of class specification (MSB)
178
  9,                // Total size of class-specific descriptors (LSB)
179
  0,                // Total size of class-specific descriptors (MSB)
180
  0x01,             // Number of streaming interfaces
181
  0x01,             // MIDI Streaming Interface 1 belongs to this AudioControl Interface
182
#endif
183
 
184
  // Standard MS Interface Descriptor
185
  9,                // Descriptor length
186
  DSCR_INTRFC,          // Descriptor type
187
#if USE_AC_INTERFACE
188
  0x01,             // Zero-based index of this interface
189
#else
190
  0x00,             // Zero-based index of this interface
191
#endif
192
  0x00,             // Alternate setting
193
  0x02,             // Number of end points 
194
  0x01,             // Interface class  (AUDIO)
195
  0x03,             // Interface sub class  (MIDISTREAMING)
196
  0x00,             // Interface sub sub class
197
  0x00,             // Interface descriptor string index
198
 
199
  // Class-specific MS Interface Descriptor
200
  7,                // Descriptor length
201
  CS_INTERFACE,         // Descriptor type
202
#if USE_AC_INTERFACE
203
  0x01,             // Zero-based index of this interface
204
#else
205
  0x00,             // Zero-based index of this interface
206
#endif
207
  0x00,             // revision of this class specification (LSB)
208
  0x01,             // revision of this class specification (MSB)
209
                // Total size of class-specific descriptors (LSB)
210
  7+(NUMBER_MIDI_INTERFACES)*(6+6+9+9)+9+(4+NUMBER_MIDI_INTERFACES)+9+(4+NUMBER_MIDI_INTERFACES),
211
  0,                // Total size of class-specific descriptors (MSB)
212
 
213
  // MIDI IN Jack Descriptor (Embedded)
214
  6,                // Descriptor length
215
  CS_INTERFACE,         // Descriptor type (CS_INTERFACE)
216
  0x02,             // MIDI_IN_JACK subtype
217
  0x01,             // EMBEDDED
218
  0x01,             // ID of this jack
219
  0x00,             // unused
220
 
221
  // MIDI Adapter MIDI IN Jack Descriptor (External)
222
  6,                // Descriptor length
223
  CS_INTERFACE,         // Descriptor type (CS_INTERFACE)
224
  0x02,             // MIDI_IN_JACK subtype
225
  0x02,             // EXTERNAL
226
  0x02,             // ID of this jack
227
  0x00,             // unused
228
 
229
  // MIDI Adapter MIDI OUT Jack Descriptor (Embedded)
230
  9,                // Descriptor length
231
  CS_INTERFACE,         // Descriptor type (CS_INTERFACE)
232
  0x03,             // MIDI_OUT_JACK subtype
233
  0x01,             // EMBEDDED
234
  0x03,             // ID of this jack
235
  0x01,             // number of input pins of this jack
236
  0x02,             // ID of the entity to which this pin is connected
237
  0x01,             // Output Pin number of the entity to which this input pin is connected
238
  0x00,             // unused
239
 
240
  // MIDI Adapter MIDI OUT Jack Descriptor (External)
241
  9,                // Descriptor length
242
  CS_INTERFACE,         // Descriptor type (CS_INTERFACE)
243
  0x03,             // MIDI_OUT_JACK subtype
244
  0x02,             // EXTERNAL
245
  0x04,             // ID of this jack
246
  0x01,             // number of input pins of this jack
247
  0x01,             // ID of the entity to which this pin is connected
248
  0x01,             // Output Pin number of the entity to which this input pin is connected
249
  0x00,             // unused
250
 
251
#if NUMBER_MIDI_INTERFACES >= 2
252
  // Second MIDI IN Jack Descriptor (Embedded)
253
  6,                // Descriptor length
254
  CS_INTERFACE,         // Descriptor type (CS_INTERFACE)
255
  0x02,             // MIDI_IN_JACK subtype
256
  0x01,             // EMBEDDED
257
  0x05,             // ID of this jack
258
  0x00,             // unused
259
 
260
  // Second MIDI Adapter MIDI IN Jack Descriptor (External)
261
  6,                // Descriptor length
262
  CS_INTERFACE,         // Descriptor type (CS_INTERFACE)
263
  0x02,             // MIDI_IN_JACK subtype
264
  0x02,             // EXTERNAL
265
  0x06,             // ID of this jack
266
  0x00,             // unused
267
 
268
  // Second MIDI Adapter MIDI OUT Jack Descriptor (Embedded)
269
  9,                // Descriptor length
270
  CS_INTERFACE,         // Descriptor type (CS_INTERFACE)
271
  0x03,             // MIDI_OUT_JACK subtype
272
  0x01,             // EMBEDDED
273
  0x07,             // ID of this jack
274
  0x01,             // number of input pins of this jack
275
  0x06,             // ID of the entity to which this pin is connected
276
  0x01,             // Output Pin number of the entity to which this input pin is connected
277
  0x00,             // unused
278
 
279
  // Second MIDI Adapter MIDI OUT Jack Descriptor (External)
280
  9,                // Descriptor length
281
  CS_INTERFACE,         // Descriptor type (CS_INTERFACE)
282
  0x03,             // MIDI_OUT_JACK subtype
283
  0x02,             // EXTERNAL
284
  0x08,             // ID of this jack
285
  0x01,             // number of input pins of this jack
286
  0x05,             // ID of the entity to which this pin is connected
287
  0x01,             // Output Pin number of the entity to which this input pin is connected
288
  0x00,             // unused
289
#endif
290
 
291
 
292
#if NUMBER_MIDI_INTERFACES >= 3
293
  // Third MIDI IN Jack Descriptor (Embedded)
294
  6,                // Descriptor length
295
  CS_INTERFACE,         // Descriptor type (CS_INTERFACE)
296
  0x02,             // MIDI_IN_JACK subtype
297
  0x01,             // EMBEDDED
298
  0x09,             // ID of this jack
299
  0x00,             // unused
300
 
301
  // Third MIDI Adapter MIDI IN Jack Descriptor (External)
302
  6,                // Descriptor length
303
  CS_INTERFACE,         // Descriptor type (CS_INTERFACE)
304
  0x02,             // MIDI_IN_JACK subtype
305
  0x02,             // EXTERNAL
306
  0x0a,             // ID of this jack
307
  0x00,             // unused
308
 
309
  // Third MIDI Adapter MIDI OUT Jack Descriptor (Embedded)
310
  9,                // Descriptor length
311
  CS_INTERFACE,         // Descriptor type (CS_INTERFACE)
312
  0x03,             // MIDI_OUT_JACK subtype
313
  0x01,             // EMBEDDED
314
  0x0b,             // ID of this jack
315
  0x01,             // number of input pins of this jack
316
  0x0a,             // ID of the entity to which this pin is connected
317
  0x01,             // Output Pin number of the entity to which this input pin is connected
318
  0x00,             // unused
319
 
320
  // Third MIDI Adapter MIDI OUT Jack Descriptor (External)
321
  9,                // Descriptor length
322
  CS_INTERFACE,         // Descriptor type (CS_INTERFACE)
323
  0x03,             // MIDI_OUT_JACK subtype
324
  0x02,             // EXTERNAL
325
  0x0c,             // ID of this jack
326
  0x01,             // number of input pins of this jack
327
  0x09,             // ID of the entity to which this pin is connected
328
  0x01,             // Output Pin number of the entity to which this input pin is connected
329
  0x00,             // unused
330
#endif
331
 
332
 
333
#if NUMBER_MIDI_INTERFACES >= 4
334
  // Fourth MIDI IN Jack Descriptor (Embedded)
335
  6,                // Descriptor length
336
  CS_INTERFACE,         // Descriptor type (CS_INTERFACE)
337
  0x02,             // MIDI_IN_JACK subtype
338
  0x01,             // EMBEDDED
339
  0x0d,             // ID of this jack
340
  0x00,             // unused
341
 
342
  // Fourth MIDI Adapter MIDI IN Jack Descriptor (External)
343
  6,                // Descriptor length
344
  CS_INTERFACE,         // Descriptor type (CS_INTERFACE)
345
  0x02,             // MIDI_IN_JACK subtype
346
  0x02,             // EXTERNAL
347
  0x0e,             // ID of this jack
348
  0x00,             // unused
349
 
350
  // Fourth MIDI Adapter MIDI OUT Jack Descriptor (Embedded)
351
  9,                // Descriptor length
352
  CS_INTERFACE,         // Descriptor type (CS_INTERFACE)
353
  0x03,             // MIDI_OUT_JACK subtype
354
  0x01,             // EMBEDDED
355
  0x0f,             // ID of this jack
356
  0x01,             // number of input pins of this jack
357
  0x0e,             // ID of the entity to which this pin is connected
358
  0x01,             // Output Pin number of the entity to which this input pin is connected
359
  0x00,             // unused
360
 
361
  // Fourth MIDI Adapter MIDI OUT Jack Descriptor (External)
362
  9,                // Descriptor length
363
  CS_INTERFACE,         // Descriptor type (CS_INTERFACE)
364
  0x03,             // MIDI_OUT_JACK subtype
365
  0x02,             // EXTERNAL
366
  0x10,             // ID of this jack
367
  0x01,             // number of input pins of this jack
368
  0x0d,             // ID of the entity to which this pin is connected
369
  0x01,             // Output Pin number of the entity to which this input pin is connected
370
  0x00,             // unused
371
#endif
372
 
373
 
374
#if NUMBER_MIDI_INTERFACES >= 5
375
  // Fifth MIDI IN Jack Descriptor (Embedded)
376
  6,                // Descriptor length
377
  CS_INTERFACE,         // Descriptor type (CS_INTERFACE)
378
  0x02,             // MIDI_IN_JACK subtype
379
  0x01,             // EMBEDDED
380
  0x11,             // ID of this jack
381
  0x00,             // unused
382
 
383
  // Fifth MIDI Adapter MIDI IN Jack Descriptor (External)
384
  6,                // Descriptor length
385
  CS_INTERFACE,         // Descriptor type (CS_INTERFACE)
386
  0x02,             // MIDI_IN_JACK subtype
387
  0x02,             // EXTERNAL
388
  0x12,             // ID of this jack
389
  0x00,             // unused
390
 
391
  // Fifth MIDI Adapter MIDI OUT Jack Descriptor (Embedded)
392
  9,                // Descriptor length
393
  CS_INTERFACE,         // Descriptor type (CS_INTERFACE)
394
  0x03,             // MIDI_OUT_JACK subtype
395
  0x01,             // EMBEDDED
396
  0x13,             // ID of this jack
397
  0x01,             // number of input pins of this jack
398
  0x12,             // ID of the entity to which this pin is connected
399
  0x01,             // Output Pin number of the entity to which this input pin is connected
400
  0x00,             // unused
401
 
402
  // Fifth MIDI Adapter MIDI OUT Jack Descriptor (External)
403
  9,                // Descriptor length
404
  CS_INTERFACE,         // Descriptor type (CS_INTERFACE)
405
  0x03,             // MIDI_OUT_JACK subtype
406
  0x02,             // EXTERNAL
407
  0x14,             // ID of this jack
408
  0x01,             // number of input pins of this jack
409
  0x11,             // ID of the entity to which this pin is connected
410
  0x01,             // Output Pin number of the entity to which this input pin is connected
411
  0x00,             // unused
412
#endif
413
 
414
 
415
  // Standard Bulk IN Endpoint Descriptor
416
  9,                // Descriptor length
417
  DSCR_ENDPNT,          // Descriptor type
418
  0x83,             // In Endpoint 3
419
  0x02,             // Bulk, not shared
420
  0x08,             // 8 bytes per packet (LSB)
421
  0x00,             // bytes per packet (MSB)
422
  0x00,             // ignore for bulk
423
  0x00,             // unused
424
  0x00,             // unused
425
 
426
  // Class-specific MS Bulk In Endpoint Descriptor
427
  4+NUMBER_MIDI_INTERFACES, // Descriptor length
428
  CS_ENDPOINT,          // Descriptor type (CS_ENDPOINT)
429
  0x01,             // MS_GENERAL
430
  NUMBER_MIDI_INTERFACES,   // number of embedded MIDI Out Jacks
431
  0x03,             // ID of embedded MIDI Out Jack
432
#if NUMBER_MIDI_INTERFACES >= 2
433
  0x07,             // ID of embedded MIDI Out Jack
434
#endif
435
#if NUMBER_MIDI_INTERFACES >= 3
436
  0x0b,             // ID of embedded MIDI Out Jack
437
#endif
438
#if NUMBER_MIDI_INTERFACES >= 4
439
  0x0f,             // ID of embedded MIDI Out Jack
440
#endif
441
#if NUMBER_MIDI_INTERFACES >= 5
442
  0x13,             // ID of embedded MIDI Out Jack
443
#endif
444
 
445
  // Standard Bulk OUT Endpoint Descriptor
446
  9,                // Descriptor length
447
  DSCR_ENDPNT,          // Descriptor type
448
  0x04,             // Out Endpoint 4
449
  0x02,             // Bulk, not shared
450
  0x08,             // 8 bytes per packet (LSB)
451
  0x00,             // bytes per packet (MSB)
452
  0x00,             // ignore for bulk
453
  0x00,             // unused
454
  0x00,             // unused
455
 
456
  // Class-specific MS Bulk Out Endpoint Descriptor
457
  4+NUMBER_MIDI_INTERFACES, // Descriptor length
458
  CS_ENDPOINT,          // Descriptor type (CS_ENDPOINT)
459
  0x01,             // MS_GENERAL
460
  NUMBER_MIDI_INTERFACES,   // number of embedded MIDI IN Jacks
461
  0x01,             // ID of embedded MIDI In Jack
462
#if NUMBER_MIDI_INTERFACES >= 2
463
  0x05,             // ID of embedded MIDI In Jack
464
#endif
465
#if NUMBER_MIDI_INTERFACES >= 3
466
  0x09,             // ID of embedded MIDI In Jack
467
#endif
468
#if NUMBER_MIDI_INTERFACES >= 4
469
  0x0d,             // ID of embedded MIDI In Jack
470
#endif
471
#if NUMBER_MIDI_INTERFACES >= 5
472
  0x11,             // ID of embedded MIDI In Jack
473
#endif
474
};
475
 
476
 
477
// prevent that more than 256 bytes are allocated
421 tk 478
// see also README.txt (current GM5 firmware can only read out the lower 256 byte
479
// bank - for later firmwares, we could locate the blocker at 0x7200)
416 tk 480
 
980 tk 481
// TK: meanwhile most people should use the newer firmware, therefore
482
// the blocker has been moved to 0x7200
483
const unsigned char __at(0x7200) OVERRUN_BLOCKER[] = { 0x00 };
416 tk 484
 
980 tk 485
 
416 tk 486
// ==========================================================================
487
// Initialize size variables for external access
488
// ==========================================================================
489
unsigned char EEPROM_CONTENT_Write(void) __wparam
490
{
491
  unsigned char error = 0;
492
  unsigned char addr;
493
  unsigned char *ptr;
494
  unsigned char addr_dscr_interface;
495
  unsigned char addr_dscr_endpoints;
496
 
497
  // determine pointer to interface descriptor
498
  addr_dscr_interface = USBDSC_CFG[0];
499
  if( USBDSC_CFG[addr_dscr_interface+1] != DSCR_INTRFC )
500
    return 0x40; // interface descriptor at wrong position
501
  addr_dscr_interface += ((unsigned char)USBDSC_CFG&0xff);
502
 
503
  // determine pointer to endpoint descriptor
504
  addr_dscr_endpoints=0;
505
  for(addr=0; addr<0xff;) {
506
    if( USBDSC_CFG[addr+1] == DSCR_ENDPNT ) {
507
      addr_dscr_endpoints = addr;
508
      break;
509
    }
510
    addr += USBDSC_CFG[addr+0];
511
  }
512
 
513
  if( !addr_dscr_endpoints ) {
514
    return 0x41; // endpoint descriptor not found
515
  }
516
  addr_dscr_endpoints += ((unsigned char)USBDSC_CFG&0xff);
517
 
518
 
519
  // ensure that verify mode is enabled
520
  MIOS_BOX_CFG1.BS_DIS_VERIFY=0;
521
 
522
  // select CS#0, block0
523
  MIOS_BOX_CFG1.BS_A=0;
524
 
525
  // program header
526
  if( error=IIC_EEPROM8_Write(0x00, (unsigned char)USBDSC_DEVICE&0xff) ) return error; // pointer to device descriptor
527
  if( error=IIC_EEPROM8_Write(0x01, (unsigned char)USBDSC_CFG&0xff) )    return error; // pointer to configuration descriptor
528
  if( error=IIC_EEPROM8_Write(0x02, 0x05) )                              return error; // pointer to string table
529
  if( error=IIC_EEPROM8_Write(0x03, addr_dscr_interface) )               return error; // pointer to interface descriptors
530
  if( error=IIC_EEPROM8_Write(0x04, addr_dscr_endpoints) )               return error; // pointer to entpoint descriptors
531
 
532
  // string header
533
  if( error=IIC_EEPROM8_Write(0x05, (unsigned char)USBDSC_STR0&0xff) ) return error;
534
  if( error=IIC_EEPROM8_Write(0x06, (unsigned char)USBDSC_STR1&0xff) ) return error;
535
  if( error=IIC_EEPROM8_Write(0x07, (unsigned char)USBDSC_STR2&0xff) ) return error;
536
  if( error=IIC_EEPROM8_Write(0x08, (unsigned char)USBDSC_STR1&0xff) ) return error;
537
  if( error=IIC_EEPROM8_Write(0x09, (unsigned char)USBDSC_STR1&0xff) ) return error;
538
  if( error=IIC_EEPROM8_Write(0x0a, (unsigned char)USBDSC_STR1&0xff) ) return error;
539
  if( error=IIC_EEPROM8_Write(0x0b, (unsigned char)USBDSC_STR3&0xff) ) return error;
540
  if( error=IIC_EEPROM8_Write(0x0c, (unsigned char)USBDSC_STR1&0xff) ) return error;
541
 
542
  if( error=IIC_EEPROM8_Write(0x0d, 0x00) )                            return error; // fill
543
  if( error=IIC_EEPROM8_Write(0x0e, 0x00) )                            return error; // fill
544
  if( error=IIC_EEPROM8_Write(0x0f, 0x00) )                            return error; // fill
545
 
546
  // program descriptors at 0x10..0xff
547
  addr=0x10;
548
  ptr=(unsigned char *)0x7010;
549
  do {
550
    if( error = IIC_EEPROM8_Write(addr, *ptr) )
551
      return error;
552
    ++ptr;
553
  } while( ++addr );
554
 
555
  // select CS#0, block1
556
  MIOS_BOX_CFG1.BS_A=1;
557
 
558
  do {
559
    if( error = IIC_EEPROM8_Write(addr, *ptr) )
560
      return error;
561
    ++ptr;
562
  } while( ++addr );
563
 
564
 
565
  // select CS#0, block0
566
  MIOS_BOX_CFG1.BS_A=0;
567
 
568
  // read back EEPROM content of bank0 for debugging
569
  addr=0;
570
  do {
571
    eeprom_content[addr] = IIC_EEPROM8_Read(addr);
572
  } while( ++addr );
573
 
574
  return MIOS_BOX_STAT.BS_AVAILABLE ? 0x00 : 0x02;
575
}
576