eeprom->cbus_function[4] = CBUS_SLEEP;
}
else
+ {
+ if(ftdi->type == TYPE_232H)
+ {
+ int i;
+ for (i=0; i<10; i++)
+ eeprom->cbus_function[i] = CBUSH_TRISTATE;
+ }
eeprom->size = -1;
+ }
return 0;
}
+/*FTD2XX doesn't check for values not fitting in the ACBUS Signal oprtions*/
+void set_ft232h_cbus(struct ftdi_eeprom *eeprom, unsigned char * output)
+{
+ int i;
+ for(i=0; i<5;i++)
+ {
+ int mode_low, mode_high;
+ if (eeprom->cbus_function[2*i]> CBUSH_CLK7_5)
+ mode_low = CBUSH_TRISTATE;
+ else
+ mode_low = eeprom->cbus_function[2*i];
+ if (eeprom->cbus_function[2*i+1]> CBUSH_CLK7_5)
+ mode_high = CBUSH_TRISTATE;
+ else
+ mode_high = eeprom->cbus_function[2*i];
+ output[0x18+i] = mode_high <<4 | mode_low;
+ }
+}
/**
Build binary buffer from ftdi_eeprom structure.
Output is suitable for ftdi_write_eeprom().
break;
case TYPE_2232C:
- output[0x00] = (eeprom->channel_a_type);
+ output[0x00] = (1<<(eeprom->channel_a_type)) & 0x7;
if ( eeprom->channel_a_driver == DRIVER_VCP)
output[0x00] |= DRIVER_VCP;
else
else
output[0x00] &= ~HIGH_CURRENT_DRIVE;
- output[0x01] = (eeprom->channel_b_type);
+ output[0x01] = (1<<(eeprom->channel_b_type)) & 0x7;
if ( eeprom->channel_b_driver == DRIVER_VCP)
output[0x01] |= DRIVER_VCP;
else
output[0x16] = eeprom->cbus_function[4];
break;
case TYPE_2232H:
- output[0x00] = (eeprom->channel_a_type);
+ output[0x00] = (1<<(eeprom->channel_a_type)) & 0x7;
if ( eeprom->channel_a_driver == DRIVER_VCP)
output[0x00] |= DRIVER_VCP;
else
output[0x00] &= ~DRIVER_VCP;
- output[0x01] = (eeprom->channel_b_type);
+ output[0x01] = (1<<(eeprom->channel_b_type)) & 0x7;
if ( eeprom->channel_b_driver == DRIVER_VCP)
output[0x01] |= DRIVER_VCP;
else
fprintf(stderr,"FIXME: Build FT4232H specific EEPROM settings\n");
break;
case TYPE_232H:
- output[0x00] = (eeprom->channel_a_type);
+ output[0x00] = (1<<(eeprom->channel_a_type)) & 0xf;
if ( eeprom->channel_a_driver == DRIVER_VCP)
output[0x00] |= DRIVER_VCPH;
else
if (eeprom->group1_slew == SLOW_SLEW)
output[0x0d] |= SLOW_SLEW;
+ set_ft232h_cbus(eeprom, output);
+
output[0x1e] = eeprom->chip;
fprintf(stderr,"FIXME: Build FT232H specific EEPROM settings\n");
break;
return user_area_size;
}
+/* FTD2XX doesn't allow to set multiple bits in the interface mode bitfield*/
+unsigned char bit2type(unsigned char bits)
+{
+ switch (bits)
+ {
+ case 0: return 0;
+ case 1: return 1;
+ case 2: return 2;
+ case 4: return 3;
+ case 8: return 4;
+ default:
+ fprintf(stderr," Unexpected value %d for Hardware Interface type\n",
+ bits);
+ }
+ return 0;
+}
/**
Decode binary EEPROM image into an ftdi_eeprom structure.
}
else if (ftdi->type == TYPE_2232C)
{
- eeprom->channel_a_type = buf[0x00] & 0x7;
+ eeprom->channel_a_type = bit2type(buf[0x00] & 0x7);
eeprom->channel_a_driver = buf[0x00] & DRIVER_VCP;
eeprom->high_current_a = buf[0x00] & HIGH_CURRENT_DRIVE;
eeprom->channel_b_type = buf[0x01] & 0x7;
}
else if ((ftdi->type == TYPE_2232H) ||(ftdi->type == TYPE_4232H))
{
- eeprom->channel_a_type = buf[0x00] & 0x7;
+ eeprom->channel_a_type = bit2type(buf[0x00] & 0x7);
eeprom->channel_a_driver = buf[0x00] & DRIVER_VCP;
eeprom->channel_b_type = buf[0x01] & 0x7;
eeprom->channel_b_driver = buf[0x01] & DRIVER_VCP;
}
else if (ftdi->type == TYPE_232H)
{
+ int i;
+
eeprom->channel_a_type = buf[0x00] & 0xf;
eeprom->channel_a_driver = (buf[0x00] & DRIVER_VCPH)?DRIVER_VCP:0;
eeprom->clock_polarity = buf[0x01] & FT1284_CLK_IDLE_STATE;
eeprom->group1_schmitt = buf[0x0d] & IS_SCHMITT;
eeprom->group1_slew = buf[0x0d] & SLOW_SLEW;
+ for(i=0; i<5; i++)
+ {
+ eeprom->cbus_function[2*i ] = buf[0x18+i] & 0x0f;
+ eeprom->cbus_function[2*i+1] = (buf[0x18+i] >> 4) & 0x0f;
+ }
eeprom->chip = buf[0x1e];
/*FIXME: Decipher more values*/
}
if (verbose)
{
- char *channel_mode[] = {"UART","245","CPU", "unknown", "OPTO", "unknown1","unknown2","unknown3","FT1284"};
+ char *channel_mode[] = {"UART","245","CPU", "OPTO", "FT1284"};
fprintf(stdout, "VID: 0x%04x\n",eeprom->vendor_id);
fprintf(stdout, "PID: 0x%04x\n",eeprom->product_id);
fprintf(stdout, "Release: 0x%04x\n",release);
}
else if (ftdi->type == TYPE_232H)
{
+ int i;
+ char *cbush_mux[] = {"TRISTATE","RXLED","TXLED", "TXRXLED","PWREN",
+ "SLEEP","DRIVE_0","DRIVE_1","IOMODE","TXDEN",
+ "CLK30","CLK15","CLK7_5"
+ };
fprintf(stdout,"ACBUS has %d mA drive%s%s\n",
(eeprom->group0_drive+1) *4,
(eeprom->group0_schmitt)?" Schmitt Input":"",
(eeprom->group1_drive+1) *4,
(eeprom->group1_schmitt)?" Schmitt Input":"",
(eeprom->group1_slew)?" Slow Slew":"");
+ for (i=0; i<10; i++)
+ {
+ if (eeprom->cbus_function[i]<= CBUSH_CLK7_5 )
+ fprintf(stdout,"C%d Function: %s\n", i,
+ cbush_mux[eeprom->cbus_function[i]]);
+ }
+
}
if (ftdi->type == TYPE_R)
case CBUS_FUNCTION_4:
*value = ftdi->eeprom->cbus_function[4];
break;
+ case CBUS_FUNCTION_5:
+ *value = ftdi->eeprom->cbus_function[5];
+ break;
+ case CBUS_FUNCTION_6:
+ *value = ftdi->eeprom->cbus_function[6];
+ break;
+ case CBUS_FUNCTION_7:
+ *value = ftdi->eeprom->cbus_function[7];
+ break;
+ case CBUS_FUNCTION_8:
+ *value = ftdi->eeprom->cbus_function[8];
+ break;
+ case CBUS_FUNCTION_9:
+ *value = ftdi->eeprom->cbus_function[8];
+ break;
case HIGH_CURRENT:
*value = ftdi->eeprom->high_current;
break;
case CBUS_FUNCTION_4:
ftdi->eeprom->cbus_function[4] = value;
break;
+ case CBUS_FUNCTION_5:
+ ftdi->eeprom->cbus_function[5] = value;
+ break;
+ case CBUS_FUNCTION_6:
+ ftdi->eeprom->cbus_function[6] = value;
+ break;
+ case CBUS_FUNCTION_7:
+ ftdi->eeprom->cbus_function[7] = value;
+ break;
+ case CBUS_FUNCTION_8:
+ ftdi->eeprom->cbus_function[8] = value;
+ break;
+ case CBUS_FUNCTION_9:
+ ftdi->eeprom->cbus_function[9] = value;
+ break;
case HIGH_CURRENT:
ftdi->eeprom->high_current = value;
break;