X-Git-Url: http://developer.intra2net.com/git/?p=libftdi;a=blobdiff_plain;f=src%2Fftdi.c;h=ea487d0583ca1b3895a67cd34971342963b28803;hp=b6caf6c182323e676591cf9f36268512faf96cf0;hb=19f1452cde9bfe9da0e2830af128fae958ae877a;hpb=32e2d8b00c3168dd46c34080aa4d83abaf05a685 diff --git a/src/ftdi.c b/src/ftdi.c index b6caf6c..ea487d0 100644 --- a/src/ftdi.c +++ b/src/ftdi.c @@ -295,7 +295,7 @@ struct ftdi_version_info ftdi_get_library_version(void) Finds all ftdi devices with given VID:PID on the usb bus. Creates a new ftdi_device_list which needs to be deallocated by ftdi_list_free() after use. With VID:PID 0:0, search for the default devices - (0x403:0x6001, 0x403:0x6010, 0x403:0x6011, 0x403:0x6014) + (0x403:0x6001, 0x403:0x6010, 0x403:0x6011, 0x403:0x6014, 0x403:0x6015) \param ftdi pointer to ftdi_context \param devlist Pointer where to store list of found devices @@ -328,11 +328,12 @@ 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))) + || desc.idProduct == 0x6011 || desc.idProduct == 0x6014 + || desc.idProduct == 0x6015))) { *curdev = (struct ftdi_device_list*)malloc(sizeof(struct ftdi_device_list)); if (!*curdev) @@ -413,8 +414,8 @@ int ftdi_usb_get_strings(struct ftdi_context * ftdi, struct libusb_device * dev, if ((ftdi==NULL) || (dev==NULL)) return -1; - if (libusb_open(dev, &ftdi->usb_dev) < 0) - ftdi_error_return(-4, "libusb_open() failed"); + if (ftdi->usb_dev == NULL && libusb_open(dev, &ftdi->usb_dev) < 0) + ftdi_error_return(-4, "libusb_open() failed"); if (libusb_get_device_descriptor(dev, &desc) < 0) ftdi_error_return(-11, "libusb_get_device_descriptor() failed"); @@ -2603,6 +2604,8 @@ int ftdi_eeprom_build(struct ftdi_context *ftdi) user_area_size = 90; // two extra config bytes and 4 bytes PnP stuff break; case TYPE_R: + user_area_size = 96; + break; case TYPE_230X: user_area_size = 88; // four extra config bytes + 4 bytes PnP stuff break; @@ -3065,6 +3068,7 @@ int ftdi_eeprom_build(struct ftdi_context *ftdi) { output[0x1a + j] = eeprom->cbus_function[j]; } + output[0x0b] = eeprom->invert; break; } @@ -3120,6 +3124,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<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; @@ -3391,6 +3408,8 @@ int ftdi_eeprom_decode(struct ftdi_context *ftdi, int verbose) eeprom->group1_drive = (buf[0x0c] >> 4) & 0x03; eeprom->group1_schmitt = (buf[0x0c] >> 4) & IS_SCHMITT; eeprom->group1_slew = (buf[0x0c] >> 4) & SLOW_SLEW; + + eeprom->invert = buf[0xb]; } if (verbose) @@ -3474,7 +3493,6 @@ 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" @@ -3496,7 +3514,6 @@ int ftdi_eeprom_decode(struct ftdi_context *ftdi, int verbose) } else if (ftdi->type == TYPE_230X) { - int i; char *cbush_mux[] = {"TRISTATE","RXLED","TXLED", "TXRXLED","PWREN", "SLEEP","DRIVE_0","DRIVE_1","IOMODE","TXDEN", "CLK24","CLK12","CLK6","BAT_DETECT","BAT_DETECT#", @@ -3516,6 +3533,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->invert) + print_inverted_bits(eeprom->invert); } if (ftdi->type == TYPE_R) @@ -3527,14 +3547,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]