libftdi prototypes in Linux (ftdi.h)
ftdi_init(struct ftdi_context *ftdi);
- Fills struct ftdi_context with default values
- Allocates the read buffer to 4096 chunksize using ftdi_read_set_chunksize.
int ftdi_set_interface(struct ftdi_context *ftdi, enum ftdi_interface interface);
- Sets the interface, index, and end points to values different from that set by ftdi_init or ftdi_open.
void ftdi_deinit(struct ftdi_context *ftdi);
- Deallocates the buffer space in an ftdi_context.
void ftdi_set_usbdev (struct ftdi_context *ftdi, usb_dev_handle *usbdev);
- Sets the ftdi_context device pointer to the specified device handle.
int ftdi_usb_find_all(struct ftdi_context *ftdi, struct ftdi_device_list **devlist, int vendor, int product);
- Does usb_init.
- Creates a linked list of all devices with the specified vendor and product identifications.
- List must be deallocated when not needed.
void ftdi_list_free(struct ftdi_device_list **devlist);
- Deallocates a device list created by ftdi_usb_find_all.
int ftdi_usb_open(struct ftdi_context *ftdi, int vendor, int product);
- Simply does ftdi_usb_open_desc with null description and serial number parameters.
int ftdi_usb_open_desc(struct ftdi_context *ftdi, int vendor, int product, const char* description, const char* serial);
- Does usb_init
- Looks for devices that match the vendor and product codes, and also match the description and serial number values unless they are null. To check the description and serial numbers, each device is opened using usb_open, checked, and then closed using usb_close.
- Ends by reopening the selected device (the first one matched) using ftdi_usb_open_dev and returns the file handle.
int ftdi_usb_open_dev(struct ftdi_context *ftdi, struct usb_device *dev);
- Does usb_open
- Does usb_claim_interface
- Does ftdi_usb_reset
- Does ftdi_set_baudrate
- Ascertains chip type, and for 2322C, sets ftdi.index to 1 if not already set.
int ftdi_usb_close(struct ftdi_context *ftdi);
- Does usb_release_interface
- Does usb_close.
int ftdi_usb_reset(struct ftdi_context *ftdi);
- Uses usb_control_msg to send request_type 0x40, request 0x00, and value 0x00 to channel ftdi.index.
int ftdi_usb_purge_buffers(struct ftdi_context *ftdi);
- Uses usb_control_msg to send request_type 0x40, request 0x00 and values 0x01 & 0x02 (RX & TX buffers) to channel ftdi.index.
int ftdi_set_baudrate(struct ftdi_context *ftdi, int baudrate);
- Uses usb_control_msg to send request_type 0x40, request 0x03, with value and index (calculated by ftdi_convert_baudrate). The upper 8 bits of the index parameter are used for the 8 additional divisor bits.
int ftdi_set_line_property(struct ftdi_context *ftdi, enum ftdi_bits_type bits, enum ftdi_stopbits_type sbit, enum ftdi_parity_type parity);
- Uses usb_control_msg to send request_type 0x40, request 0x04, with specified parity, data bit count, and stop bit specs to channel ftdi.index.
int ftdi_read_data(struct ftdi_context *ftdi, unsigned char *buf, int size);
- Uses usb_bulk_read to obtain ftdi.readbuffer_chunksize blocks and stacks them in buffer buf.
int ftdi_read_data_set_chunksize(struct ftdi_context *ftdi, unsigned int chunksize);
- Allocates ftdi.readbuffer
- Sets ftdi.offset=0, ftdi.readbuffer_remaining=0, and ftdi.readbuffer_chunksize=4096
int ftdi_read_data_get_chunksize(struct ftdi_context *ftdi, unsigned int *chunksize);
- Returns the chunksize for reading data (ftdi.readbuffer_chunksize).
int ftdi_write_data(struct ftdi_context *ftdi, unsigned char *buf, int size);
- Uses usb_bulk_write to send buf contents in chunksize blocks to device specified in ftdi.
int ftdi_write_data_set_chunksize(struct ftdi_context *ftdi, unsigned int chunksize);
- Sets ftdi.writebuffer_chunksize to chunksize.
int ftdi_write_data_get_chunksize(struct ftdi_context *ftdi, unsigned int *chunksize);
- Returns the chunksize for writing data (ftdi.writebuffer_chunksize).
int ftdi_enable_bitbang(struct ftdi_context *ftdi, unsigned char bitmask);
- Uses usb_control_msg to send request_type 0x40, request 0x0B, with value (ftdi.bitbang_mode in upper 8 bits and bitmask in low 8 bits) to channel ftdi.index.
- Sets ftdi.bitbang_enabled=1.
int ftdi_disable_bitbang(struct ftdi_context *ftdi);
- Uses usb_control_msg to send request_type 0x40, request 0x0B, with value 0 to channel ftdi.index.
- Sets ftdi.bitbang_enabled=0.
int ftdi_set_bitmode(struct ftdi_context *ftdi, unsigned char bitmask, unsigned char mode);
- Uses usb_control_msg to send request_type 0x40, request 0x0B, with value (mode in the upper 8 bits and bitmask in the lower 8 bits) 0 to channel ftdi.index.
- Sets ftdi.bitbang_mode=mode and sets ftdi.bitbang_enabled on bitbang or syncbitbang modes.
int ftdi_read_pins(struct ftdi_context *ftdi, unsigned char *pins);
- Uses usb_control_msg to send request_type 0xC0, request 0x0C, with value 0 to channel ftdi.index with result placed in pins, size=1.
int ftdi_set_latency_timer(struct ftdi_context *ftdi, unsigned char latency);
- Uses usb_control_msg to send request_type 0x40, request 0x09, value=latency to channel ftdi.index.
int ftdi_get_latency_timer(struct ftdi_context *ftdi, unsigned char *latency);
- Uses usb_control_msg to send request_type 0xC0, request 0x0A, value=0 to channel ftdi.index with result placed in latency, size=1.
void ftdi_eeprom_initdefaults(struct ftdi_eeprom *eeprom);
- Sets default values into EEPROM.
int ftdi_eeprom_build(struct ftdi_eeprom *eeprom, unsigned char *output);
- Assembles EEPROM data into a 128-byte array that ends with a 2-byte checksum.
int ftdi_read_eeprom(struct ftdi_context *ftdi, unsigned char *eeprom);
- Uses 64 usb_control_msg commands to send request_type 0xC0, request 0x90, with value 0 and index=word address. This fills EEPROM 2 bytes at a time.
int ftdi_write_eeprom(struct ftdi_context *ftdi, unsigned char *eeprom);
- Uses 64 usb_control_msgs to send request_type 0x40, request 0x91, with value=2-byte words and index=word aliress. This fills the ftdi chip's EEPROM 2 bytes at a time.
int ftdi_erase_eeprom(struct ftdi_context *ftdi);
- Uses usb_control_msg to send request_type 0x40, request 0x92, with value=0 and index=0.
int ftdi_setflowctrl(struct ftdi_context *ftdi, int flowctrl);
- Disables flow control or sets type of flow control (RTS/CTS, DTR/DSR, or XON/XOFF).
int ftdi_setdtr(struct ftdi_context *ftdi, int state);
- Sets the DTR UART control line to either 1 (high) or 0 (low) as specified by state.
int ftdi_setrts(struct ftdi_context *ftdi, int state);
- Sets the RTS UART control line to either 1 (high) or 0 (low) as specified by state.
char *ftdi_get_error_string(struct ftdi_context *ftdi);
- Returns ftdi.error_str defined by various commands using an inline function ftdi_error_return.
Last updated: February 18, 2007
Contact Craig Van Degrift if you have problems or questions with this web site.