39 #ifdef LIBFTDI_LINUX_ASYNC_MODE
40 #include <sys/ioctl.h>
41 #include <sys/select.h>
42 #include <sys/types.h>
44 #include <linux/usbdevice_fs.h>
47 #define ftdi_error_return(code, str) do { \
48 ftdi->error_str = str; \
62 static int ftdi_usb_close_internal (
struct ftdi_context *ftdi)
68 ret = usb_close (ftdi->
usb_dev);
111 #ifdef LIBFTDI_LINUX_ASYNC_MODE
210 ftdi_usb_close_internal (ftdi);
269 struct usb_device *dev;
273 if (usb_find_busses() < 0)
275 if (usb_find_devices() < 0)
280 for (bus = usb_get_busses(); bus; bus = bus->next)
282 for (dev = bus->devices; dev; dev = dev->next)
284 if (dev->descriptor.idVendor == vendor
285 && dev->descriptor.idProduct == product)
291 (*curdev)->next = NULL;
292 (*curdev)->dev =
dev;
294 curdev = &(*curdev)->
next;
312 for (curdev = *devlist; curdev != NULL;)
359 char * manufacturer,
int mnf_len,
char * description,
int desc_len,
char * serial,
int serial_len)
361 if ((ftdi==NULL) || (dev==NULL))
364 if (!(ftdi->
usb_dev = usb_open(dev)))
367 if (manufacturer != NULL)
369 if (usb_get_string_simple(ftdi->
usb_dev, dev->descriptor.iManufacturer, manufacturer, mnf_len) <= 0)
371 ftdi_usb_close_internal (ftdi);
376 if (description != NULL)
378 if (usb_get_string_simple(ftdi->
usb_dev, dev->descriptor.iProduct, description, desc_len) <= 0)
380 ftdi_usb_close_internal (ftdi);
387 if (usb_get_string_simple(ftdi->
usb_dev, dev->descriptor.iSerialNumber, serial, serial_len) <= 0)
389 ftdi_usb_close_internal (ftdi);
394 if (ftdi_usb_close_internal (ftdi) != 0)
406 static unsigned int _ftdi_determine_max_packet_size(
struct ftdi_context *ftdi,
struct usb_device *
dev)
408 unsigned int packet_size;
411 if (ftdi == NULL || dev == NULL)
422 if (dev->descriptor.bNumConfigurations > 0 && dev->config)
424 struct usb_config_descriptor config = dev->config[0];
426 if (ftdi->
interface < config.bNumInterfaces)
428 struct usb_interface interface = config.interface[ftdi->
interface];
429 if (interface.num_altsetting > 0)
431 struct usb_interface_descriptor descriptor = interface.altsetting[0];
432 if (descriptor.bNumEndpoints > 0)
434 packet_size = descriptor.endpoint[0].wMaxPacketSize;
459 int detach_errno = 0;
465 if (!(ftdi->
usb_dev = usb_open(dev)))
468 #ifdef LIBUSB_HAS_GET_DRIVER_NP
478 if (usb_detach_kernel_driver_np(ftdi->
usb_dev, ftdi->
interface) != 0 && errno != ENODATA)
479 detach_errno = errno;
488 if (dev->descriptor.bNumConfigurations > 0)
492 config_val = dev->config[0].bConfigurationValue;
494 if (usb_set_configuration(ftdi->
usb_dev, config_val) &&
497 ftdi_usb_close_internal (ftdi);
498 if (detach_errno == EPERM)
504 ftdi_error_return(-3,
"unable to set usb configuration. Make sure the default FTDI driver is not in use");
512 ftdi_usb_close_internal (ftdi);
513 if (detach_errno == EPERM)
519 ftdi_error_return(-5,
"unable to claim usb device. Make sure the default FTDI driver is not in use");
525 ftdi_usb_close_internal (ftdi);
531 if (dev->descriptor.bcdDevice == 0x400 || (dev->descriptor.bcdDevice == 0x200
532 && dev->descriptor.iSerialNumber == 0))
534 else if (dev->descriptor.bcdDevice == 0x200)
536 else if (dev->descriptor.bcdDevice == 0x500)
538 else if (dev->descriptor.bcdDevice == 0x600)
540 else if (dev->descriptor.bcdDevice == 0x700)
542 else if (dev->descriptor.bcdDevice == 0x800)
544 else if (dev->descriptor.bcdDevice == 0x900)
565 ftdi_usb_close_internal (ftdi);
609 const char* description,
const char* serial)
639 const char* description,
const char* serial,
unsigned int index)
642 struct usb_device *dev;
647 if (usb_find_busses() < 0)
649 if (usb_find_devices() < 0)
655 for (bus = usb_get_busses(); bus; bus = bus->next)
657 for (dev = bus->devices; dev; dev = dev->next)
659 if (dev->descriptor.idVendor == vendor
660 && dev->descriptor.idProduct == product)
662 if (!(ftdi->
usb_dev = usb_open(dev)))
665 if (description != NULL)
667 if (usb_get_string_simple(ftdi->
usb_dev, dev->descriptor.iProduct,
string,
sizeof(
string)) <= 0)
669 ftdi_usb_close_internal (ftdi);
672 if (strncmp(
string, description,
sizeof(
string)) != 0)
674 if (ftdi_usb_close_internal (ftdi) != 0)
681 if (usb_get_string_simple(ftdi->
usb_dev, dev->descriptor.iSerialNumber,
string,
sizeof(
string)) <= 0)
683 ftdi_usb_close_internal (ftdi);
686 if (strncmp(
string, serial,
sizeof(
string)) != 0)
688 if (ftdi_usb_close_internal (ftdi) != 0)
694 if (ftdi_usb_close_internal (ftdi) != 0)
744 if (description[0] == 0 || description[1] !=
':')
747 if (description[0] ==
'd')
750 struct usb_device *dev;
754 if (usb_find_busses() < 0)
756 if (usb_find_devices() < 0)
759 for (bus = usb_get_busses(); bus; bus = bus->next)
761 for (dev = bus->devices; dev; dev = dev->next)
764 const char *desc = description + 2;
765 size_t len = strlen(bus->dirname);
766 if (strncmp(desc, bus->dirname, len))
772 if (strcmp(desc, dev->filename))
781 else if (description[0] ==
'i' || description[0] ==
's')
784 unsigned int product;
785 unsigned int index=0;
786 const char *serial=NULL;
787 const char *startp, *endp;
790 startp=description+2;
791 vendor=strtoul((
char*)startp,(
char**)&endp,0);
792 if (*endp !=
':' || endp == startp || errno != 0)
796 product=strtoul((
char*)startp,(
char**)&endp,0);
797 if (endp == startp || errno != 0)
800 if (description[0] ==
'i' && *endp != 0)
807 index=strtoul((
char*)startp,(
char**)&endp,0);
808 if (*endp != 0 || endp == startp || errno != 0)
811 if (description[0] ==
's')
839 if (ftdi == NULL || ftdi->
usb_dev == NULL)
865 if (ftdi == NULL || ftdi->
usb_dev == NULL)
891 if (ftdi == NULL || ftdi->
usb_dev == NULL)
916 if (ftdi == NULL || ftdi->
usb_dev == NULL)
949 #ifdef LIBFTDI_LINUX_ASYNC_MODE
958 if (ftdi_usb_close_internal (ftdi) != 0)
969 static int ftdi_convert_baudrate(
int baudrate,
struct ftdi_context *ftdi,
970 unsigned short *value,
unsigned short *index)
972 static const char am_adjust_up[8] = {0, 0, 0, 1, 0, 3, 2, 1};
973 static const char am_adjust_dn[8] = {0, 0, 0, 1, 0, 1, 2, 3};
974 static const char frac_code[8] = {0, 3, 2, 4, 1, 5, 6, 7};
975 int divisor, best_divisor, best_baud, best_baud_diff;
976 unsigned long encoded_divisor;
985 divisor = 24000000 / baudrate;
990 divisor -= am_adjust_dn[divisor & 7];
997 for (i = 0; i < 2; i++)
999 int try_divisor = divisor + i;
1004 if (try_divisor <= 8)
1009 else if (ftdi->
type !=
TYPE_AM && try_divisor < 12)
1014 else if (divisor < 16)
1024 try_divisor += am_adjust_up[try_divisor & 7];
1025 if (try_divisor > 0x1FFF8)
1028 try_divisor = 0x1FFF8;
1033 if (try_divisor > 0x1FFFF)
1036 try_divisor = 0x1FFFF;
1041 baud_estimate = (24000000 + (try_divisor / 2)) / try_divisor;
1043 if (baud_estimate < baudrate)
1045 baud_diff = baudrate - baud_estimate;
1049 baud_diff = baud_estimate - baudrate;
1051 if (i == 0 || baud_diff < best_baud_diff)
1054 best_divisor = try_divisor;
1055 best_baud = baud_estimate;
1056 best_baud_diff = baud_diff;
1065 encoded_divisor = (best_divisor >> 3) | (frac_code[best_divisor & 7] << 14);
1067 if (encoded_divisor == 1)
1069 encoded_divisor = 0;
1071 else if (encoded_divisor == 0x4001)
1073 encoded_divisor = 1;
1076 *value = (
unsigned short)(encoded_divisor & 0xFFFF);
1080 *index = (
unsigned short)(encoded_divisor >> 8);
1082 *index |= ftdi->
index;
1085 *index = (
unsigned short)(encoded_divisor >> 16);
1104 unsigned short value, index;
1105 int actual_baudrate;
1107 if (ftdi == NULL || ftdi->
usb_dev == NULL)
1112 baudrate = baudrate*4;
1115 actual_baudrate = ftdi_convert_baudrate(baudrate, ftdi, &value, &index);
1116 if (actual_baudrate <= 0)
1120 if ((actual_baudrate * 2 < baudrate )
1121 || ((actual_baudrate < baudrate)
1122 ? (actual_baudrate * 21 < baudrate * 20)
1123 : (baudrate * 21 < actual_baudrate * 20)))
1124 ftdi_error_return (-1,
"Unsupported baudrate. Note: bitbang baudrates are automatically multiplied by 4");
1171 unsigned short value = bits;
1173 if (ftdi == NULL || ftdi->
usb_dev == NULL)
1179 value |= (0x00 << 8);
1182 value |= (0x01 << 8);
1185 value |= (0x02 << 8);
1188 value |= (0x03 << 8);
1191 value |= (0x04 << 8);
1198 value |= (0x00 << 11);
1201 value |= (0x01 << 11);
1204 value |= (0x02 << 11);
1211 value |= (0x00 << 14);
1214 value |= (0x01 << 14);
1241 int total_written = 0;
1243 if (ftdi == NULL || ftdi->
usb_dev == NULL)
1246 while (offset < size)
1250 if (offset+write_size > size)
1251 write_size = size-offset;
1257 total_written += ret;
1258 offset += write_size;
1261 return total_written;
1264 #ifdef LIBFTDI_LINUX_ASYNC_MODE
1265 #ifdef USB_CLASS_PTP
1266 #error LIBFTDI_LINUX_ASYNC_MODE is not compatible with libusb-compat-0.1!
1280 static int _usb_get_async_urbs_pending(
struct ftdi_context *ftdi)
1282 struct usbdevfs_urb *urb;
1306 static void _usb_async_cleanup(
struct ftdi_context *ftdi,
int wait_for_more,
int timeout_msec)
1309 struct usbdevfs_urb *urb;
1318 tv.tv_sec = timeout_msec / 1000;
1319 tv.tv_usec = (timeout_msec % 1000) * 1000;
1326 while (_usb_get_async_urbs_pending(ftdi)
1327 && (ret = ioctl(ftdi->
usb_dev->
fd, USBDEVFS_REAPURBNDELAY, &urb)) == -1
1330 if (keep_going && !wait_for_more)
1338 select(ftdi->
usb_dev->
fd+1, NULL, &writefds, NULL, &tv);
1341 if (ret == 0 && urb != NULL)
1375 static int _usb_bulk_write_async(
struct ftdi_context *ftdi,
int ep,
char *bytes,
int size)
1377 struct usbdevfs_urb *urb;
1378 int bytesdone = 0, requested;
1379 int ret, cleanup_count;
1387 for (cleanup_count=0; urb==NULL && cleanup_count <= 1; cleanup_count++)
1408 requested = size - bytesdone;
1409 if (requested > 4096)
1412 memset(urb,0,
sizeof(urb));
1414 urb->type = USBDEVFS_URB_TYPE_BULK;
1417 urb->buffer = bytes + bytesdone;
1418 urb->buffer_length = requested;
1420 urb->actual_length = 0;
1421 urb->number_of_packets = 0;
1422 urb->usercontext = 0;
1426 ret = ioctl(ftdi->
usb_dev->
fd, USBDEVFS_SUBMITURB, urb);
1428 while (ret < 0 && errno == EINTR);
1432 bytesdone += requested;
1434 while (bytesdone < size);
1461 int total_written = 0;
1463 if (ftdi == NULL || ftdi->
usb_dev == NULL)
1466 while (offset < size)
1470 if (offset+write_size > size)
1471 write_size = size-offset;
1473 ret = _usb_bulk_write_async(ftdi, ftdi->
in_ep, buf+offset, write_size);
1477 total_written += ret;
1478 offset += write_size;
1481 return total_written;
1483 #endif // LIBFTDI_LINUX_ASYNC_MODE
1540 int offset = 0, ret = 1, i, num_of_chunks, chunk_remains;
1543 if (ftdi == NULL || ftdi->
usb_dev == NULL)
1548 if (packet_size == 0)
1552 if (size <= ftdi->readbuffer_remaining)
1573 while (offset < size && ret > 0)
1586 num_of_chunks = ret / packet_size;
1587 chunk_remains = ret % packet_size;
1593 if (ret > packet_size - 2)
1595 for (i = 1; i < num_of_chunks; i++)
1599 if (chunk_remains > 2)
1604 ret -= 2*num_of_chunks;
1607 ret -= 2*(num_of_chunks-1)+chunk_remains;
1618 if (offset+ret <= size)
1633 int part_size = size-offset;
1638 offset += part_size;
1665 unsigned char *new_buf;
1674 if ((new_buf = (
unsigned char *)realloc(ftdi->
readbuffer, chunksize)) == NULL)
1717 unsigned short usb_val;
1719 if (ftdi == NULL || ftdi->
usb_dev == NULL)
1729 ftdi_error_return(-1,
"unable to enter bitbang mode. Perhaps not a BM type chip?");
1746 if (ftdi == NULL || ftdi->
usb_dev == NULL)
1750 ftdi_error_return(-1,
"unable to leave bitbang mode. Perhaps not a BM type chip?");
1770 unsigned short usb_val;
1772 if (ftdi == NULL || ftdi->
usb_dev == NULL)
1776 usb_val |= (mode << 8);
1778 ftdi_error_return(-1,
"unable to configure bitbang mode. Perhaps selected mode not supported on your chip?");
1797 if (ftdi == NULL || ftdi->
usb_dev == NULL)
1823 unsigned short usb_val;
1828 if (ftdi == NULL || ftdi->
usb_dev == NULL)
1850 unsigned short usb_val;
1852 if (ftdi == NULL || ftdi->
usb_dev == NULL)
1858 *latency = (
unsigned char)usb_val;
1906 if (ftdi == NULL || ftdi->
usb_dev == NULL)
1912 *status = (usb_val[1] << 8) | (usb_val[0] & 0xFF);
1930 if (ftdi == NULL || ftdi->
usb_dev == NULL)
1953 unsigned short usb_val;
1955 if (ftdi == NULL || ftdi->
usb_dev == NULL)
1983 unsigned short usb_val;
1985 if (ftdi == NULL || ftdi->
usb_dev == NULL)
2014 unsigned short usb_val;
2016 if (ftdi == NULL || ftdi->
usb_dev == NULL)
2049 unsigned char eventch,
unsigned char enable)
2051 unsigned short usb_val;
2053 if (ftdi == NULL || ftdi->
usb_dev == NULL)
2078 unsigned char errorch,
unsigned char enable)
2080 unsigned short usb_val;
2082 if (ftdi == NULL || ftdi->
usb_dev == NULL)
2143 for (i=0; i < 5; i++)
2171 if (eeprom->
serial != 0) {
2195 unsigned short checksum, value;
2196 unsigned char manufacturer_size = 0, product_size = 0, serial_size = 0;
2198 const int cbus_max[5] = {13, 13, 13, 13, 9};
2206 product_size = strlen(eeprom->
product);
2207 if (eeprom->
serial != NULL)
2208 serial_size = strlen(eeprom->
serial);
2211 for (i = 0; i < 5; i++)
2218 if (eeprom->
invert)
return -4;
2222 size_check = eeprom->
size;
2229 if (eeprom->
size>=256) size_check = 120;
2230 size_check -= manufacturer_size*2;
2231 size_check -= product_size*2;
2232 size_check -= serial_size*2;
2239 memset (output, 0, eeprom->
size);
2245 output[0x01] = 0x40;
2256 output[0x06] = 0x00;
2259 output[0x07] = 0x02;
2262 output[0x07] = 0x04;
2265 output[0x07] = 0x05;
2268 output[0x07] = 0x06;
2271 output[0x07] = 0x07;
2274 output[0x07] = 0x08;
2277 output[0x07] = 0x09;
2280 output[0x07] = 0x00;
2322 output[0x0B] = eeprom->
invert & 0xff;
2335 output[0x0F] = manufacturer_size*2 + 2;
2339 output[0x11] = product_size*2 + 2;
2343 output[0x13] = serial_size*2 + 2;
2361 if (eeprom->
size >= 256) i = 0x80;
2365 output[0x0E] = i | 0x80;
2366 output[i++] = manufacturer_size*2 + 2;
2368 for (j = 0; j < manufacturer_size; j++)
2371 output[i] = 0x00, i++;
2375 output[0x10] = i | 0x80;
2376 output[i] = product_size*2 + 2, i++;
2377 output[i] = 0x03, i++;
2378 for (j = 0; j < product_size; j++)
2380 output[i] = eeprom->
product[j], i++;
2381 output[i] = 0x00, i++;
2385 output[0x12] = i | 0x80;
2386 output[i] = serial_size*2 + 2, i++;
2387 output[i] = 0x03, i++;
2388 for (j = 0; j < serial_size; j++)
2390 output[i] = eeprom->
serial[j], i++;
2391 output[i] = 0x00, i++;
2397 for (i = 0; i < eeprom->
size/2-1; i++)
2399 value = output[i*2];
2400 value += output[(i*2)+1] << 8;
2402 checksum = value^checksum;
2403 checksum = (checksum << 1) | (checksum >> 15);
2406 output[eeprom->
size-2] = checksum;
2407 output[eeprom->
size-1] = checksum >> 8;
2428 unsigned short checksum, eeprom_checksum, value;
2429 unsigned char manufacturer_size = 0, product_size = 0, serial_size = 0;
2431 int eeprom_size = 128;
2436 size_check = eeprom->
size;
2443 if (eeprom->
size>=256)size_check = 120;
2444 size_check -= manufacturer_size*2;
2445 size_check -= product_size*2;
2446 size_check -= serial_size*2;
2460 eeprom->
vendor_id = buf[0x02] + (buf[0x03] << 8);
2463 eeprom->
product_id = buf[0x04] + (buf[0x05] << 8);
2465 value = buf[0x06] + (buf[0x07]<<8);
2521 eeprom->
invert = buf[0x0B];
2527 eeprom->
usb_version = buf[0x0C] + (buf[0x0D] << 8);
2532 manufacturer_size = buf[0x0F]/2;
2533 if (manufacturer_size > 0) eeprom->
manufacturer = malloc(manufacturer_size);
2538 product_size = buf[0x11]/2;
2539 if (product_size > 0) eeprom->
product = malloc(product_size);
2544 serial_size = buf[0x13]/2;
2545 if (serial_size > 0) eeprom->
serial = malloc(serial_size);
2546 else eeprom->
serial = NULL;
2562 i = buf[0x0E] & 0x7f;
2563 for (j=0;j<manufacturer_size-1;j++)
2570 i = buf[0x10] & 0x7f;
2571 for (j=0;j<product_size-1;j++)
2573 eeprom->
product[j] = buf[2*j+i+2];
2578 i = buf[0x12] & 0x7f;
2579 for (j=0;j<serial_size-1;j++)
2581 eeprom->
serial[j] = buf[2*j+i+2];
2583 eeprom->
serial[j] =
'\0';
2588 for (i = 0; i < eeprom_size/2-1; i++)
2591 value += buf[(i*2)+1] << 8;
2593 checksum = value^checksum;
2594 checksum = (checksum << 1) | (checksum >> 15);
2597 eeprom_checksum = buf[eeprom_size-2] + (buf[eeprom_size-1] << 8);
2599 if (eeprom_checksum != checksum)
2601 fprintf(stderr,
"Checksum Error: %04x %04x\n", checksum, eeprom_checksum);
2621 if (ftdi == NULL || ftdi->
usb_dev == NULL)
2644 if (ftdi == NULL || ftdi->
usb_dev == NULL)
2661 static unsigned char ftdi_read_chipid_shift(
unsigned char value)
2663 return ((value & 1) << 1) |
2664 ((value & 2) << 5) |
2665 ((value & 4) >> 2) |
2666 ((value & 8) << 4) |
2667 ((value & 16) >> 1) |
2668 ((value & 32) >> 1) |
2669 ((value & 64) >> 4) |
2670 ((value & 128) >> 2);
2685 unsigned int a = 0, b = 0;
2687 if (ftdi == NULL || ftdi->
usb_dev == NULL)
2692 a = a << 8 | a >> 8;
2695 b = b << 8 | b >> 8;
2696 a = (a << 16) | (b & 0xFFFF);
2697 a = ftdi_read_chipid_shift(a) | ftdi_read_chipid_shift(a>>8)<<8
2698 | ftdi_read_chipid_shift(a>>16)<<16 | ftdi_read_chipid_shift(a>>24)<<24;
2699 *chipid = a ^ 0xa5f0f7d1;
2721 int i=0,j,minsize=32;
2724 if (ftdi == NULL || ftdi->
usb_dev == NULL)
2729 for (j = 0; i < maxsize/2 && j<size; j++)
2739 while (size<=maxsize && memcmp(eeprom,&eeprom[size/2],size/2)!=0);
2757 if (ftdi == NULL || ftdi->
usb_dev == NULL)
2780 unsigned short usb_val, status;
2783 if (ftdi == NULL || ftdi->
usb_dev == NULL)
2796 usb_val = eeprom[i*2];
2797 usb_val += eeprom[(i*2)+1] << 8;
2820 if (ftdi == NULL || ftdi->
usb_dev == NULL)
int ftdi_read_pins(struct ftdi_context *ftdi, unsigned char *pins)
int ftdi_usb_open(struct ftdi_context *ftdi, int vendor, int product)
#define FTDI_DEVICE_OUT_REQTYPE
enum ftdi_module_detach_mode module_detach_mode
#define SIO_SET_LATENCY_TIMER_REQUEST
list of usb devices created by ftdi_usb_find_all()
struct ftdi_device_list * next
int ftdi_read_data_get_chunksize(struct ftdi_context *ftdi, unsigned int *chunksize)
void ftdi_list_free2(struct ftdi_device_list *devlist)
int ftdi_usb_purge_tx_buffer(struct ftdi_context *ftdi)
#define SIO_SET_EVENT_CHAR_REQUEST
int ftdi_read_eeprom_location(struct ftdi_context *ftdi, int eeprom_addr, unsigned short *eeprom_val)
void ftdi_deinit(struct ftdi_context *ftdi)
#define HIGH_CURRENT_DRIVE
#define SIO_READ_PINS_REQUEST
#define SIO_RESET_REQUEST
int ftdi_usb_open_desc_index(struct ftdi_context *ftdi, int vendor, int product, const char *description, const char *serial, unsigned int index)
#define SIO_SET_BAUDRATE_REQUEST
int ftdi_set_baudrate(struct ftdi_context *ftdi, int baudrate)
int ftdi_write_eeprom(struct ftdi_context *ftdi, unsigned char *eeprom)
#define SIO_SET_DATA_REQUEST
#define SIO_WRITE_EEPROM_REQUEST
Main context structure for all libftdi functions.
int ftdi_usb_get_strings(struct ftdi_context *ftdi, struct usb_device *dev, char *manufacturer, int mnf_len, char *description, int desc_len, char *serial, int serial_len)
#define FTDI_URB_USERCONTEXT_COOKIE
int ftdi_set_event_char(struct ftdi_context *ftdi, unsigned char eventch, unsigned char enable)
int ftdi_set_bitmode(struct ftdi_context *ftdi, unsigned char bitmask, unsigned char mode)
void ftdi_list_free(struct ftdi_device_list **devlist)
int ftdi_enable_bitbang(struct ftdi_context *ftdi, unsigned char bitmask)
#define FTDI_DEVICE_IN_REQTYPE
int ftdi_set_line_property(struct ftdi_context *ftdi, enum ftdi_bits_type bits, enum ftdi_stopbits_type sbit, enum ftdi_parity_type parity)
int ftdi_usb_purge_rx_buffer(struct ftdi_context *ftdi)
struct ftdi_context * ftdi_new(void)
int ftdi_write_data(struct ftdi_context *ftdi, unsigned char *buf, int size)
void ftdi_eeprom_setsize(struct ftdi_context *ftdi, struct ftdi_eeprom *eeprom, int size)
int ftdi_erase_eeprom(struct ftdi_context *ftdi)
int ftdi_set_interface(struct ftdi_context *ftdi, enum ftdi_interface interface)
#define FTDI_DEFAULT_EEPROM_SIZE
int ftdi_read_eeprom(struct ftdi_context *ftdi, unsigned char *eeprom)
unsigned int readbuffer_remaining
void ftdi_set_usbdev(struct ftdi_context *ftdi, usb_dev_handle *usb)
int ftdi_usb_open_dev(struct ftdi_context *ftdi, struct usb_device *dev)
int ftdi_set_error_char(struct ftdi_context *ftdi, unsigned char errorch, unsigned char enable)
#define SIO_GET_LATENCY_TIMER_REQUEST
unsigned int async_usb_buffer_size
int ftdi_init(struct ftdi_context *ftdi)
int ftdi_eeprom_decode(struct ftdi_eeprom *eeprom, unsigned char *buf, int size)
void ftdi_async_complete(struct ftdi_context *ftdi, int wait_for_more)
unsigned char * readbuffer
unsigned int writebuffer_chunksize
void ftdi_eeprom_initdefaults(struct ftdi_eeprom *eeprom)
#define SIO_READ_EEPROM_REQUEST
int ftdi_poll_modem_status(struct ftdi_context *ftdi, unsigned short *status)
int ftdi_setdtr_rts(struct ftdi_context *ftdi, int dtr, int rts)
#define SIO_SET_FLOW_CTRL_REQUEST
#define SIO_SET_BITMODE_REQUEST
#define SIO_SET_ERROR_CHAR_REQUEST
int ftdi_write_data_set_chunksize(struct ftdi_context *ftdi, unsigned int chunksize)
unsigned char bitbang_mode
int ftdi_eeprom_build(struct ftdi_eeprom *eeprom, unsigned char *output)
#define SIO_SET_MODEM_CTRL_REQUEST
#define SIO_POLL_MODEM_STATUS_REQUEST
int ftdi_setflowctrl(struct ftdi_context *ftdi, int flowctrl)
void ftdi_eeprom_free(struct ftdi_eeprom *eeprom)
int ftdi_usb_open_desc(struct ftdi_context *ftdi, int vendor, int product, const char *description, const char *serial)
struct usb_dev_handle * usb_dev
int ftdi_usb_close(struct ftdi_context *ftdi)
unsigned int max_packet_size
int ftdi_setrts(struct ftdi_context *ftdi, int state)
int ftdi_usb_reset(struct ftdi_context *ftdi)
int ftdi_get_latency_timer(struct ftdi_context *ftdi, unsigned char *latency)
int ftdi_read_data_set_chunksize(struct ftdi_context *ftdi, unsigned int chunksize)
#define SIO_RESET_PURGE_RX
int ftdi_write_data_get_chunksize(struct ftdi_context *ftdi, unsigned int *chunksize)
unsigned char bitbang_enabled
int ftdi_usb_open_string(struct ftdi_context *ftdi, const char *description)
int ftdi_disable_bitbang(struct ftdi_context *ftdi)
int ftdi_setdtr(struct ftdi_context *ftdi, int state)
int ftdi_set_latency_timer(struct ftdi_context *ftdi, unsigned char latency)
#define SIO_RESET_PURGE_TX
unsigned int readbuffer_chunksize
char * ftdi_get_error_string(struct ftdi_context *ftdi)
#define SIO_ERASE_EEPROM_REQUEST
int ftdi_read_eeprom_getsize(struct ftdi_context *ftdi, unsigned char *eeprom, int maxsize)
int ftdi_usb_purge_buffers(struct ftdi_context *ftdi)
int ftdi_read_data(struct ftdi_context *ftdi, unsigned char *buf, int size)
int ftdi_write_eeprom_location(struct ftdi_context *ftdi, int eeprom_addr, unsigned short eeprom_val)
#define ftdi_error_return(code, str)
unsigned int readbuffer_offset
int ftdi_write_data_async(struct ftdi_context *ftdi, unsigned char *buf, int size)
void ftdi_free(struct ftdi_context *ftdi)
int ftdi_read_chipid(struct ftdi_context *ftdi, unsigned int *chipid)
int ftdi_usb_find_all(struct ftdi_context *ftdi, struct ftdi_device_list **devlist, int vendor, int product)
int ftdi_set_line_property2(struct ftdi_context *ftdi, enum ftdi_bits_type bits, enum ftdi_stopbits_type sbit, enum ftdi_parity_type parity, enum ftdi_break_type break_type)