X-Git-Url: http://developer.intra2net.com/git/?a=blobdiff_plain;f=src%2Fftdi.c;h=043d24a3153d330256f567aaeed212922c205d0f;hb=c3034a16d2e7394f71357938b3f9844168716b0a;hp=b17e8983e8d53a3f0648022542fd57d590d16e26;hpb=1189b11aff1b36510367f17a0aedf2abccb66ec7;p=libftdi diff --git a/src/ftdi.c b/src/ftdi.c index b17e898..043d24a 100644 --- a/src/ftdi.c +++ b/src/ftdi.c @@ -223,7 +223,7 @@ int ftdi_usb_find_all(struct ftdi_context *ftdi, struct ftdi_device_list **devli curdev = devlist; *curdev = NULL; - for (bus = usb_busses; bus; bus = bus->next) { + for (bus = usb_get_busses(); bus; bus = bus->next) { for (dev = bus->devices; dev; dev = dev->next) { if (dev->descriptor.idVendor == vendor && dev->descriptor.idProduct == product) @@ -445,7 +445,7 @@ int ftdi_usb_open_desc(struct ftdi_context *ftdi, int vendor, int product, if (usb_find_devices() < 0) ftdi_error_return(-2, "usb_find_devices() failed"); - for (bus = usb_busses; bus; bus = bus->next) { + for (bus = usb_get_busses(); bus; bus = bus->next) { for (dev = bus->devices; dev; dev = dev->next) { if (dev->descriptor.idVendor == vendor && dev->descriptor.idProduct == product) { @@ -557,11 +557,11 @@ int ftdi_usb_purge_buffers(struct ftdi_context *ftdi) int result; result = ftdi_usb_purge_rx_buffer(ftdi); - if (!result) + if (result < 0) return -1; result = ftdi_usb_purge_tx_buffer(ftdi); - if (!result) + if (result < 0) return -2; return 0; @@ -1532,19 +1532,19 @@ int ftdi_eeprom_build(struct ftdi_eeprom *eeprom, unsigned char *output) output[0x07] = 0x02; // Addr 08: Config descriptor - // Bit 1: remote wakeup if 1 - // Bit 0: self powered if 1 - // - j = 0; + // Bit 7: always 1 + // Bit 6: 1 if this device is self powered, 0 if bus powered + // Bit 5: 1 if this device uses remote wakeup + // Bit 4: 1 if this device is battery powered + j = 0x80; if (eeprom->self_powered == 1) - j = j | 1; + j |= 0x40; if (eeprom->remote_wakeup == 1) - j = j | 2; + j |= 0x20; output[0x08] = j; // Addr 09: Max power consumption: max power = value * 2 mA output[0x09] = eeprom->max_power; - ; // Addr 0A: Chip configuration // Bit 7: 0 - reserved