Defines | |
| #define | ftdi_error_return(code, str) |
Functions | |
| int | ftdi_init (struct ftdi_context *ftdi) |
| int | ftdi_set_interface (struct ftdi_context *ftdi, enum ftdi_interface interface) |
| void | ftdi_deinit (struct ftdi_context *ftdi) |
| void | ftdi_set_usbdev (struct ftdi_context *ftdi, usb_dev_handle *usb) |
| int | ftdi_usb_find_all (struct ftdi_context *ftdi, struct ftdi_device_list **devlist, int vendor, int product) |
| void | ftdi_list_free (struct ftdi_device_list **devlist) |
| 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) |
| int | ftdi_usb_open_dev (struct ftdi_context *ftdi, struct usb_device *dev) |
| int | ftdi_usb_open (struct ftdi_context *ftdi, int vendor, int product) |
| int | ftdi_usb_open_desc (struct ftdi_context *ftdi, int vendor, int product, const char *description, const char *serial) |
| int | ftdi_usb_reset (struct ftdi_context *ftdi) |
| int | ftdi_usb_purge_buffers (struct ftdi_context *ftdi) |
| int | ftdi_usb_close (struct ftdi_context *ftdi) |
| int | ftdi_set_baudrate (struct ftdi_context *ftdi, int baudrate) |
| 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_write_data (struct ftdi_context *ftdi, unsigned char *buf, int size) |
| int | ftdi_write_data_set_chunksize (struct ftdi_context *ftdi, unsigned int chunksize) |
| int | ftdi_write_data_get_chunksize (struct ftdi_context *ftdi, unsigned int *chunksize) |
| int | ftdi_read_data (struct ftdi_context *ftdi, unsigned char *buf, int size) |
| int | ftdi_read_data_set_chunksize (struct ftdi_context *ftdi, unsigned int chunksize) |
| int | ftdi_read_data_get_chunksize (struct ftdi_context *ftdi, unsigned int *chunksize) |
| int | ftdi_enable_bitbang (struct ftdi_context *ftdi, unsigned char bitmask) |
| int | ftdi_disable_bitbang (struct ftdi_context *ftdi) |
| int | ftdi_set_bitmode (struct ftdi_context *ftdi, unsigned char bitmask, unsigned char mode) |
| int | ftdi_read_pins (struct ftdi_context *ftdi, unsigned char *pins) |
| int | ftdi_set_latency_timer (struct ftdi_context *ftdi, unsigned char latency) |
| int | ftdi_get_latency_timer (struct ftdi_context *ftdi, unsigned char *latency) |
| void | ftdi_eeprom_initdefaults (struct ftdi_eeprom *eeprom) |
| int | ftdi_eeprom_build (struct ftdi_eeprom *eeprom, unsigned char *output) |
| int | ftdi_read_eeprom (struct ftdi_context *ftdi, unsigned char *eeprom) |
| int | ftdi_write_eeprom (struct ftdi_context *ftdi, unsigned char *eeprom) |
| int | ftdi_erase_eeprom (struct ftdi_context *ftdi) |
| char * | ftdi_get_error_string (struct ftdi_context *ftdi) |
| int | ftdi_setflowctrl (struct ftdi_context *ftdi, int flowctrl) |
| int | ftdi_setdtr (struct ftdi_context *ftdi, int state) |
| int | ftdi_setrts (struct ftdi_context *ftdi, int state) |
| #define ftdi_error_return | ( | code, | |||
| str | ) |
Value:
do { \ ftdi->error_str = str; \ return code; \ } while(0);
| int ftdi_init | ( | struct ftdi_context * | ftdi | ) |
Initializes a ftdi_context.
| ftdi | pointer to ftdi_context |
| 0,: | all fine | |
| -1,: | couldn't allocate read buffer |
| int ftdi_set_interface | ( | struct ftdi_context * | ftdi, | |
| enum ftdi_interface | interface | |||
| ) |
Open selected channels on a chip, otherwise use first channel.
| ftdi | pointer to ftdi_context | |
| interface | Interface to use for FT2232C chips. |
| 0,: | all fine | |
| -1,: | unknown interface |
| void ftdi_deinit | ( | struct ftdi_context * | ftdi | ) |
| void ftdi_set_usbdev | ( | struct ftdi_context * | ftdi, | |
| usb_dev_handle * | usb | |||
| ) |
Use an already open libusb device.
| ftdi | pointer to ftdi_context | |
| usb | libusb usb_dev_handle to use |
| int ftdi_usb_find_all | ( | struct ftdi_context * | ftdi, | |
| struct ftdi_device_list ** | devlist, | |||
| int | vendor, | |||
| int | product | |||
| ) |
Finds all ftdi devices on the usb bus. Creates a new ftdi_device_list which needs to be deallocated by ftdi_list_free() after use.
| ftdi | pointer to ftdi_context | |
| devlist | Pointer where to store list of found devices | |
| vendor | Vendor ID to search for | |
| product | Product ID to search for |
| >0,: | number of devices found | |
| -1,: | usb_find_busses() failed | |
| -2,: | usb_find_devices() failed | |
| -3,: | out of memory |
| void ftdi_list_free | ( | struct ftdi_device_list ** | devlist | ) |
| 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 | |||
| ) |
Return device ID strings from the usb device.
The parameters manufacturer, description and serial may be NULL or pointer to buffers to store the fetched strings.
| ftdi | pointer to ftdi_context | |
| dev | libusb usb_dev to use | |
| manufacturer | Store manufacturer string here if not NULL | |
| mnf_len | Buffer size of manufacturer string | |
| description | Store product description string here if not NULL | |
| desc_len | Buffer size of product description string | |
| serial | Store serial string here if not NULL | |
| serial_len | Buffer size of serial string |
| 0,: | all fine | |
| -1,: | wrong arguments | |
| -4,: | unable to open device | |
| -7,: | get product manufacturer failed | |
| -8,: | get product description failed | |
| -9,: | get serial number failed | |
| -10,: | unable to close device |
| int ftdi_usb_open_dev | ( | struct ftdi_context * | ftdi, | |
| struct usb_device * | dev | |||
| ) |
Opens a ftdi device given by a usb_device.
| ftdi | pointer to ftdi_context | |
| dev | libusb usb_dev to use |
| 0,: | all fine | |
| -4,: | unable to open device | |
| -5,: | unable to claim device | |
| -6,: | reset failed | |
| -7,: | set baudrate failed |
| int ftdi_usb_open | ( | struct ftdi_context * | ftdi, | |
| int | vendor, | |||
| int | product | |||
| ) |
Opens the first device with a given vendor and product ids.
| ftdi | pointer to ftdi_context | |
| vendor | Vendor ID | |
| product | Product ID |
| same | as ftdi_usb_open_desc() |
| int ftdi_usb_open_desc | ( | struct ftdi_context * | ftdi, | |
| int | vendor, | |||
| int | product, | |||
| const char * | description, | |||
| const char * | serial | |||
| ) |
Opens the first device with a given, vendor id, product id, description and serial.
| ftdi | pointer to ftdi_context | |
| vendor | Vendor ID | |
| product | Product ID | |
| description | Description to search for. Use NULL if not needed. | |
| serial | Serial to search for. Use NULL if not needed. |
| 0,: | all fine | |
| -1,: | usb_find_busses() failed | |
| -2,: | usb_find_devices() failed | |
| -3,: | usb device not found | |
| -4,: | unable to open device | |
| -5,: | unable to claim device | |
| -6,: | reset failed | |
| -7,: | set baudrate failed | |
| -8,: | get product description failed | |
| -9,: | get serial number failed | |
| -10,: | unable to close device |
| int ftdi_usb_reset | ( | struct ftdi_context * | ftdi | ) |
Resets the ftdi device.
| ftdi | pointer to ftdi_context |
| 0,: | all fine | |
| -1,: | FTDI reset failed |
| int ftdi_usb_purge_buffers | ( | struct ftdi_context * | ftdi | ) |
Clears the buffers on the chip.
| ftdi | pointer to ftdi_context |
| 0,: | all fine | |
| -1,: | write buffer purge failed | |
| -2,: | read buffer purge failed |
| int ftdi_usb_close | ( | struct ftdi_context * | ftdi | ) |
Closes the ftdi device. Call ftdi_deinit() if you're cleaning up.
| ftdi | pointer to ftdi_context |
| 0,: | all fine | |
| -1,: | usb_release failed | |
| -2,: | usb_close failed |
| int ftdi_set_baudrate | ( | struct ftdi_context * | ftdi, | |
| int | baudrate | |||
| ) |
Sets the chip baud rate
| ftdi | pointer to ftdi_context | |
| baudrate | baud rate to set |
| 0,: | all fine | |
| -1,: | invalid baudrate | |
| -2,: | setting baudrate failed |
| int ftdi_set_line_property | ( | struct ftdi_context * | ftdi, | |
| enum ftdi_bits_type | bits, | |||
| enum ftdi_stopbits_type | sbit, | |||
| enum ftdi_parity_type | parity | |||
| ) |
Set (RS232) line characteristics by Alain Abbas
| ftdi | pointer to ftdi_context | |
| bits | Number of bits | |
| sbit | Number of stop bits | |
| parity | Parity mode |
| 0,: | all fine | |
| -1,: | Setting line property failed |
| int ftdi_write_data | ( | struct ftdi_context * | ftdi, | |
| unsigned char * | buf, | |||
| int | size | |||
| ) |
Writes data in chunks (see ftdi_write_data_set_chunksize()) to the chip
| ftdi | pointer to ftdi_context | |
| buf | Buffer with the data | |
| size | Size of the buffer |
| <0,: | error code from usb_bulk_write() | |
| >0,: | number of bytes written |
| int ftdi_write_data_set_chunksize | ( | struct ftdi_context * | ftdi, | |
| unsigned int | chunksize | |||
| ) |
Configure write buffer chunk size. Default is 4096.
| ftdi | pointer to ftdi_context | |
| chunksize | Chunk size |
| 0,: | all fine |
| int ftdi_write_data_get_chunksize | ( | struct ftdi_context * | ftdi, | |
| unsigned int * | chunksize | |||
| ) |
Get write buffer chunk size.
| ftdi | pointer to ftdi_context | |
| chunksize | Pointer to store chunk size in |
| 0,: | all fine |
| int ftdi_read_data | ( | struct ftdi_context * | ftdi, | |
| unsigned char * | buf, | |||
| int | size | |||
| ) |
Reads data in chunks (see ftdi_read_data_set_chunksize()) from the chip.
Automatically strips the two modem status bytes transfered during every read.
| ftdi | pointer to ftdi_context | |
| buf | Buffer to store data in | |
| size | Size of the buffer |
| <0,: | error code from usb_bulk_read() | |
| 0,: | no data was available | |
| >0,: | number of bytes read |
| int ftdi_read_data_set_chunksize | ( | struct ftdi_context * | ftdi, | |
| unsigned int | chunksize | |||
| ) |
Configure read buffer chunk size. Default is 4096.
Automatically reallocates the buffer.
| ftdi | pointer to ftdi_context | |
| chunksize | Chunk size |
| 0,: | all fine |
| int ftdi_read_data_get_chunksize | ( | struct ftdi_context * | ftdi, | |
| unsigned int * | chunksize | |||
| ) |
Get read buffer chunk size.
| ftdi | pointer to ftdi_context | |
| chunksize | Pointer to store chunk size in |
| 0,: | all fine |
| int ftdi_enable_bitbang | ( | struct ftdi_context * | ftdi, | |
| unsigned char | bitmask | |||
| ) |
Enable bitbang mode.
For advanced bitbang modes of the FT2232C chip use ftdi_set_bitmode().
| ftdi | pointer to ftdi_context | |
| bitmask | Bitmask to configure lines. HIGH/ON value configures a line as output. |
| 0,: | all fine | |
| -1,: | can't enable bitbang mode |
| int ftdi_disable_bitbang | ( | struct ftdi_context * | ftdi | ) |
Disable bitbang mode.
| ftdi | pointer to ftdi_context |
| 0,: | all fine | |
| -1,: | can't disable bitbang mode |
| int ftdi_set_bitmode | ( | struct ftdi_context * | ftdi, | |
| unsigned char | bitmask, | |||
| unsigned char | mode | |||
| ) |
Enable advanced bitbang mode for FT2232C chips.
| ftdi | pointer to ftdi_context | |
| bitmask | Bitmask to configure lines. HIGH/ON value configures a line as output. | |
| mode | Bitbang mode: 1 for normal mode, 2 for SPI mode |
| 0,: | all fine | |
| -1,: | can't enable bitbang mode |
| int ftdi_read_pins | ( | struct ftdi_context * | ftdi, | |
| unsigned char * | pins | |||
| ) |
Directly read pin state. Useful for bitbang mode.
| ftdi | pointer to ftdi_context | |
| pins | Pointer to store pins into |
| 0,: | all fine | |
| -1,: | read pins failed |
| int ftdi_set_latency_timer | ( | struct ftdi_context * | ftdi, | |
| unsigned char | latency | |||
| ) |
Set latency timer
The FTDI chip keeps data in the internal buffer for a specific amount of time if the buffer is not full yet to decrease load on the usb bus.
| ftdi | pointer to ftdi_context | |
| latency | Value between 1 and 255 |
| 0,: | all fine | |
| -1,: | latency out of range | |
| -2,: | unable to set latency timer |
| int ftdi_get_latency_timer | ( | struct ftdi_context * | ftdi, | |
| unsigned char * | latency | |||
| ) |
Get latency timer
| ftdi | pointer to ftdi_context | |
| latency | Pointer to store latency value in |
| 0,: | all fine | |
| -1,: | unable to get latency timer |
| void ftdi_eeprom_initdefaults | ( | struct ftdi_eeprom * | eeprom | ) |
| int ftdi_eeprom_build | ( | struct ftdi_eeprom * | eeprom, | |
| unsigned char * | output | |||
| ) |
Build binary output from ftdi_eeprom structure. Output is suitable for ftdi_write_eeprom().
| eeprom | Pointer to ftdi_eeprom | |
| output | Buffer of 128 bytes to store eeprom image to |
| >0,: | used eeprom size | |
| -1,: | eeprom size (128 bytes) exceeded by custom strings |
| int ftdi_read_eeprom | ( | struct ftdi_context * | ftdi, | |
| unsigned char * | eeprom | |||
| ) |
Read eeprom
| ftdi | pointer to ftdi_context | |
| eeprom | Pointer to store eeprom into |
| 0,: | all fine | |
| -1,: | read failed |
| int ftdi_write_eeprom | ( | struct ftdi_context * | ftdi, | |
| unsigned char * | eeprom | |||
| ) |
Write eeprom
| ftdi | pointer to ftdi_context | |
| eeprom | Pointer to read eeprom from |
| 0,: | all fine | |
| -1,: | read failed |
| int ftdi_erase_eeprom | ( | struct ftdi_context * | ftdi | ) |
| char* ftdi_get_error_string | ( | struct ftdi_context * | ftdi | ) |
Get string representation for last error code
| ftdi | pointer to ftdi_context |
| Pointer | to error string |
| int ftdi_setflowctrl | ( | struct ftdi_context * | ftdi, | |
| int | flowctrl | |||
| ) |
Set flowcontrol for ftdi chip
| ftdi | pointer to ftdi_context | |
| flowctrl | flow control to use. should be SIO_DISABLE_FLOW_CTRL, SIO_RTS_CTS_HS, SIO_DTR_DSR_HS or SIO_XON_XOFF_HS |
| 0,: | all fine | |
| -1,: | set flow control failed |
| int ftdi_setdtr | ( | struct ftdi_context * | ftdi, | |
| int | state | |||
| ) |
Set dtr line
| ftdi | pointer to ftdi_context | |
| state | state to set line to (1 or 0) |
| 0,: | all fine | |
| -1,: | set dtr failed |
| int ftdi_setrts | ( | struct ftdi_context * | ftdi, | |
| int | state | |||
| ) |
Set rts line
| ftdi | pointer to ftdi_context | |
| state | state to set line to (1 or 0) |
| 0,: | all fine | |
| -1 | set rts failed |
1.5.4