X-Git-Url: http://developer.intra2net.com/git/?p=libftdi;a=blobdiff_plain;f=src%2Fftdi.c;h=fe146b75ad8254f36e564136bf11da6006268fe1;hp=ad9e20e453eda60cb5fbaf7f3c865bee659b43c0;hb=1ad9e4cc95b76fa304f6e21723eaf2fb457e0006;hpb=a1b2db22abd6fbc134238952c84122ea8b11b856 diff --git a/src/ftdi.c b/src/ftdi.c index ad9e20e..fe146b7 100644 --- a/src/ftdi.c +++ b/src/ftdi.c @@ -328,9 +328,9 @@ int ftdi_usb_find_all(struct ftdi_context *ftdi, struct ftdi_device_list **devli if (libusb_get_device_descriptor(dev, &desc) < 0) ftdi_error_return_free_device_list(-6, "libusb_get_device_descriptor() failed", devs); - if (((vendor != 0 && product != 0) && + if (((vendor || product) && desc.idVendor == vendor && desc.idProduct == product) || - ((vendor == 0 && product == 0) && + (!(vendor || product) && (desc.idVendor == 0x403) && (desc.idProduct == 0x6001 || desc.idProduct == 0x6010 || desc.idProduct == 0x6011 || desc.idProduct == 0x6014))) { @@ -3065,7 +3065,7 @@ int ftdi_eeprom_build(struct ftdi_context *ftdi) { output[0x1a + j] = eeprom->cbus_function[j]; } - output[0x0b] = eeprom->rs232_inversion; + output[0x0b] = eeprom->invert; break; } @@ -3121,6 +3121,21 @@ static unsigned char bit2type(unsigned char bits) } return 0; } +/* Decode 230X / 232R type chips invert bits + * Prints directly to stdout. +*/ +static void print_inverted_bits(int invert) +{ + char *r_bits[] = {"TXD","RXD","RTS","CTS","DTR","DSR","DCD","RI"}; + int i; + + fprintf(stdout,"Inverted bits:"); + for (i=0; i<8; i++) + if ((invert & (1<group1_schmitt = (buf[0x0c] >> 4) & IS_SCHMITT; eeprom->group1_slew = (buf[0x0c] >> 4) & SLOW_SLEW; - eeprom->rs232_inversion = buf[0xb]; + eeprom->invert = buf[0xb]; } if (verbose) @@ -3515,33 +3530,9 @@ int ftdi_eeprom_decode(struct ftdi_context *ftdi, int verbose) if (eeprom->cbus_function[i]<= CBUSH_AWAKE) fprintf(stdout,"CBUS%d Function: %s\n", i, cbush_mux[eeprom->cbus_function[i]]); } - if(eeprom->rs232_inversion ) { - struct bitnames { - int mask; - char *name; - }; - - struct bitnames invbitlist[] = { - {INVERT_TXD, "TXD"}, - {INVERT_RXD, "RXD"}, - {INVERT_RTS, "RTS"}, - {INVERT_CTS, "CTS"}, - {INVERT_DTR, "DTR"}, - {INVERT_DSR, "DSR"}, - {INVERT_DCD, "DCD"}, - {INVERT_RI, "RI"}, - {0, NULL}, - }; - int n = 0; - printf("Inversion on "); - for (i=0; invbitlist[i].mask;i++) { - if(eeprom->rs232_inversion & invbitlist[i].mask) { - if (n++) printf (","); - printf (" %s", invbitlist[i].name); - } - } - printf (" Pin%s\n",(n==1)?"":"s"); - } + + if (eeprom->invert) + print_inverted_bits(eeprom->invert); } if (ftdi->type == TYPE_R) @@ -3553,14 +3544,8 @@ int ftdi_eeprom_decode(struct ftdi_context *ftdi, int verbose) char *cbus_BB[] = {"RXF","TXE","RD", "WR"}; if (eeprom->invert) - { - char *r_bits[] = {"TXD","RXD","RTS", "CTS","DTR","DSR","DCD","RI"}; - fprintf(stdout,"Inverted bits:"); - for (i=0; i<8; i++) - if ((eeprom->invert & (1<invert); + for (i=0; i<5; i++) { if (eeprom->cbus_function[i]eeprom->size; break; - case RS232_INVERSION: - *value = ftdi->eeprom->rs232_inversion; - break; default: ftdi_error_return(-1, "Request for unknown EEPROM value"); } @@ -3957,9 +3939,6 @@ int ftdi_set_eeprom_value(struct ftdi_context *ftdi, enum ftdi_eeprom_value valu case CHIP_SIZE: ftdi_error_return(-2, "EEPROM Value can't be changed"); break; - case RS232_INVERSION: - ftdi->eeprom->rs232_inversion = value; - break; default : ftdi_error_return(-1, "Request to unknown EEPROM value");