X-Git-Url: http://developer.intra2net.com/git/?a=blobdiff_plain;f=src%2Fftdi.c;h=7aa0417726452c11cc4de2ef1a9d20dea0b09e35;hb=263d3ba0f28fa9e78e752e65537d98377eb29119;hp=76e6f42abf560d5c73450f8ca5e578fb8f298131;hpb=91d7a2015293c56a7f889898ff7ef0b45d78ae7a;p=libftdi diff --git a/src/ftdi.c b/src/ftdi.c index 76e6f42..7aa0417 100644 --- a/src/ftdi.c +++ b/src/ftdi.c @@ -2261,10 +2261,36 @@ int ftdi_eeprom_initdefaults(struct ftdi_context *ftdi, char * manufacturer, 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(). @@ -2663,7 +2689,22 @@ int ftdi_eeprom_build(struct ftdi_context *ftdi) output[0x00] |= DRIVER_VCPH; else output[0x00] &= ~DRIVER_VCPH; - + if (eeprom->powersave) + output[0x01] |= POWER_SAVE_DISABLE_H; + else + output[0x01] &= ~POWER_SAVE_DISABLE_H; + if (eeprom->clock_polarity) + output[0x01] |= FT1284_CLK_IDLE_STATE; + else + output[0x01] &= ~FT1284_CLK_IDLE_STATE; + if (eeprom->data_order) + output[0x01] |= FT1284_DATA_LSB; + else + output[0x01] &= ~FT1284_DATA_LSB; + if (eeprom->flow_control) + output[0x01] |= FT1284_FLOW_CONTROL; + else + output[0x01] &= ~FT1284_FLOW_CONTROL; if (eeprom->group0_drive > DRIVE_16MA) output[0x0c] |= DRIVE_16MA; else @@ -2682,6 +2723,8 @@ int ftdi_eeprom_build(struct ftdi_context *ftdi) 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; @@ -2923,8 +2966,14 @@ int ftdi_eeprom_decode(struct ftdi_context *ftdi, int verbose) } 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->data_order = buf[0x01] & FT1284_DATA_LSB; + eeprom->flow_control = buf[0x01] & FT1284_FLOW_CONTROL; + eeprom->powersave = buf[0x01] & POWER_SAVE_DISABLE_H; eeprom->group0_drive = buf[0x0c] & DRIVE_16MA; eeprom->group0_schmitt = buf[0x0c] & IS_SCHMITT; eeprom->group0_slew = buf[0x0c] & SLOW_SLEW; @@ -2932,6 +2981,11 @@ int ftdi_eeprom_decode(struct ftdi_context *ftdi, int verbose) 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*/ } @@ -2963,6 +3017,11 @@ int ftdi_eeprom_decode(struct ftdi_context *ftdi, int verbose) fprintf(stdout, "Suspend on DBUS7\n"); if (eeprom->suspend_pull_downs) fprintf(stdout, "Pull IO pins low during suspend\n"); + if(eeprom->powersave) + { + if(ftdi->type >= TYPE_232H) + fprintf(stdout,"Enter low power state on ACBUS7\n"); + } if (eeprom->remote_wakeup) fprintf(stdout, "Enable Remote Wake Up\n"); fprintf(stdout, "PNP: %d\n",(eeprom->is_not_pnp)?0:1); @@ -2971,6 +3030,13 @@ int ftdi_eeprom_decode(struct ftdi_context *ftdi, int verbose) channel_mode[eeprom->channel_a_type], (eeprom->channel_a_driver)?" VCP":"", (eeprom->high_current_a)?" High Current IO":""); + if (ftdi->type >= TYPE_232H) + { + fprintf(stdout,"FT1284 Mode Clock is idle %s, %s first, %sFlow Control\n", + (eeprom->clock_polarity)?"HIGH":"LOW", + (eeprom->data_order)?"LSB":"MSB", + (eeprom->flow_control)?"":"No "); + } if ((ftdi->type >= TYPE_2232C) && (ftdi->type != TYPE_R) && (ftdi->type != TYPE_232H)) fprintf(stdout,"Channel B has Mode %s%s%s\n", channel_mode[eeprom->channel_b_type], @@ -3005,6 +3071,11 @@ int ftdi_eeprom_decode(struct ftdi_context *ftdi, int verbose) } 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":"", @@ -3013,6 +3084,13 @@ int ftdi_eeprom_decode(struct ftdi_context *ftdi, int verbose) (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) @@ -3127,6 +3205,21 @@ int ftdi_get_eeprom_value(struct ftdi_context *ftdi, enum ftdi_eeprom_value valu 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; @@ -3175,7 +3268,19 @@ int ftdi_get_eeprom_value(struct ftdi_context *ftdi, enum ftdi_eeprom_value valu case GROUP3_SLEW: *value = ftdi->eeprom->group3_slew; break; - case CHIP_TYPE: + case POWER_SAVE: + *value = ftdi->eeprom->powersave; + break; + case CLOCK_POLARITY: + *value = ftdi->eeprom->clock_polarity; + break; + case DATA_ORDER: + *value = ftdi->eeprom->data_order; + break; + case FLOW_CONTROL: + *value = ftdi->eeprom->flow_control; + break; + case CHIP_TYPE: *value = ftdi->eeprom->chip; break; case CHIP_SIZE: @@ -3263,6 +3368,21 @@ int ftdi_set_eeprom_value(struct ftdi_context *ftdi, enum ftdi_eeprom_value valu 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; @@ -3314,6 +3434,18 @@ int ftdi_set_eeprom_value(struct ftdi_context *ftdi, enum ftdi_eeprom_value valu case CHIP_TYPE: ftdi->eeprom->chip = value; break; + case POWER_SAVE: + ftdi->eeprom->powersave = value; + break; + case CLOCK_POLARITY: + ftdi->eeprom->clock_polarity = value; + break; + case DATA_ORDER: + ftdi->eeprom->data_order = value; + break; + case FLOW_CONTROL: + ftdi->eeprom->flow_control = value; + break; case CHIP_SIZE: ftdi_error_return(-2, "EEPROM Value can't be changed"); default :