Data Structures | |
struct | usb_dev_handle |
Defines | |
#define | ftdi_error_return(code, str) |
Functions | |
int | ftdi_init (struct ftdi_context *ftdi) |
struct ftdi_context * | ftdi_new () |
int | ftdi_set_interface (struct ftdi_context *ftdi, enum ftdi_interface interface) |
void | ftdi_deinit (struct ftdi_context *ftdi) |
void | ftdi_free (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) |
void | ftdi_list_free2 (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_rx_buffer (struct ftdi_context *ftdi) |
int | ftdi_usb_purge_tx_buffer (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_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) |
int | ftdi_write_data (struct ftdi_context *ftdi, unsigned char *buf, int size) |
void | ftdi_async_complete (struct ftdi_context *ftdi, int wait_for_more) |
int | ftdi_write_data_async (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) |
int | ftdi_poll_modem_status (struct ftdi_context *ftdi, unsigned short *status) |
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) |
int | ftdi_setdtr_rts (struct ftdi_context *ftdi, int dtr, int rts) |
int | ftdi_set_event_char (struct ftdi_context *ftdi, unsigned char eventch, unsigned char enable) |
int | ftdi_set_error_char (struct ftdi_context *ftdi, unsigned char errorch, unsigned char enable) |
void | ftdi_eeprom_setsize (struct ftdi_context *ftdi, struct ftdi_eeprom *eeprom, int size) |
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_read_chipid (struct ftdi_context *ftdi, unsigned int *chipid) |
int | ftdi_read_eeprom_getsize (struct ftdi_context *ftdi, unsigned char *eeprom, int maxsize) |
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) |
#define ftdi_error_return | ( | code, | |||
str | ) |
Value:
do { \ ftdi->error_str = str; \ return code; \ } while(0);
Referenced by ftdi_disable_bitbang(), ftdi_enable_bitbang(), ftdi_erase_eeprom(), ftdi_get_latency_timer(), ftdi_init(), ftdi_poll_modem_status(), ftdi_read_chipid(), ftdi_read_data(), ftdi_read_data_set_chunksize(), ftdi_read_eeprom(), ftdi_read_eeprom_getsize(), ftdi_read_pins(), ftdi_set_baudrate(), ftdi_set_bitmode(), ftdi_set_error_char(), ftdi_set_event_char(), ftdi_set_interface(), ftdi_set_latency_timer(), ftdi_set_line_property2(), ftdi_setdtr(), ftdi_setdtr_rts(), ftdi_setflowctrl(), ftdi_setrts(), ftdi_usb_find_all(), ftdi_usb_get_strings(), ftdi_usb_open_desc(), ftdi_usb_open_dev(), ftdi_usb_purge_rx_buffer(), ftdi_usb_purge_tx_buffer(), ftdi_usb_reset(), ftdi_write_data(), ftdi_write_data_async(), and ftdi_write_eeprom().
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 |
References ftdi_context::async_usb_buffer, ftdi_context::async_usb_buffer_size, ftdi_context::baudrate, ftdi_context::bitbang_enabled, ftdi_context::bitbang_mode, ftdi_context::eeprom_size, ftdi_context::error_str, FTDI_DEFAULT_EEPROM_SIZE, ftdi_error_return, ftdi_read_data_set_chunksize(), FTDI_URB_USERCONTEXT_COOKIE, ftdi_context::in_ep, ftdi_context::index, ftdi_context::interface, ftdi_context::out_ep, ftdi_context::readbuffer, ftdi_context::readbuffer_offset, ftdi_context::readbuffer_remaining, ftdi_context::type, TYPE_BM, ftdi_context::usb_dev, ftdi_context::usb_read_timeout, ftdi_context::usb_write_timeout, and ftdi_context::writebuffer_chunksize.
Referenced by ftdi_new().
struct ftdi_context* ftdi_new | ( | ) | [read] |
Allocate and initialize a new ftdi_context
References ftdi_init().
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 |
References ftdi_error_return, ftdi_context::in_ep, ftdi_context::index, ftdi_context::interface, INTERFACE_A, INTERFACE_ANY, INTERFACE_B, and ftdi_context::out_ep.
void ftdi_deinit | ( | struct ftdi_context * | ftdi | ) |
Deinitializes a ftdi_context.
ftdi | pointer to ftdi_context |
References ftdi_context::async_usb_buffer, and ftdi_context::readbuffer.
Referenced by ftdi_free().
void ftdi_free | ( | struct ftdi_context * | ftdi | ) |
Deinitialize and free an ftdi_context.
ftdi | pointer to ftdi_context |
References ftdi_deinit().
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 |
References ftdi_context::usb_dev.
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 |
References ftdi_error_return, and ftdi_device_list::next.
void ftdi_list_free | ( | struct ftdi_device_list ** | devlist | ) |
Frees a usb device list.
devlist | USB device list created by ftdi_usb_find_all() |
References ftdi_device_list::next.
Referenced by ftdi_list_free2().
void ftdi_list_free2 | ( | struct ftdi_device_list * | devlist | ) |
Frees a usb device list.
devlist | USB device list created by ftdi_usb_find_all() |
References ftdi_list_free().
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 |
References ftdi_error_return, and ftdi_context::usb_dev.
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 | |
-3,: | unable to config device | |
-4,: | unable to open device | |
-5,: | unable to claim device | |
-6,: | reset failed | |
-7,: | set baudrate failed |
References ftdi_error_return, ftdi_set_baudrate(), ftdi_usb_reset(), ftdi_context::index, ftdi_context::interface, INTERFACE_A, ftdi_context::type, TYPE_2232C, TYPE_AM, TYPE_BM, TYPE_R, and ftdi_context::usb_dev.
Referenced by ftdi_usb_open_desc().
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() |
References 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 |
References ftdi_error_return, ftdi_usb_open_dev(), and ftdi_context::usb_dev.
Referenced by ftdi_usb_open().
int ftdi_usb_reset | ( | struct ftdi_context * | ftdi | ) |
Resets the ftdi device.
ftdi | pointer to ftdi_context |
0,: | all fine | |
-1,: | FTDI reset failed |
References ftdi_error_return, ftdi_context::index, ftdi_context::readbuffer_offset, ftdi_context::readbuffer_remaining, SIO_RESET_REQUEST, SIO_RESET_REQUEST_TYPE, SIO_RESET_SIO, ftdi_context::usb_dev, and ftdi_context::usb_write_timeout.
Referenced by ftdi_usb_open_dev().
int ftdi_usb_purge_rx_buffer | ( | struct ftdi_context * | ftdi | ) |
Clears the read buffer on the chip and the internal read buffer.
ftdi | pointer to ftdi_context |
0,: | all fine | |
-1,: | read buffer purge failed |
References ftdi_error_return, ftdi_context::index, ftdi_context::readbuffer_offset, ftdi_context::readbuffer_remaining, SIO_RESET_PURGE_RX, SIO_RESET_REQUEST, SIO_RESET_REQUEST_TYPE, ftdi_context::usb_dev, and ftdi_context::usb_write_timeout.
Referenced by ftdi_usb_purge_buffers().
int ftdi_usb_purge_tx_buffer | ( | struct ftdi_context * | ftdi | ) |
Clears the write buffer on the chip.
ftdi | pointer to ftdi_context |
0,: | all fine | |
-1,: | write buffer purge failed |
References ftdi_error_return, ftdi_context::index, SIO_RESET_PURGE_TX, SIO_RESET_REQUEST, SIO_RESET_REQUEST_TYPE, ftdi_context::usb_dev, and ftdi_context::usb_write_timeout.
Referenced by ftdi_usb_purge_buffers().
int ftdi_usb_purge_buffers | ( | struct ftdi_context * | ftdi | ) |
Clears the buffers on the chip and the internal read buffer.
ftdi | pointer to ftdi_context |
0,: | all fine | |
-1,: | read buffer purge failed | |
-2,: | write buffer purge failed |
References ftdi_usb_purge_rx_buffer(), and ftdi_usb_purge_tx_buffer().
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 |
References ftdi_async_complete(), ftdi_context::interface, and ftdi_context::usb_dev.
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 |
References ftdi_context::baudrate, ftdi_context::bitbang_enabled, ftdi_error_return, SIO_SET_BAUDRATE_REQUEST, SIO_SET_BAUDRATE_REQUEST_TYPE, ftdi_context::usb_dev, and ftdi_context::usb_write_timeout.
Referenced by ftdi_usb_open_dev().
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. The break type can only be set via ftdi_set_line_property2() and defaults to "off".
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 |
References BREAK_OFF, and ftdi_set_line_property2().
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 | |||
) |
Set (RS232) line characteristics
ftdi | pointer to ftdi_context | |
bits | Number of bits | |
sbit | Number of stop bits | |
parity | Parity mode | |
break_type | Break type |
0,: | all fine | |
-1,: | Setting line property failed |
References BREAK_OFF, BREAK_ON, EVEN, ftdi_error_return, ftdi_context::index, MARK, NONE, ODD, SIO_SET_DATA_REQUEST, SIO_SET_DATA_REQUEST_TYPE, SPACE, STOP_BIT_1, STOP_BIT_15, STOP_BIT_2, ftdi_context::usb_dev, and ftdi_context::usb_write_timeout.
Referenced by ftdi_set_line_property().
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 |
References ftdi_error_return, ftdi_context::in_ep, ftdi_context::usb_dev, ftdi_context::usb_write_timeout, and ftdi_context::writebuffer_chunksize.
void ftdi_async_complete | ( | struct ftdi_context * | ftdi, | |
int | wait_for_more | |||
) |
Wait until one or more async URBs are completed by the kernel and mark their positions in the async-buffer as unused.
ftdi | pointer to ftdi_context | |
wait_for_more | if != 0 wait for more than one write to complete (until write timeout) |
References ftdi_context::usb_write_timeout.
Referenced by ftdi_usb_close().
int ftdi_write_data_async | ( | struct ftdi_context * | ftdi, | |
unsigned char * | buf, | |||
int | size | |||
) |
Writes data in chunks (see ftdi_write_data_set_chunksize()) to the chip. Does not wait for completion of the transfer nor does it make sure that the transfer was successful.
This function could be extended to use signals and callbacks to inform the caller of completion or error - but this is not done yet, volunteers welcome.
Works around libusb and directly accesses functions only available on Linux. Only available if compiled with --with-async-mode.
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 |
References ftdi_error_return, ftdi_context::in_ep, and ftdi_context::writebuffer_chunksize.
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 |
References ftdi_context::writebuffer_chunksize.
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 |
References ftdi_context::writebuffer_chunksize.
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 |
References ftdi_error_return, ftdi_context::out_ep, ftdi_context::readbuffer, ftdi_context::readbuffer_chunksize, ftdi_context::readbuffer_offset, ftdi_context::readbuffer_remaining, ftdi_context::usb_dev, and ftdi_context::usb_read_timeout.
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 |
References ftdi_error_return, ftdi_context::readbuffer, ftdi_context::readbuffer_chunksize, ftdi_context::readbuffer_offset, and ftdi_context::readbuffer_remaining.
Referenced by ftdi_init().
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 |
References ftdi_context::readbuffer_chunksize.
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 |
References ftdi_context::bitbang_enabled, ftdi_context::bitbang_mode, ftdi_error_return, ftdi_context::index, ftdi_context::usb_dev, and ftdi_context::usb_write_timeout.
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 |
References ftdi_context::bitbang_enabled, ftdi_error_return, ftdi_context::index, ftdi_context::usb_dev, and ftdi_context::usb_write_timeout.
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 |
References ftdi_context::bitbang_enabled, ftdi_context::bitbang_mode, BITMODE_BITBANG, BITMODE_SYNCBB, ftdi_error_return, ftdi_context::index, ftdi_context::usb_dev, and ftdi_context::usb_write_timeout.
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 |
References ftdi_error_return, ftdi_context::index, ftdi_context::usb_dev, and ftdi_context::usb_read_timeout.
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 |
References ftdi_error_return, ftdi_context::index, ftdi_context::usb_dev, and ftdi_context::usb_write_timeout.
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 |
References ftdi_error_return, ftdi_context::index, ftdi_context::usb_dev, and ftdi_context::usb_read_timeout.
int ftdi_poll_modem_status | ( | struct ftdi_context * | ftdi, | |
unsigned short * | status | |||
) |
Poll modem status information
This function allows the retrieve the two status bytes of the device. The device sends these bytes also as a header for each read access where they are discarded by ftdi_read_data(). The chip generates the two stripped status bytes in the absence of data every 40 ms.
Layout of the first byte:
Layout of the second byte:
ftdi | pointer to ftdi_context | |
status | Pointer to store status information in. Must be two bytes. |
0,: | all fine | |
-1,: | unable to retrieve status information |
References ftdi_error_return, ftdi_context::index, ftdi_context::usb_dev, and ftdi_context::usb_read_timeout.
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 |
References ftdi_error_return, ftdi_context::index, SIO_SET_FLOW_CTRL_REQUEST, SIO_SET_FLOW_CTRL_REQUEST_TYPE, ftdi_context::usb_dev, and ftdi_context::usb_write_timeout.
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 |
References ftdi_error_return, ftdi_context::index, SIO_SET_DTR_HIGH, SIO_SET_DTR_LOW, SIO_SET_MODEM_CTRL_REQUEST, SIO_SET_MODEM_CTRL_REQUEST_TYPE, ftdi_context::usb_dev, and ftdi_context::usb_write_timeout.
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 |
References ftdi_error_return, ftdi_context::index, SIO_SET_MODEM_CTRL_REQUEST, SIO_SET_MODEM_CTRL_REQUEST_TYPE, SIO_SET_RTS_HIGH, SIO_SET_RTS_LOW, ftdi_context::usb_dev, and ftdi_context::usb_write_timeout.
int ftdi_setdtr_rts | ( | struct ftdi_context * | ftdi, | |
int | dtr, | |||
int | rts | |||
) |
Set dtr and rts line in one pass
ftdi | pointer to ftdi_context | |
dtr | DTR state to set line to (1 or 0) | |
rts | RTS state to set line to (1 or 0) |
0,: | all fine | |
-1 | set dtr/rts failed |
References ftdi_error_return, ftdi_context::index, SIO_SET_DTR_HIGH, SIO_SET_DTR_LOW, SIO_SET_MODEM_CTRL_REQUEST, SIO_SET_MODEM_CTRL_REQUEST_TYPE, SIO_SET_RTS_HIGH, SIO_SET_RTS_LOW, ftdi_context::usb_dev, and ftdi_context::usb_write_timeout.
int ftdi_set_event_char | ( | struct ftdi_context * | ftdi, | |
unsigned char | eventch, | |||
unsigned char | enable | |||
) |
Set the special event character
ftdi | pointer to ftdi_context | |
eventch | Event character | |
enable | 0 to disable the event character, non-zero otherwise |
0,: | all fine | |
-1,: | unable to set event character |
References ftdi_error_return, ftdi_context::index, ftdi_context::usb_dev, and ftdi_context::usb_write_timeout.
int ftdi_set_error_char | ( | struct ftdi_context * | ftdi, | |
unsigned char | errorch, | |||
unsigned char | enable | |||
) |
Set error character
ftdi | pointer to ftdi_context | |
errorch | Error character | |
enable | 0 to disable the error character, non-zero otherwise |
0,: | all fine | |
-1,: | unable to set error character |
References ftdi_error_return, ftdi_context::index, ftdi_context::usb_dev, and ftdi_context::usb_write_timeout.
void ftdi_eeprom_setsize | ( | struct ftdi_context * | ftdi, | |
struct ftdi_eeprom * | eeprom, | |||
int | size | |||
) |
Set the eeprom size
ftdi | pointer to ftdi_context | |
eeprom | Pointer to ftdi_eeprom | |
size |
References ftdi_context::eeprom_size, and ftdi_eeprom::size.
void ftdi_eeprom_initdefaults | ( | struct ftdi_eeprom * | eeprom | ) |
Init eeprom with default values.
eeprom | Pointer to ftdi_eeprom |
References ftdi_eeprom::BM_type_chip, ftdi_eeprom::change_usb_version, FTDI_DEFAULT_EEPROM_SIZE, ftdi_eeprom::in_is_isochronous, ftdi_eeprom::manufacturer, ftdi_eeprom::max_power, ftdi_eeprom::out_is_isochronous, ftdi_eeprom::product, ftdi_eeprom::product_id, ftdi_eeprom::remote_wakeup, ftdi_eeprom::self_powered, ftdi_eeprom::serial, ftdi_eeprom::size, ftdi_eeprom::suspend_pull_downs, ftdi_eeprom::usb_version, ftdi_eeprom::use_serial, and ftdi_eeprom::vendor_id.
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 |
References ftdi_eeprom::BM_type_chip, ftdi_eeprom::change_usb_version, ftdi_eeprom::in_is_isochronous, ftdi_eeprom::manufacturer, ftdi_eeprom::max_power, ftdi_eeprom::out_is_isochronous, ftdi_eeprom::product, ftdi_eeprom::product_id, ftdi_eeprom::remote_wakeup, ftdi_eeprom::self_powered, ftdi_eeprom::serial, ftdi_eeprom::size, ftdi_eeprom::suspend_pull_downs, ftdi_eeprom::usb_version, ftdi_eeprom::use_serial, and ftdi_eeprom::vendor_id.
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 |
References ftdi_context::eeprom_size, ftdi_error_return, ftdi_context::usb_dev, and ftdi_context::usb_read_timeout.
int ftdi_read_chipid | ( | struct ftdi_context * | ftdi, | |
unsigned int * | chipid | |||
) |
Read the FTDIChip-ID from R-type devices
ftdi | pointer to ftdi_context | |
chipid | Pointer to store FTDIChip-ID |
0,: | all fine | |
-1,: | read failed |
References ftdi_error_return, ftdi_context::usb_dev, and ftdi_context::usb_read_timeout.
int ftdi_read_eeprom_getsize | ( | struct ftdi_context * | ftdi, | |
unsigned char * | eeprom, | |||
int | maxsize | |||
) |
Guesses size of eeprom by reading eeprom and comparing halves - will not work with blank eeprom Call this function then do a write then call again to see if size changes, if so write again.
ftdi | pointer to ftdi_context | |
eeprom | Pointer to store eeprom into | |
maxsize | the size of the buffer to read into |
size | of eeprom |
References ftdi_error_return, ftdi_context::usb_dev, and ftdi_context::usb_read_timeout.
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 |
References ftdi_context::eeprom_size, ftdi_error_return, ftdi_context::usb_dev, and ftdi_context::usb_write_timeout.
int ftdi_erase_eeprom | ( | struct ftdi_context * | ftdi | ) |
Erase eeprom
ftdi | pointer to ftdi_context |
0,: | all fine | |
-1,: | erase failed |
References ftdi_error_return, ftdi_context::usb_dev, and ftdi_context::usb_write_timeout.
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 |
References ftdi_context::error_str.