ftdi.c(3)
π ftdi.c π
okay bestie, this is the libftdi1 manual page for ftdi.c, and we are gonna get through every single detail together. no skipping, no "you get the idea" behavior. periodt. π
πΈ NAME πΈ
ftdi.c β the libftdi1 page for the C file that holds all this USB-to-FTDI goodness. π¦
β¨ SYNOPSIS β¨
first up, the includes, exactly as the manual gives them:
#include <libusb.h>
#include <string.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include 'ftdi_i.h'
#include 'ftdi.h'
#include 'ftdi_version_i.h'
π Macros π
#define _FTDI_DISABLE_DEPRECATED#define ftdi_error_return(code, str)#define ftdi_error_return_free_device_list(code, str, devs)#define H_CLK 120000000#define C_CLK 48000000#define MAGIC 0x55aa
π¦ Functions π¦
here is the whole function guest list, bestie β nobody gets left out:
int ftdi_init (struct ftdi_context *ftdi)struct ftdi_context * ftdi_new (void)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, libusb_device_handle *usb)struct ftdi_version_info ftdi_get_library_version (void)βGet libftdi library version.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 libusb_device *dev, char *manufacturer, int mnf_len, char *description, int desc_len, char *serial, int serial_len)int ftdi_usb_get_strings2 (struct ftdi_context *ftdi, struct libusb_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, libusb_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_open_desc_index (struct ftdi_context *ftdi, int vendor, int product, const char *description, const char *serial, unsigned int index)int ftdi_usb_open_bus_addr (struct ftdi_context *ftdi, uint8_t bus, uint8_t addr)int ftdi_usb_open_string (struct ftdi_context *ftdi, const char *description)int ftdi_usb_reset (struct ftdi_context *ftdi)int ftdi_tciflush (struct ftdi_context *ftdi)int ftdi_usb_purge_rx_buffer (struct ftdi_context *ftdi)int ftdi_tcoflush (struct ftdi_context *ftdi)int ftdi_usb_purge_tx_buffer (struct ftdi_context *ftdi)int ftdi_tcioflush (struct ftdi_context *ftdi)int ftdi_usb_purge_buffers (struct ftdi_context *ftdi)int ftdi_usb_close (struct ftdi_context *ftdi)int convert_baudrate_UT_export (int baudrate, struct ftdi_context *ftdi, unsigned short *value, unsigned short *index)β wrapper function to exportftdi_convert_baudrate()to the unit test. Do not use, it's only for the unit test framework.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, const unsigned char *buf, int size)struct ftdi_transfer_control * ftdi_write_data_submit (struct ftdi_context *ftdi, unsigned char *buf, int size)struct ftdi_transfer_control * ftdi_read_data_submit (struct ftdi_context *ftdi, unsigned char *buf, int size)int ftdi_transfer_data_done (struct ftdi_transfer_control *tc)void ftdi_transfer_data_cancel (struct ftdi_transfer_control *tc, struct timeval *to)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_set_bitmode (struct ftdi_context *ftdi, unsigned char bitmask, unsigned char mode)int ftdi_set_module_detach_mode (struct ftdi_context *ftdi, enum ftdi_module_detach_mode mode)int ftdi_disable_bitbang (struct ftdi_context *ftdi)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_setflowctrl_xonxoff (struct ftdi_context *ftdi, unsigned char xon, unsigned char xoff)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)int ftdi_eeprom_initdefaults (struct ftdi_context *ftdi, const char *manufacturer, const char *product, const char *serial)int ftdi_eeprom_set_strings (struct ftdi_context *ftdi, const char *manufacturer, const char *product, const char *serial)int ftdi_eeprom_get_strings (struct ftdi_context *ftdi, char *manufacturer, int mnf_len, char *product, int prod_len, char *serial, int serial_len)void set_ft232h_cbus (struct ftdi_eeprom *eeprom, unsigned char *output)int ftdi_eeprom_build (struct ftdi_context *ftdi)int ftdi_eeprom_decode (struct ftdi_context *ftdi, int verbose)int ftdi_get_eeprom_value (struct ftdi_context *ftdi, enum ftdi_eeprom_value value_name, int *value)int ftdi_set_eeprom_value (struct ftdi_context *ftdi, enum ftdi_eeprom_value value_name, int value)int ftdi_get_eeprom_buf (struct ftdi_context *ftdi, unsigned char *buf, int size)int ftdi_set_eeprom_buf (struct ftdi_context *ftdi, const unsigned char *buf, int size)int ftdi_set_eeprom_user_data (struct ftdi_context *ftdi, const char *buf, int size)int ftdi_read_eeprom_location (struct ftdi_context *ftdi, int eeprom_addr, unsigned short *eeprom_val)int ftdi_read_eeprom (struct ftdi_context *ftdi)int ftdi_read_chipid (struct ftdi_context *ftdi, unsigned int *chipid)int ftdi_write_eeprom_location (struct ftdi_context *ftdi, int eeprom_addr, unsigned short eeprom_val)int ftdi_write_eeprom (struct ftdi_context *ftdi)int ftdi_erase_eeprom (struct ftdi_context *ftdi)const char * ftdi_get_error_string (struct ftdi_context *ftdi)
π§ Macro Definition Documentation π§
π
_FTDI_DISABLE_DEPRECATED π
</h3>
Definition at line 40 of file ftdi.c.
π ftdi_error_return(code, str) π</h3>
Value:
do { \
if ( ftdi ) \
ftdi->error_str = str; \
else \
fprintf(stderr, str); \
return code; \
} while(0);
Definition at line 44 of file ftdi.c.
it's referenced by: ftdi_disable_bitbang(), ftdi_eeprom_build(), ftdi_eeprom_decode(), ftdi_eeprom_get_strings(), ftdi_eeprom_initdefaults(), ftdi_eeprom_set_strings(), ftdi_erase_eeprom(), ftdi_get_eeprom_buf(), ftdi_get_eeprom_value(), ftdi_get_latency_timer(), ftdi_init(), ftdi_poll_modem_status(), ftdi_read_chipid(), ftdi_read_data(), ftdi_read_data_get_chunksize(), ftdi_read_data_set_chunksize(), ftdi_read_eeprom(), ftdi_read_eeprom_location(), ftdi_read_pins(), ftdi_set_baudrate(), ftdi_set_bitmode(), ftdi_set_eeprom_buf(), ftdi_set_eeprom_user_data(), ftdi_set_eeprom_value(), ftdi_set_error_char(), ftdi_set_event_char(), ftdi_set_interface(), ftdi_set_latency_timer(), ftdi_set_line_property2(), ftdi_set_module_detach_mode(), ftdi_setdtr(), ftdi_setdtr_rts(), ftdi_setflowctrl(), ftdi_setflowctrl_xonxoff(), ftdi_setrts(), ftdi_tciflush(), ftdi_tcioflush(), ftdi_tcoflush(), ftdi_usb_close(), ftdi_usb_find_all(), ftdi_usb_get_strings(), ftdi_usb_get_strings2(), ftdi_usb_open_bus_addr(), ftdi_usb_open_desc_index(), ftdi_usb_open_dev(), ftdi_usb_open_string(), ftdi_usb_purge_buffers(), ftdi_usb_purge_rx_buffer(), ftdi_usb_purge_tx_buffer(), ftdi_usb_reset(), ftdi_write_data(), ftdi_write_data_get_chunksize(), ftdi_write_data_set_chunksize(), ftdi_write_eeprom(), and ftdi_write_eeprom_location().
π¦ ftdi_error_return_free_device_list(code, str, devs) π¦</h3>
Value:
do { \
libusb_free_device_list(devs,1); \
ftdi->error_str = str; \
return code; \
} while(0);
Definition at line 52 of file ftdi.c.
it's referenced by: ftdi_usb_find_all(), ftdi_usb_open_bus_addr(), ftdi_usb_open_desc_index(), and ftdi_usb_open_string().
β¨ #define H_CLK, #define C_CLK, #define MAGIC β¨</h3>
#define H_CLK 120000000
#define C_CLK 48000000
#define MAGIC 0x55aa
Erase eeprom
This is not supported on FT232R/FT245R according to the MProg manual from FTDI.
heads up, bestie: this is not supported on FT232R/FT245R according to the MProg manual from FTDI.
Parameters:
ftdipointer toftdi_context
Return values:
0all fine-1erase failed-2USB device unavailable-3Writing magic failed-4Read EEPROM failed-5Unexpected EEPROM value
Definition at line 4722 of file ftdi.c.
Referenced by ftdi_erase_eeprom().
π Function Documentation π
π± int ftdi_init (struct ftdi_context * ftdi) π±</h2>
Initializes a ftdi_context.
Parameters:
ftdipointer toftdi_context
Return values:
0all fine-1couldn't allocate read buffer-2couldn't allocate struct buffer-3libusb_init()failed
Remarks: This should be called before all functions
Definition at line 91 of file ftdi.c.
References: AUTO_DETACH_SIO_MODULE, ftdi_context::baudrate, ftdi_context::bitbang_enabled, ftdi_context::bitbang_mode, ftdi_context::eeprom, ftdi_context::error_str, ftdi_error_return, ftdi_read_data_set_chunksize(), ftdi_set_interface(), INTERFACE_ANY, ftdi_context::max_packet_size, ftdi_context::module_detach_mode, ftdi_context::readbuffer, ftdi_context::readbuffer_offset, ftdi_context::readbuffer_remaining, ftdi_context::type, TYPE_BM, ftdi_context::usb_ctx, 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 (void ) π</h2>
Allocate and initialize a new ftdi_context
Returns β a pointer to a new ftdi_context, or NULL on failure π
Definition at line 132 of file ftdi.c.
References: ftdi_init().
Referenced by: Ftdi::Context::Private::Private().
int ftdi_set_interface (struct ftdi_context * ftdi, enum ftdi_interface interface)
Okay so this one opens selected channels on a chip β otherwise it just uses the first channel β¨
Parameters
ftdiβ pointer toftdi_contextinterfaceβ interface to use forFT2232C/2232H/4232Hchips
Return values
0β all fine-1β unknown interface-2β USB device unavailable-3β device already open, interface canβt be set in that state
Definition at line 161 of file ftdi.c.
References: ftdi_error_return, ftdi_context::in_ep, ftdi_context::index, ftdi_context::interface, INTERFACE_A, INTERFACE_ANY, INTERFACE_B, INTERFACE_C, INTERFACE_D, ftdi_context::out_ep, and ftdi_context::usb_dev.
Referenced by: ftdi_init(), and Ftdi::Context::set_interface().
void ftdi_deinit (struct ftdi_context * ftdi)
Deinitializes a ftdi_context β like logging out of the group chat, but for your context π«Ά
Parameters
ftdiβ pointer toftdi_context
Definition at line 214 of file ftdi.c.
References: ftdi_context::eeprom, ftdi_eeprom::manufacturer, ftdi_eeprom::product, ftdi_context::readbuffer, ftdi_eeprom::serial, and ftdi_context::usb_ctx.
Referenced by: ftdi_free().
void ftdi_free (struct ftdi_context * ftdi)
Deinitialize and free an ftdi_context β full cleanup era π
Parameters
ftdiβ pointer toftdi_context
Definition at line 260 of file ftdi.c.
References: ftdi_deinit().
Referenced by: Ftdi::Context::set_context(), and Ftdi::Context::Private::~Private().
void ftdi_set_usbdev (struct ftdi_context * ftdi, libusb_device_handle * usb)
Use an already open libusb device β no need to open a new one, bestie π₯
Parameters
ftdiβ pointer toftdi_contextusbβlibusblibusb_device_handleto use
Definition at line 272 of file ftdi.c.
References: ftdi_context::usb_dev.
Referenced by: Ftdi::Context::set_usb_device().
struct ftdi_version_info ftdi_get_library_version (void )
Get the libftdi library version β the ultimate vibe check for your library β¨
Returns
ftdi_version_infoβ library version information
Definition at line 285 of file ftdi.c.
References: ftdi_get_library_version(), ftdi_version_info::major, ftdi_version_info::micro, ftdi_version_info::minor, ftdi_version_info::snapshot_str, and ftdi_version_info::version_str.
Referenced by: ftdi_get_library_version().
int ftdi_usb_find_all (struct ftdi_context * ftdi, struct ftdi_device_list ** devlist, int vendor, int product)
Finds all ftdi devices with the given VID:PID on the USB bus ππ Creates a new ftdi_device_list which needs to be deallocated by ftdi_list_free() after use. With VID:PID 0:0, search for the default devices (0x403:0x6001, 0x403:0x6010, 0x403:0x6011, 0x403:0x6014, 0x403:0x6015).
Parameters
ftdiβ pointer toftdi_contextdevlistβ pointer where to store list of found devicesvendorβ vendor ID to search forproductβ product ID to search for
Return values
>0β number of devices found-3β out of memory-5βlibusb_get_device_list()failed-6βlibusb_get_device_descriptor()failed
Definition at line 314 of file ftdi.c.
References: ftdi_device_list::dev, ftdi_error_return, ftdi_error_return_free_device_list, ftdi_device_list::next, and ftdi_context::usb_ctx.
Referenced by: Ftdi::List::find_all().
void ftdi_list_free (struct ftdi_device_list ** devlist)
Frees a USB device list β clean up your mess, icon behavior π
Parameters
devlistβ USB device list created byftdi_usb_find_all()
Definition at line 362 of file ftdi.c.
References: ftdi_device_list::dev, and ftdi_device_list::next.
Referenced by: Ftdi::List::clear(), ftdi_list_free2(), and Ftdi::List::Private::~Private().
void ftdi_list_free2 (struct ftdi_device_list * devlist)
Frees a USB device list β yes, again, but this one takes the pointer directly πΈ
Parameters
devlistβ USB device list created byftdi_usb_find_all()
Definition at line 382 of file ftdi.c.
References: ftdi_list_free().
int ftdi_usb_get_strings (struct ftdi_context * ftdi, struct libusb_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.
Note: use this function only in combination withftdi_usb_find_all()as it closes the internal"usb_dev"after use.
Parameters
ftdiβ pointer toftdi_contextdevβlibusbusb_devto usemanufacturerβ store manufacturer string here if notNULLmnf_lenβ buffer size of manufacturer stringdescriptionβ store product description string here if notNULLdesc_lenβ buffer size of product description stringserialβ store serial string here if notNULLserial_lenβ buffer size of serial string
Return values
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-11βlibusb_get_device_descriptor()failed
Definition at line 413 of file ftdi.c.
References: ftdi_device_list::dev, ftdi_error_return, ftdi_usb_get_strings2(), and ftdi_context::usb_dev.
Referenced by: Ftdi::Context::get_strings().
int ftdi_usb_get_strings2 (struct ftdi_context * ftdi, struct libusb_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 glow-up version β¨
The parameters manufacturer, description and serial may be NULL or pointer to buffers to store the fetched strings.
Note: the old function ftdi_usb_get_strings() always closes the device. This version only closes the device if it was opened by it.
Parameters
ftdiβ pointer toftdi_contextdevβlibusbusb_devto usemanufacturerβ store manufacturer string here if notNULLmnf_lenβ buffer size of manufacturer stringdescriptionβ store product description string here if notNULLdesc_lenβ buffer size of product description stringserialβ store serial string here if notNULLserial_lenβ buffer size of serial string
Return values
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-11βlibusb_get_device_descriptor()failed
Definition at line 470 of file ftdi.c.
References: ftdi_error_return, and ftdi_context::usb_dev.
Referenced by: ftdi_usb_get_strings().
int ftdi_usb_open_dev (struct ftdi_context * ftdi, libusb_device * dev)
Opens a ftdi device given by a usb_device β main character opening energy π
Parameters
ftdiβ pointer toftdi_contextdevβlibusbusb_devto use
Return values
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-8β ftdi context invalid-9βlibusb_get_device_descriptor()failed-10βlibusb_get_config_descriptor()failed-11βlibusb_detach_kernel_driver()failed-12βlibusb_get_configuration()failed
Definition at line 601 of file ftdi.c.
References: AUTO_DETACH_REATACH_SIO_MODULE, AUTO_DETACH_SIO_MODULE, ftdi_error_return, ftdi_set_baudrate(), ftdi_usb_reset(), ftdi_context::interface, ftdi_context::max_packet_size, ftdi_context::module_detach_mode, ftdi_context::type, TYPE_2232C, TYPE_2232H, TYPE_230X, TYPE_232H, TYPE_4232H, TYPE_AM, TYPE_BM, TYPE_R, and ftdi_context::usb_dev.
Referenced by: ftdi_usb_open_bus_addr(), ftdi_usb_open_desc_index(), ftdi_usb_open_string(), and Ftdi::Context::get_strings_and_reopen().
int ftdi_usb_open (struct ftdi_context * ftdi, int vendor, int product)
Opens the first device with a given vendor and product IDs π
Parameters
ftdiβ pointer toftdi_contextvendorβ vendor IDproductβ product ID
Return values
- same as
ftdi_usb_open_desc()
Definition at line 719 of file ftdi.c.
References: ftdi_usb_open_desc().
Referenced by: Ftdi::Context::open().
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 π
Parameters
ftdiβ pointer toftdi_contextvendorβ vendor IDproductβ product IDdescriptionβ description to search for. UseNULLif not needed.serialβ serial to search for. UseNULLif not needed.
Return values
0β all fine-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-12βlibusb_get_device_list()failed-13βlibusb_get_device_descriptor()failed
Definition at line 745 of file ftdi.c.
References: ftdi_usb_open_desc_index().
Referenced by: ftdi_usb_open().
int ftdi_usb_open_desc_index (struct ftdi_context * ftdi, int vendor, int product, const char * description, const char * serial, unsigned int index)
Opens the index-th device with a given vendor ID, product ID, description and serial β for when thereβs more than one and you gotta pick your fave π
Parameters
ftdiβ pointer toftdi_contextvendorβ vendor IDproductβ product IDdescriptionβ description to search for. UseNULLif not needed.serialβ serial to search for. UseNULLif not needed.indexβ number of matching device to open if there are more than one, starts with0.
Return values
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-11β ftdi context invalid-12βlibusb_get_device_list()failed
Definition at line 776 of file ftdi.c.
References: ftdi_error_return, ftdi_error_return_free_device_list, ftdi_usb_open_dev(), ftdi_context::usb_ctx, and ftdi_context::usb_dev.
Referenced by: ftdi_usb_open_desc(), ftdi_usb_open_string(), and Ftdi::Context::open().
int ftdi_usb_open_bus_addr (struct ftdi_context * ftdi, uint8_t bus, uint8_t addr)
Opens the device at a given USB bus and device address πβ¨
Parameters
ftdiβ pointer toftdi_contextbusβ bus numberaddrβ device address
still the return values for the function above, bestie π
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-11β ftdi context invalid-12βlibusb_get_device_list()failed
π Definition at line 869 of file ftdi.c.
π References: ftdi_error_return, ftdi_error_return_free_device_list, ftdi_usb_open_dev(), and ftdi_context::usb_ctx.
int ftdi_usb_open_string (struct ftdi_context * ftdi, const char * description)
Okay so this one opens the ftdi-device that a description-string tells you about. It's literally built for parsing a device-description that somebody handed you as a commandline argument. So thoughtful of it π
Parameters
ftdiβ pointer toftdi_contextdescriptionβ NULL-terminated description-string, using this format:d:<devicenode>β path of bus and device-node (e.g."003/001") within usb device tree (usually at/proc/bus/usb/)i:<vendor>:<product>β first device with given vendor and product id, ids can be decimal, octal (preceded by"0") or hex (preceded by"0x")i:<vendor>:<product>:<index>β as above with index being the number of the device (starting with0) if there are more than ones:<vendor>:<product>:<serial>β first device with given vendor id, product id and serial string
Note β The description format may be extended in later versions. (so don't get too attached to the exact grammar, bestie π«Ά)
Return values
0β all fine β¨-2βlibusb_get_device_list()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-11β illegal description format π-12β ftdi context invalid
π Definition at line 922 of file ftdi.c.
π References: ftdi_error_return, ftdi_error_return_free_device_list, ftdi_usb_open_desc_index(), ftdi_usb_open_dev(), and ftdi_context::usb_ctx.
π Referenced by: Ftdi::Context::open().
int ftdi_usb_reset (struct ftdi_context * ftdi)
Resets the ftdi device. That's it, that's the whole vibe. Fresh start, main character energy π₯
Parameters
ftdiβ pointer toftdi_context
Return values
0β all fine β¨-1β FTDI reset failed π-2β USB device unavailable π
π Definition at line 1015 of file ftdi.c.
π References: FTDI_DEVICE_OUT_REQTYPE, ftdi_error_return, ftdi_context::index, ftdi_context::readbuffer_offset, ftdi_context::readbuffer_remaining, SIO_RESET_REQUEST, SIO_RESET_SIO, ftdi_context::usb_dev, and ftdi_context::usb_write_timeout.
π Referenced by: ftdi_usb_open_dev(), ftdi_write_eeprom(), and Ftdi::Context::reset().
int ftdi_tciflush (struct ftdi_context * ftdi)
Clears the read buffer on the chip and the internal read buffer. This is the correct behavior for an RX flush β like, actually correct, not fake-correct π
Parameters
ftdiβ pointer toftdi_context
Return values
0β all fine β¨-1β read buffer purge failed π-2β USB device unavailable π
π Definition at line 1042 of file ftdi.c.
π References: FTDI_DEVICE_OUT_REQTYPE, ftdi_error_return, ftdi_context::index, ftdi_context::readbuffer_offset, ftdi_context::readbuffer_remaining, SIO_RESET_REQUEST, SIO_TCIFLUSH, ftdi_context::usb_dev, and ftdi_context::usb_write_timeout.
π Referenced by: ftdi_tcioflush(), and Ftdi::Context::tcflush().
int ftdi_usb_purge_rx_buffer (struct ftdi_context * ftdi)
Clears the write buffer on the chip and the internal read buffer. Yeah. That is incorrect behavior for an RX flush β it's giving chaotic wrongness π
Parameters
ftdiβ pointer toftdi_context
Return values
0β all fine β¨-1β write buffer purge failed π-2β USB device unavailable π
Deprecated β Use ftdi_tciflush(struct ftdi_context *ftdi)
π Definition at line 1072 of file ftdi.c.
π References: FTDI_DEVICE_OUT_REQTYPE, ftdi_error_return, ftdi_context::index, ftdi_context::readbuffer_offset, ftdi_context::readbuffer_remaining, SIO_RESET_PURGE_RX, SIO_RESET_REQUEST, ftdi_context::usb_dev, and ftdi_context::usb_write_timeout.
π Referenced by: Ftdi::Context::flush(), and ftdi_usb_purge_buffers().
int ftdi_tcoflush (struct ftdi_context * ftdi)
Clears the write buffer on the chip. Correct behavior for a TX flush β we love a glow-up β¨
Parameters
ftdiβ pointer toftdi_context
Return values
0β all fine β¨-1β write buffer purge failed π-2β USB device unavailable π
π Definition at line 1099 of file ftdi.c.
π References: FTDI_DEVICE_OUT_REQTYPE, ftdi_error_return, ftdi_context::index, SIO_RESET_REQUEST, SIO_TCOFLUSH, ftdi_context::usb_dev, and ftdi_context::usb_write_timeout.
π Referenced by: ftdi_tcioflush(), and Ftdi::Context::tcflush().
int ftdi_usb_purge_tx_buffer (struct ftdi_context * ftdi)
Clears the read buffer on the chip. Which is, again, incorrect behavior for a TX flush. Not the serve you think it is, bestie π
Parameters
ftdiβ pointer toftdi_context
Return values
0β all fine β¨-1β read buffer purge failed π-2β USB device unavailable π
Deprecated β Use ftdi_tcoflush(struct ftdi_context *ftdi)
π Definition at line 1125 of file ftdi.c.
π References: FTDI_DEVICE_OUT_REQTYPE, ftdi_error_return, ftdi_context::index, SIO_RESET_PURGE_TX, SIO_RESET_REQUEST, ftdi_context::usb_dev, and ftdi_context::usb_write_timeout.
π Referenced by: Ftdi::Context::flush(), and ftdi_usb_purge_buffers().
int ftdi_tcioflush (struct ftdi_context * ftdi)
Clears the RX and TX FIFOs on the chip plus the internal read buffer. This is correct behavior for both RX and TX flush β the one that actually understood the assignment πβ¨
Parameters
ftdiβ pointer toftdi_context
Return values
0β all fine β¨-1β read buffer purge failed π-2β write buffer purge failed π-3β USB device unavailable π
π Definition at line 1149 of file ftdi.c.
π References: ftdi_error_return, ftdi_tciflush(), ftdi_tcoflush(), and ftdi_context::usb_dev.
π Referenced by: ftdi_readstream(), and Ftdi::Context::tcflush().
int ftdi_usb_purge_buffers (struct ftdi_context * ftdi)
Clears the buffers on the chip and the internal read buffer. While coded incorrectly, the result is satisfactory β ngl that's the most relatable sentence in this whole manpage π "coded incorrectly, works anyway, we move"
Parameters
ftdiβ pointer toftdi_context
Return values
0β all fine β¨-1β read buffer purge failed π-2β write buffer purge failed π-3β USB device unavailable π
Deprecated β Use ftdi_tcioflush(struct ftdi_context *ftdi)
π Definition at line 1180 of file ftdi.c.
π References: ftdi_error_return, ftdi_usb_purge_rx_buffer(), ftdi_usb_purge_tx_buffer(), and ftdi_context::usb_dev.
π Referenced by: Ftdi::Context::flush().
int ftdi_usb_close (struct ftdi_context * ftdi)
Closes the ftdi device. π
But bestie, listen β call ftdi_deinit() if you're cleaning up. Closing is not cleaning, they're different chores.
Parameters
ftdiβ pointer toftdi_context
Return values
0β all fine β¨-1βusb_releasefailed π-3β ftdi context invalid π
π Definition at line 1209 of file ftdi.c.
π References: ftdi_error_return, ftdi_context::interface, and ftdi_context::usb_dev.
π Referenced by: Ftdi::Context::close(), and Ftdi::Context::Private::~Private().
int convert_baudrate_UT_export (int baudrate, struct ftdi_context * ftdi, unsigned short * value, unsigned short * index)
Wrapper function to export ftdi_convert_baudrate() to the unit test. π§ͺ Do not use β it's only for the unit test framework. Like, for real, hands off π
π Definition at line 1443 of file ftdi.c.
int ftdi_set_baudrate (struct ftdi_context * ftdi, int baudrate)
Sets the chip baud rate. Speedy era activated π₯
Parameters
ftdiβ pointer toftdi_contextbaudrateβ baud rate to set
Return values
0β all fine β¨-1β invalid baudrate π-2β setting baudrate failed π-3β USB device unavailable π
π Definition at line 1460 of file ftdi.c.
π References: ftdi_context::baudrate, ftdi_context::bitbang_enabled, FTDI_DEVICE_OUT_REQTYPE, ftdi_error_return, SIO_SET_BAUDRATE_REQUEST, ftdi_context::usb_dev, and ftdi_context::usb_write_timeout.
π Referenced by: ftdi_usb_open_dev(), and Ftdi::Context::set_baud_rate().
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. Heads up though β the break type can only be set via ftdi_set_line_property2() and defaults to "off". So if you came here for break types, wrong door, babes πͺ
Parameters
ftdiβ pointer toftdi_contextbitsβ Number of bitssbitβ Number of stop bitsparityβ Parity mode
Return values
0β all fine β¨-1β Setting line property failed π
π Definition at line 1506 of file ftdi.c.
π References: BREAK_OFF, and ftdi_set_line_property2().
π Referenced by: Ftdi::Context::set_line_property().
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 β but this time with the break type included, so this is the deluxe version β¨π
Parameters
ftdiβ pointer toftdi_contextbitsβ Number of bitssbitβ Number of stop bitsparityβ Parity modebreak_typeβ Break type
Return values
0β all fine β¨-1β Setting line property failed π-2β USB device unavailable π
π Definition at line 1525 of file ftdi.c.
π References: BREAK_OFF, BREAK_ON, EVEN, FTDI_DEVICE_OUT_REQTYPE, ftdi_error_return, ftdi_context::index, MARK, NONE, ODD, SIO_SET_DATA_REQUEST, 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(), and Ftdi::Context::set_line_property().
int ftdi_write_data (struct ftdi_context * ftdi, const unsigned char * buf, int size)
Writes data in chunks (see ftdi_write_data_set_chunksize()) to the chip. Chunk by chunk, little by little, we love a consistent queen π
Parameters
ftdiβ pointer toftdi_contextbufβ Buffer with the datasizeβ Size of the buffer
Return values
-666β USB device unavailable ππ (yes, really, that's the code)<0β error code fromusb_bulk_write()>0β number of bytes written
π Definition at line 1595 of file ftdi.c.
π References: ftdi_error_return, ftdi_context::in_ep, ftdi_context::usb_dev, ftdi_context::usb_write_timeout, and ftdi_context::writebuffer_chunksize.
π Referenced by: Ftdi::Context::write().
struct ftdi_transfer_control * ftdi_write_data_submit (struct ftdi_context * ftdi, unsigned char * buf, int size)
Writes data to the chip. Does not wait for completion of the transfer, and it does not make sure the transfer was even successful. Very much "sent it, hope it lands" energy ππ
Use libusb 1.0 asynchronous API.
Parameters for ftdi_write_data_submit β picking up right where we left off, bestie:
ftdiβ pointer toftdi_contextbufβ buffer with the datasizeβ size of the buffer
Return values
NULLβ some error happens when submit transfer!NULLβ pointer to aftdi_transfer_control
Definition at line 1755 of file ftdi.c.
References: ftdi_transfer_control::buf, ftdi_transfer_control::completed, ftdi_transfer_control::ftdi, ftdi_context::in_ep, ftdi_transfer_control::offset, ftdi_transfer_control::size, ftdi_transfer_control::transfer, ftdi_context::usb_dev, ftdi_context::usb_write_timeout, and ftdi_context::writebuffer_chunksize.
π ftdi_read_data_submit π
struct ftdi_transfer_control * ftdi_read_data_submit (struct ftdi_context *
ftdi, unsigned char * buf, int size)
Reads data from the chip. Does not wait for completion of the transfer, and it does not make sure the transfer was successful. Itβs giving βfire and forget,β no cap.
Use libusb 1.0 asynchronous API.
Parameters
ftdiβ pointer toftdi_contextbufβ buffer with the datasizeβ size of the buffer
Return values
NULLβ some error happens when submit transfer!NULLβ pointer to aftdi_transfer_control
Definition at line 1817 of file ftdi.c.
References: ftdi_transfer_control::buf, ftdi_transfer_control::completed, ftdi_transfer_control::ftdi, ftdi_transfer_control::offset, ftdi_context::out_ep, ftdi_context::readbuffer, ftdi_context::readbuffer_chunksize, ftdi_context::readbuffer_offset, ftdi_context::readbuffer_remaining, ftdi_transfer_control::size, ftdi_transfer_control::transfer, ftdi_context::usb_dev, and ftdi_context::usb_read_timeout.
π¦ ftdi_transfer_data_done π¦
int ftdi_transfer_data_done (struct ftdi_transfer_control * tc)
Wait for completion of the transfer. Yes bestie, this is the βokay now actually chill until itβs doneβ function.
Use libusb 1.0 asynchronous API.
Parameters
tcβ pointer toftdi_transfer_control
Return values
< 0β some error happens>= 0β data size transferred
Heads up:tc->transfercould beNULLif(size <= ftdi->readbuffer_remaining)atftdi_read_data_submit(). Therefore, we need to check it here. Not me forgetting β the code literally has to guard it. π
Definition at line 1896 of file ftdi.c.
References: ftdi_transfer_control::completed, ftdi_transfer_control::ftdi, ftdi_transfer_control::offset, ftdi_transfer_control::transfer, and ftdi_context::usb_ctx.
π ftdi_transfer_data_cancel π
void ftdi_transfer_data_cancel (struct ftdi_transfer_control * tc, struct
timeval * to)
Cancel transfer and wait for completion.
Use libusb 1.0 asynchronous API.
Parameters
tcβ pointer toftdi_transfer_controltoβ pointer to timeout value orNULLfor infinite
Definition at line 1943 of file ftdi.c.
References: ftdi_transfer_control::completed, ftdi_transfer_control::ftdi, ftdi_transfer_control::transfer, and ftdi_context::usb_ctx.
β¨ ftdi_write_data_set_chunksize β¨
int ftdi_write_data_set_chunksize (struct ftdi_context * ftdi, unsigned int
chunksize)
Configure write buffer chunk size. Default is 4096.
Parameters
ftdiβ pointer toftdi_contextchunksizeβ chunk size
Return values
0β all fine-1β ftdi context invalid
Definition at line 1977 of file ftdi.c.
References: ftdi_error_return, and ftdi_context::writebuffer_chunksize.
Referenced by Ftdi::Context::set_write_chunk_size().
πΈ ftdi_write_data_get_chunksize πΈ
int ftdi_write_data_get_chunksize (struct ftdi_context * ftdi, unsigned int
* chunksize)
Get write buffer chunk size.
Parameters
ftdiβ pointer toftdi_contextchunksizeβ pointer to store chunk size in
Return values
0β all fine-1β ftdi context invalid
Definition at line 1995 of file ftdi.c.
References: ftdi_error_return, and ftdi_context::writebuffer_chunksize.
Referenced by Ftdi::Context::write_chunk_size().
π ftdi_read_data π
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 transferred during every read. Iconic behavior, honestly.
Parameters
ftdiβ pointer toftdi_contextbufβ buffer to store data insizeβ size of the buffer
Return values
-666β USB device unavailable<0β error code fromlibusb_bulk_transfer()0β no data was available>0β number of bytes read
Definition at line 2019 of file ftdi.c.
References: ftdi_error_return, ftdi_context::max_packet_size, 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.
Referenced by Ftdi::Context::read().
π§ ftdi_read_data_set_chunksize π§
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. Slay.
Parameters
ftdiβ pointer toftdi_contextchunksizeβ chunk size
Return values
0β all fine-1β ftdi context invalid
Definition at line 2145 of file ftdi.c.
References: ftdi_error_return, ftdi_context::readbuffer, ftdi_context::readbuffer_chunksize, ftdi_context::readbuffer_offset, and ftdi_context::readbuffer_remaining.
Referenced by ftdi_init(), and Ftdi::Context::set_read_chunk_size().
π ftdi_read_data_get_chunksize π
int ftdi_read_data_get_chunksize (struct ftdi_context * ftdi, unsigned int *
chunksize)
Get read buffer chunk size.
Parameters
ftdiβ pointer toftdi_contextchunksizeβ pointer to store chunk size in
Return values
0β all fine-1β FTDI context invalid
Definition at line 2182 of file ftdi.c.
References: ftdi_error_return, and ftdi_context::readbuffer_chunksize.
Referenced by Ftdi::Context::read_chunk_size().
π
ftdi_set_bitmode π
int ftdi_set_bitmode (struct ftdi_context * ftdi, unsigned char bitmask,
unsigned char mode)
Enable/disable bitbang modes. This is the main-character function for bitbang girlies.
Parameters
ftdiβ pointer toftdi_contextbitmaskβ bitmask to configure lines. HIGH/ON value configures a line as output.modeβ bitbang mode: use the values defined inftdi_mpsse_mode
Return values
0β all fine-1β can't enable bitbang mode-2β USB device unavailable
Definition at line 2203 of file ftdi.c.
References: ftdi_context::bitbang_enabled, ftdi_context::bitbang_mode, BITMODE_RESET, FTDI_DEVICE_OUT_REQTYPE, ftdi_error_return, ftdi_context::index, SIO_SET_BITMODE_REQUEST, ftdi_context::usb_dev, and ftdi_context::usb_write_timeout.
Referenced by ftdi_readstream(), Ftdi::Context::set_bitmode(), and Ftdi::Context::set_bitmode().
π ftdi_set_module_detach_mode π
int ftdi_set_module_detach_mode (struct ftdi_context * ftdi, enum
ftdi_module_detach_mode mode)
Set module detach mode.
Parameters
ftdiβ pointer toftdi_contextmodeβ detach mode to use.
Return values
0β all fine-1β can't enable bitbang mode
Definition at line 2229 of file ftdi.c.
References: ftdi_error_return, and ftdi_context::module_detach_mode.
π₯ ftdi_disable_bitbang π₯
int ftdi_disable_bitbang (struct ftdi_context * ftdi)
Disable bitbang mode.
Parameters
ftdiβ pointer toftdi_context
Return values
0β all fine-1β can't disable bitbang mode-2β USB device unavailable
Definition at line 2247 of file ftdi.c.
References: ftdi_context::bitbang_enabled, FTDI_DEVICE_OUT_REQTYPE, ftdi_error_return, ftdi_context::index, SIO_SET_BITMODE_REQUEST, ftdi_context::usb_dev, and ftdi_context::usb_write_timeout.
Referenced by Ftdi::Context::bitbang_disable().
π ftdi_read_pins π
int ftdi_read_pins (struct ftdi_context * ftdi, unsigned char * pins)
Directly read pin state, circumventing the read buffer. Useful for bitbang mode.
Parameters
ftdiβ pointer toftdi_contextpinsβ pointer to store pins into
Return values
0β all fine-1β read pins failed-2β USB device unavailable
Definition at line 2270 of file ftdi.c.
References: FTDI_DEVICE_IN_REQTYPE, ftdi_error_return, ftdi_context::index, SIO_READ_PINS_REQUEST, ftdi_context::usb_dev, and ftdi_context::usb_read_timeout.
Referenced by Ftdi::Context::read_pins().
π ftdi_set_latency_timer π
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.
Parameters
ftdiβ pointer toftdi_contextlatencyβ value between1and255
Return values
0β all fine-1β latency out of range-2β unable to set latency timer-3β USB device unavailable
Definition at line 2296 of file ftdi.c.
References: FTDI_DEVICE_OUT_REQTYPE, ftdi_error_return, ftdi_context::index, SIO_SET_LATENCY_TIMER_REQUEST, ftdi_context::usb_dev, and ftdi_context::usb_write_timeout.
Referenced by ftdi_write_eeprom(), and Ftdi::Context::set_latency().
β ftdi_get_latency_timer β
int ftdi_get_latency_timer (struct ftdi_context * ftdi, unsigned char *
latency)
Get latency timer.
Parameters
ftdiβ pointer toftdi_contextlatencyβ pointer to store latency value in
Return values
0β all fine-1β unable to get latency timer-2β USB device unavailable
Definition at line 2323 of file ftdi.c.
References: FTDI_DEVICE_IN_REQTYPE, ftdi_error_return, ftdi_context::index, SIO_GET_LATENCY_TIMER_REQUEST, ftdi_context::usb_dev, and ftdi_context::usb_read_timeout.
Referenced by Ftdi::Context::latency().
π«Ά ftdi_poll_modem_status π«Ά
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:
- B0..B3 - must be 0
- B4 Clear to send (CTS) 0 = inactive 1 = active
- B5 Data set ready (DTS) 0 = inactive 1 = active
- B6 Ring indicator (RI) 0 = inactive 1 = active
- B7 Receive line signal detect (RLSD) 0 = inactive 1 = active
Layout of the second byte:
- B0 Data ready (DR)
- B1 Overrun error (OE)
- B2 Parity error (PE)
- B3 Framing error (FE)
- B4 Break interrupt (BI)
- B5 Transmitter holding register (THRE)
- B6 Transmitter empty (TEMT)
- B7 Error in RCVR FIFO
Parameters
ftdiβ pointer toftdi_contextstatusβ pointer to store status information in. Must be two bytes.
Return values
0β all fine-1β unable to retrieve status information-2β USB device unavailable
Definition at line 2377 of file ftdi.c.
References: FTDI_DEVICE_IN_REQTYPE, ftdi_error_return, ftdi_context::index, SIO_POLL_MODEM_STATUS_REQUEST, ftdi_context::usb_dev, and ftdi_context::usb_read_timeout.
Referenced by ftdi_write_eeprom(), and Ftdi::Context::poll_modem_status().
π ftdi_setflowctrl π
int ftdi_setflowctrl (struct ftdi_context * ftdi, int flowctrl)
Set flowcontrol for ftdi chip
β οΈ Note: Do not use this function to enable XON/XOFF mode, use ftdi_setflowctrl_xonxoff() instead. iykyk π
Parameters
ftdiβ pointer toftdi_contextflowctrlβ flow control to use. should beSIO_DISABLE_FLOW_CTRL,SIO_RTS_CTS_HS,SIO_DTR_DSR_HS
Return values
0β all fine β¨-1β set flow control failed π-2β USB device unavailable π
Definition at line 2405 of file ftdi.c.
References FTDI_DEVICE_OUT_REQTYPE, ftdi_error_return, ftdi_context::index, SIO_SET_FLOW_CTRL_REQUEST, ftdi_context::usb_dev, and ftdi_context::usb_write_timeout.
Referenced by Ftdi::Context::set_flow_control().
π int ftdi_setflowctrl_xonxoff (struct ftdi_context * ftdi, unsigned char xon, unsigned char xoff)
okay so this one is literally THE one for XON/XOFF flowcontrol on ur ftdi chip π¦ (remember, the previous function told u not to use it for this, so this is the main character here π).
Parameters
ftdiβ pointer toftdi_contextxonβ character code used to resume transmission βΆοΈxoffβ character code used to pause transmission βΈοΈ
Return values
0β all fine β¨-1β set flow control failed π-2β USB device unavailable π
Definition at line 2429 of file ftdi.c.
References FTDI_DEVICE_OUT_REQTYPE, ftdi_error_return, ftdi_context::index, SIO_SET_FLOW_CTRL_REQUEST, SIO_XON_XOFF_HS, ftdi_context::usb_dev, and ftdi_context::usb_write_timeout.
π int ftdi_setdtr (struct ftdi_context * ftdi, int state)
Set dtr line. that's it, that's the vibe π«Ά
Parameters
ftdiβ pointer toftdi_contextstateβ state to set line to (1 or 0)
Return values
0β all fine β¨-1β set dtr failed π-2β USB device unavailable π
Definition at line 2453 of file ftdi.c.
References FTDI_DEVICE_OUT_REQTYPE, ftdi_error_return, ftdi_context::index, SIO_SET_DTR_HIGH, SIO_SET_DTR_LOW, SIO_SET_MODEM_CTRL_REQUEST, ftdi_context::usb_dev, and ftdi_context::usb_write_timeout.
Referenced by Ftdi::Context::set_dtr().
πΈ int ftdi_setrts (struct ftdi_context * ftdi, int state)
Set rts line. yes bestie it's the sibling of the last one π
Parameters
ftdiβ pointer toftdi_contextstateβ state to set line to (1 or 0)
Return values
0β all fine β¨-1β set rts failed π-2β USB device unavailable π
Definition at line 2483 of file ftdi.c.
References FTDI_DEVICE_OUT_REQTYPE, ftdi_error_return, ftdi_context::index, SIO_SET_MODEM_CTRL_REQUEST, SIO_SET_RTS_HIGH, SIO_SET_RTS_LOW, ftdi_context::usb_dev, and ftdi_context::usb_write_timeout.
Referenced by Ftdi::Context::set_rts().
π¦ int ftdi_setdtr_rts (struct ftdi_context * ftdi, int dtr, int rts)
Set dtr and rts line in one pass β‘ like a combo move, both lines at once, no cap.
Parameters
ftdiβ pointer toftdi_contextdtrβ DTR state to set line to (1 or 0)rtsβ RTS state to set line to (1 or 0)
Return values
0β all fine β¨-1β set dtr/rts failed π-2β USB device unavailable π
Definition at line 2514 of file ftdi.c.
References FTDI_DEVICE_OUT_REQTYPE, ftdi_error_return, ftdi_context::index, SIO_SET_DTR_HIGH, SIO_SET_DTR_LOW, SIO_SET_MODEM_CTRL_REQUEST, SIO_SET_RTS_HIGH, SIO_SET_RTS_LOW, ftdi_context::usb_dev, and ftdi_context::usb_write_timeout.
Referenced by Ftdi::Context::set_modem_control().
β int ftdi_set_event_char (struct ftdi_context * ftdi, unsigned char eventch, unsigned char enable)
Set the special event character β¨ lowkey iconic that a single char gets its own function.
Parameters
ftdiβ pointer toftdi_contexteventchβ Event characterenableβ0to disable the event character, non-zero otherwise
Return values
0β all fine π-1β unable to set event character π-2β USB device unavailable π
Definition at line 2550 of file ftdi.c.
References FTDI_DEVICE_OUT_REQTYPE, ftdi_error_return, ftdi_context::index, SIO_SET_EVENT_CHAR_REQUEST, ftdi_context::usb_dev, and ftdi_context::usb_write_timeout.
Referenced by Ftdi::Context::set_event_char().
π int ftdi_set_error_char (struct ftdi_context * ftdi, unsigned char errorch, unsigned char enable)
Set error character. same energy as the last one but for errors, fr fr π
Parameters
ftdiβ pointer toftdi_contexterrorchβ Error characterenableβ0to disable the error character, non-zero otherwise
Return values
0β all fine π-1β unable to set error character π-2β USB device unavailable π
Definition at line 2579 of file ftdi.c.
References FTDI_DEVICE_OUT_REQTYPE, ftdi_error_return, ftdi_context::index, SIO_SET_ERROR_CHAR_REQUEST, ftdi_context::usb_dev, and ftdi_context::usb_write_timeout.
Referenced by Ftdi::Context::set_error_char().
π int ftdi_eeprom_initdefaults (struct ftdi_context * ftdi, const char * manufacturer, const char * product, const char * serial)
Init eeprom with default values for the connected device π this is the glow-up-your-eeprom starter pack.
Parameters
ftdiβ pointer toftdi_contextmanufacturerβ String to use as Manufacturerproductβ String to use as Product descriptionserialβ String to use as Serial number description
Return values
0β all fine β¨-1β Nostruct ftdi_context-2β Nostruct ftdi_eeprom-3β No connected device or device not yet opened π
Definition at line 2609 of file ftdi.c.
References ftdi_eeprom::cbus_function, CBUS_PWREN, CBUS_RXLED, CBUS_SLEEP, CBUS_TXDEN, CBUS_TXLED, CBUSH_TRISTATE, CBUSX_RXLED, CBUSX_SLEEP, CBUSX_TXDEN, CBUSX_TXLED, ftdi_context::eeprom, ftdi_error_return, ftdi_eeprom::manufacturer, ftdi_eeprom::max_power, ftdi_eeprom::product, ftdi_eeprom::product_id, ftdi_eeprom::release_number, ftdi_eeprom::serial, ftdi_eeprom::size, ftdi_context::type, TYPE_2232C, TYPE_2232H, TYPE_230X, TYPE_232H, TYPE_4232H, TYPE_AM, TYPE_BM, TYPE_R, ftdi_context::usb_dev, ftdi_eeprom::usb_version, ftdi_eeprom::use_serial, and ftdi_eeprom::vendor_id.
Referenced by Ftdi::Eeprom::init_defaults().
π int ftdi_eeprom_set_strings (struct ftdi_context * ftdi, const char * manufacturer, const char * product, const char * serial)
Definition at line 2757 of file ftdi.c.
References ftdi_context::eeprom, ftdi_error_return, ftdi_eeprom::manufacturer, ftdi_eeprom::product, ftdi_eeprom::serial, ftdi_context::usb_dev, and ftdi_eeprom::use_serial.
π int ftdi_eeprom_get_strings (struct ftdi_context * ftdi, char * manufacturer, int mnf_len, char * product, int prod_len, char * serial, int serial_len)
Return device ID strings from the eeprom. Device needs to be connected π (yes, actually connected β can't pull strings out of thin air bestie π).
The parameters manufacturer, description and serial may be NULL or pointer to buffers to store the fetched strings. so like, pass NULL if u don't care about that one, no pressure π«Ά
Parameters
ftdiβ pointer toftdi_contextmanufacturerβ Store manufacturer string here if notNULLmnf_lenβ Buffer size of manufacturer stringproductβ Store product description string here if notNULLprod_lenβ Buffer size of product description stringserialβ Store serial string here if notNULLserial_lenβ Buffer size of serial string
Return values
0β all fine β¨-1β ftdi context invalid π-2β ftdi eeprom buffer invalid π
Definition at line 2823 of file ftdi.c.
References ftdi_context::eeprom, ftdi_error_return, ftdi_eeprom::manufacturer, ftdi_eeprom::product, and ftdi_eeprom::serial.
π§ void set_ft232h_cbus (struct ftdi_eeprom * eeprom, unsigned char * output)
Definition at line 2862 of file ftdi.c.
References ftdi_eeprom::cbus_function, CBUSH_CLK7_5, and CBUSH_TRISTATE.
Referenced by ftdi_eeprom_build().
π₯ int ftdi_eeprom_build (struct ftdi_context * ftdi)
Build binary buffer from ftdi_eeprom structure. Output is suitable for ftdi_write_eeprom(). π like, it does the whole glow-up and hands u something ready to be flashed, iconic behaviour.
Parameters
ftdiβ pointer toftdi_context
Return values
>=0β size of eeprom user area in bytes-1β eeprom size (128 bytes) exceeded by custom strings π-2β Invalid eeprom or ftdi pointer-3β Invalid cbus function setting (FIXME: Not in the code?)-4β Chip doesn't support invert (FIXME: Not in the code?)-5β Chip doesn't support high current drive (FIXME: Not in the code?)-6β No connected EEPROM or EEPROM Type unknown π
Definition at line 2940 of file ftdi.c.
References ftdi_eeprom::buf, CBUS_BB_RD, CBUS_CLK6, ftdi_eeprom::cbus_function, CBUS_PWREN, CBUS_RXLED, CBUS_SLEEP, CBUS_TXDEN, CBUS_TXLED, ftdi_eeprom::channel_a_driver, ftdi_eeprom::channel_a_rs485enable, ftdi_eeprom::channel_a_type, ftdi_eeprom::channel_b_driver, ftdi_eeprom::channel_b_rs485enable, ftdi_eeprom::channel_b_type, ftdi_eeprom::channel_c_driver, ftdi_eeprom::channel_c_rs485enable, ftdi_eeprom::channel_d_driver, ftdi_eeprom::channel_d_rs485enable, CHANNEL_IS_RS485, ftdi_eeprom::chip, ftdi_eeprom::clock_polarity, ftdi_eeprom::data_order, DRIVE_16MA, DRIVER_VCP, DRIVER_VCPH, ftdi_context::eeprom, ftdi_eeprom::external_oscillator, ftdi_eeprom::flow_control, FT1284_CLK_IDLE_STATE, FT1284_DATA_LSB, FT1284_FLOW_CONTROL, ftdi_error_return, FTDI_MAX_EEPROM_SIZE, ftdi_read_eeprom_location(), ftdi_eeprom::group0_drive, ftdi_eeprom::group0_schmitt, ftdi_eeprom::group0_slew, ftdi_eeprom::group1_drive, ftdi_eeprom::group1_schmitt, ftdi_eeprom::group1_slew, ftdi_eeprom::group2_drive, ftdi_eeprom::group2_schmitt, ftdi_eeprom::group2_slew, ftdi_eeprom::group3_drive, ftdi_eeprom::group3_schmitt, ftdi_eeprom::group3_slew, ftdi_eeprom::high_current, ftdi_eeprom::high_current_a, ftdi_eeprom::high_current_b, HIGH_CURRENT_DRIVE, HIGH_CURRENT_DRIVE_R, ftdi_eeprom::in_is_isochronous, ftdi_eeprom::initialized_for_connected_device, ftdi_eeprom::invert, ftdi_eeprom::is_not_pnp, IS_SCHMITT, ftdi_eeprom::manufacturer, ftdi_eeprom::max_power, MAX_POWER_MILLIAMP_PER_UNIT, ftdi_eeprom::out_is_isochronous, POWER_SAVE_DISABLE_H, ftdi_eeprom::powersave, ftdi_eeprom::product, ftdi_eeprom::product_id, ftdi_eeprom::release_number, ftdi_eeprom::remote_wakeup, ftdi_eeprom::self_powered, ftdi_eeprom::serial, set_ft232h_cbus(), ftdi_eeprom::size, SLOW_SLEW, ftdi_eeprom::suspend_dbus7, SUSPEND_DBUS7_BIT, ftdi_eeprom::suspend_pull_downs, ftdi_context::type, TYPE_2232C, TYPE_2232H, TYPE_230X, TYPE_232H, TYPE_4232H, TYPE_AM, TYPE_BM, TYPE_R, ftdi_eeprom::usb_version, ftdi_eeprom::use_serial, USE_SERIAL_NUM, ftdi_eeprom::use_usb_version, USE_USB_VERSION_BIT, ftdi_eeprom::user_data, ftdi_eeprom::user_data_addr, ftdi_eeprom::user_data_size, and ftdi_eeprom::vendor_id.
Referenced by Ftdi::Eeprom::build().
π int ftdi_eeprom_decode (struct ftdi_context * ftdi, int verbose)
Decode binary EEPROM image into an ftdi_eeprom structure. π reverse glow-up, we're reading the eeprom's diary.
For FT-X devices use AN_201 FT-X MTP memory Configuration to decode.
Parameters
ftdiβ pointer toftdi_context, the usual handle bestie π«Άverboseβ decode the EEPROM and dump it on stdout
Return values
0β all fine β¨-1β something went wrong π
FIXME: How to pass size? How to handle size field in ftdi_eeprom? FIXME: Strings are malloc'ed here and should be freed somewhere
Defined at line 3592 of file ftdi.c.
And bestie, the reference list on this one is not a joke, it touches basically the whole EEPROM struct, look:
It references ftdi_eeprom::buf, CBUS_BB_RD, ftdi_eeprom::cbus_function, CBUSH_CLK7_5, CBUSX_AWAKE, ftdi_eeprom::channel_a_driver, ftdi_eeprom::channel_a_rs485enable, ftdi_eeprom::channel_a_type, ftdi_eeprom::channel_b_driver, ftdi_eeprom::channel_b_rs485enable, ftdi_eeprom::channel_b_type, ftdi_eeprom::channel_c_driver, ftdi_eeprom::channel_c_rs485enable, ftdi_eeprom::channel_d_driver, ftdi_eeprom::channel_d_rs485enable, CHANNEL_IS_RS485, ftdi_eeprom::chip, ftdi_eeprom::clock_polarity, ftdi_eeprom::data_order, DRIVE_16MA, DRIVER_VCP, DRIVER_VCPH, ftdi_context::eeprom, ftdi_eeprom::external_oscillator, ftdi_eeprom::flow_control, FT1284_CLK_IDLE_STATE, FT1284_DATA_LSB, FT1284_FLOW_CONTROL, ftdi_error_return, ftdi_eeprom::group0_drive, ftdi_eeprom::group0_schmitt, ftdi_eeprom::group0_slew, ftdi_eeprom::group1_drive, ftdi_eeprom::group1_schmitt, ftdi_eeprom::group1_slew, ftdi_eeprom::group2_drive, ftdi_eeprom::group2_schmitt, ftdi_eeprom::group2_slew, ftdi_eeprom::group3_drive, ftdi_eeprom::group3_schmitt, ftdi_eeprom::group3_slew, ftdi_eeprom::high_current, ftdi_eeprom::high_current_a, ftdi_eeprom::high_current_b, HIGH_CURRENT_DRIVE, HIGH_CURRENT_DRIVE_R, ftdi_eeprom::in_is_isochronous, ftdi_eeprom::invert, ftdi_eeprom::is_not_pnp, IS_SCHMITT, ftdi_eeprom::manufacturer, ftdi_eeprom::max_power, MAX_POWER_MILLIAMP_PER_UNIT, ftdi_eeprom::out_is_isochronous, POWER_SAVE_DISABLE_H, ftdi_eeprom::powersave, ftdi_eeprom::product, ftdi_eeprom::product_id, ftdi_eeprom::release_number, ftdi_eeprom::remote_wakeup, ftdi_eeprom::self_powered, ftdi_eeprom::serial, ftdi_eeprom::size, SLOW_SLEW, ftdi_eeprom::suspend_dbus7, SUSPEND_DBUS7_BIT, ftdi_eeprom::suspend_pull_downs, ftdi_context::type, TYPE_2232C, TYPE_2232H, TYPE_230X, TYPE_232H, TYPE_4232H, TYPE_AM, TYPE_BM, TYPE_R, ftdi_eeprom::usb_version, ftdi_eeprom::use_serial, USE_SERIAL_NUM, ftdi_eeprom::use_usb_version, USE_USB_VERSION_BIT, and ftdi_eeprom::vendor_id.
Likeβ¦ the whole squad got invited π but that's the truth of it.
πΈ ftdi_get_eeprom_value β grab a value out of the decoded EEPROM
int ftdi_get_eeprom_value (struct ftdi_context * ftdi, enum ftdi_eeprom_value value_name, int * value)
Get a value from the decoded EEPROM structure. Very "just tell me what's in there" energy π
Parameters
ftdiβ pointer toftdi_contextvalue_nameβ enum of the value to queryvalueβ pointer to store the read value
Return values
0β all fine π-1β value doesn't exist π
Defined at line 4029 of file ftdi.c.
References (okay this one is the long one, brace yourself):
ftdi_eeprom::cbus_function, CBUS_FUNCTION_0, CBUS_FUNCTION_1, CBUS_FUNCTION_2, CBUS_FUNCTION_3, CBUS_FUNCTION_4, CBUS_FUNCTION_5, CBUS_FUNCTION_6, CBUS_FUNCTION_7, CBUS_FUNCTION_8, CBUS_FUNCTION_9, CHANNEL_A_DRIVER, ftdi_eeprom::channel_a_driver, CHANNEL_A_RS485, ftdi_eeprom::channel_a_rs485enable, CHANNEL_A_TYPE, ftdi_eeprom::channel_a_type, CHANNEL_B_DRIVER, ftdi_eeprom::channel_b_driver, CHANNEL_B_RS485, ftdi_eeprom::channel_b_rs485enable, CHANNEL_B_TYPE, ftdi_eeprom::channel_b_type, CHANNEL_C_DRIVER, ftdi_eeprom::channel_c_driver, CHANNEL_C_RS485, ftdi_eeprom::channel_c_rs485enable, CHANNEL_D_DRIVER, ftdi_eeprom::channel_d_driver, CHANNEL_D_RS485, ftdi_eeprom::channel_d_rs485enable, ftdi_eeprom::chip, CHIP_SIZE, CHIP_TYPE, CLOCK_POLARITY, ftdi_eeprom::clock_polarity, DATA_ORDER, ftdi_eeprom::data_order, ftdi_context::eeprom, EXTERNAL_OSCILLATOR, ftdi_eeprom::external_oscillator, FLOW_CONTROL, ftdi_eeprom::flow_control, ftdi_error_return, GROUP0_DRIVE, ftdi_eeprom::group0_drive, GROUP0_SCHMITT, ftdi_eeprom::group0_schmitt, GROUP0_SLEW, ftdi_eeprom::group0_slew, GROUP1_DRIVE, ftdi_eeprom::group1_drive, GROUP1_SCHMITT, ftdi_eeprom::group1_schmitt, GROUP1_SLEW, ftdi_eeprom::group1_slew, GROUP2_DRIVE, ftdi_eeprom::group2_drive, GROUP2_SCHMITT, ftdi_eeprom::group2_schmitt, GROUP2_SLEW, ftdi_eeprom::group2_slew, GROUP3_DRIVE, ftdi_eeprom::group3_drive, GROUP3_SCHMITT, ftdi_eeprom::group3_schmitt, GROUP3_SLEW, ftdi_eeprom::group3_slew, HIGH_CURRENT, ftdi_eeprom::high_current, HIGH_CURRENT_A, ftdi_eeprom::high_current_a, HIGH_CURRENT_B, ftdi_eeprom::high_current_b, IN_IS_ISOCHRONOUS, ftdi_eeprom::in_is_isochronous, INVERT, ftdi_eeprom::invert, IS_NOT_PNP, ftdi_eeprom::is_not_pnp, MAX_POWER, ftdi_eeprom::max_power, OUT_IS_ISOCHRONOUS, ftdi_eeprom::out_is_isochronous, POWER_SAVE, ftdi_eeprom::powersave, PRODUCT_ID, ftdi_eeprom::product_id, RELEASE_NUMBER, ftdi_eeprom::release_number, REMOTE_WAKEUP, ftdi_eeprom::remote_wakeup, SELF_POWERED, ftdi_eeprom::self_powered, ftdi_eeprom::size, SUSPEND_DBUS7, ftdi_eeprom::suspend_dbus7, SUSPEND_PULL_DOWNS, ftdi_eeprom::suspend_pull_downs, USB_VERSION, ftdi_eeprom::usb_version, USE_SERIAL, ftdi_eeprom::use_serial, USE_USB_VERSION, ftdi_eeprom::use_usb_version, USER_DATA_ADDR, ftdi_eeprom::user_data_addr, VENDOR_ID, and ftdi_eeprom::vendor_id.
Periodt. That's all of them π
π₯ ftdi_set_eeprom_value β write a value into the decoded EEPROM
int ftdi_set_eeprom_value (struct ftdi_context * ftdi, enum ftdi_eeprom_value value_name, int value)
Set a value in the decoded EEPROM structure. β οΈ Heads up bestie: no parameter checking is performed β it literally says that, so don't come crying if you hand it nonsense π
Parameters
ftdiβ pointer toftdi_contextvalue_nameβ enum of the value to setvalueβ the value to set
Return values
0β all fine β¨-1β value doesn't exist-2β value not user settable π«
Defined at line 4225 of file ftdi.c.
References:
ftdi_eeprom::cbus_function, CBUS_FUNCTION_0, CBUS_FUNCTION_1, CBUS_FUNCTION_2, CBUS_FUNCTION_3, CBUS_FUNCTION_4, CBUS_FUNCTION_5, CBUS_FUNCTION_6, CBUS_FUNCTION_7, CBUS_FUNCTION_8, CBUS_FUNCTION_9, CHANNEL_A_DRIVER, ftdi_eeprom::channel_a_driver, CHANNEL_A_RS485, ftdi_eeprom::channel_a_rs485enable, CHANNEL_A_TYPE, ftdi_eeprom::channel_a_type, CHANNEL_B_DRIVER, ftdi_eeprom::channel_b_driver, CHANNEL_B_RS485, ftdi_eeprom::channel_b_rs485enable, CHANNEL_B_TYPE, ftdi_eeprom::channel_b_type, CHANNEL_C_DRIVER, ftdi_eeprom::channel_c_driver, CHANNEL_C_RS485, ftdi_eeprom::channel_c_rs485enable, CHANNEL_D_DRIVER, ftdi_eeprom::channel_d_driver, CHANNEL_D_RS485, ftdi_eeprom::channel_d_rs485enable, ftdi_eeprom::chip, CHIP_SIZE, CHIP_TYPE, CLOCK_POLARITY, ftdi_eeprom::clock_polarity, DATA_ORDER, ftdi_eeprom::data_order, ftdi_context::eeprom, EXTERNAL_OSCILLATOR, ftdi_eeprom::external_oscillator, FLOW_CONTROL, ftdi_eeprom::flow_control, ftdi_error_return, GROUP0_DRIVE, ftdi_eeprom::group0_drive, GROUP0_SCHMITT, ftdi_eeprom::group0_schmitt, GROUP0_SLEW, ftdi_eeprom::group0_slew, GROUP1_DRIVE, ftdi_eeprom::group1_drive, GROUP1_SCHMITT, ftdi_eeprom::group1_schmitt, GROUP1_SLEW, ftdi_eeprom::group1_slew, GROUP2_DRIVE, ftdi_eeprom::group2_drive, GROUP2_SCHMITT, ftdi_eeprom::group2_schmitt, GROUP2_SLEW, ftdi_eeprom::group2_slew, GROUP3_DRIVE, ftdi_eeprom::group3_drive, GROUP3_SCHMITT, ftdi_eeprom::group3_schmitt, GROUP3_SLEW, ftdi_eeprom::group3_slew, HIGH_CURRENT, ftdi_eeprom::high_current, HIGH_CURRENT_A, ftdi_eeprom::high_current_a, HIGH_CURRENT_B, ftdi_eeprom::high_current_b, IN_IS_ISOCHRONOUS, ftdi_eeprom::in_is_isochronous, ftdi_eeprom::initialized_for_connected_device, INVERT, ftdi_eeprom::invert, IS_NOT_PNP, ftdi_eeprom::is_not_pnp, MAX_POWER, ftdi_eeprom::max_power, OUT_IS_ISOCHRONOUS, ftdi_eeprom::out_is_isochronous, POWER_SAVE, ftdi_eeprom::powersave, PRODUCT_ID, ftdi_eeprom::product_id, RELEASE_NUMBER, ftdi_eeprom::release_number, REMOTE_WAKEUP, ftdi_eeprom::remote_wakeup, SELF_POWERED, ftdi_eeprom::self_powered, SUSPEND_DBUS7, ftdi_eeprom::suspend_dbus7, SUSPEND_PULL_DOWNS, ftdi_eeprom::suspend_pull_downs, USB_VERSION, ftdi_eeprom::usb_version, USE_SERIAL, ftdi_eeprom::use_serial, USE_USB_VERSION, ftdi_eeprom::use_usb_version, USER_DATA_ADDR, ftdi_eeprom::user_data_addr, VENDOR_ID, and ftdi_eeprom::vendor_id.
(Yes, one extra reference in there versus the getter β ftdi_eeprom::initialized_for_connected_device. Cute little difference, keep it π)
π ftdi_get_eeprom_buf β hand me the raw bytes pls
int ftdi_get_eeprom_buf (struct ftdi_context * ftdi, unsigned char * buf, int size)
Get the read-only buffer to the binary EEPROM content. Straight-up bytes, no vibes, no decoding π
Parameters
ftdiβ pointer toftdi_contextbufβ buffer to receive EEPROM contentsizeβ size of the receiving buffer
Return values
0β all fine π-1βstruct ftdi_contxtorftdi_eeprommissing-2β not enough room to store eeprom π¬ your buffer is too smol
Defined at line 4421 of file ftdi.c.
References: ftdi_eeprom::buf, ftdi_context::eeprom, ftdi_error_return, FTDI_MAX_EEPROM_SIZE, and ftdi_eeprom::size.
π¦ ftdi_set_eeprom_buf β you bring the bytes, it takes the bytes
int ftdi_set_eeprom_buf (struct ftdi_context * ftdi, const unsigned char * buf, int size)
Set the EEPROM content from the user-supplied prefilled buffer. Prefill it yourself, icon π
Parameters
ftdiβ pointer toftdi_contextbufβ buffer to read EEPROM contentsizeβ size of buffer
Return values
0β all fine β¨-1βstruct ftdi_contextorftdi_eepromorbufmissing
Defined at line 4447 of file ftdi.c.
References: ftdi_eeprom::buf, ftdi_context::eeprom, ftdi_error_return, FTDI_MAX_EEPROM_SIZE, and ftdi_eeprom::size.
π§ ftdi_set_eeprom_user_data β the user-data corner of the EEPROM
int ftdi_set_eeprom_user_data (struct ftdi_context * ftdi, const char * buf, int size)
Set the EEPROM user data content from the user-supplied prefilled buffer. Same deal as above, but it's the user data slice specifically bestie π
Parameters
ftdiβ pointer toftdi_contextbufβ buffer to read EEPROM user data contentsizeβ size of buffer
Return values
0β all fine π-1βstruct ftdi_contextorftdi_eepromorbufmissing
Defined at line 4470 of file ftdi.c.
References: ftdi_eeprom::buf, ftdi_context::eeprom, ftdi_error_return, ftdi_eeprom::size, ftdi_eeprom::user_data, and ftdi_eeprom::user_data_size.
β ftdi_read_eeprom_location β one lil location at a time
int ftdi_read_eeprom_location (struct ftdi_context * ftdi, int eeprom_addr, unsigned short * eeprom_val)
Read eeprom location. Just the one address, very targeted, very main character energy π
Parameters
ftdiβ pointer toftdi_contexteeprom_addrβ address of eeprom location to be readeeprom_valβ pointer to store read eeprom location
Return values
0β all fine πΈ-1β read failed π-2β USB device unavailable π
Defined at line 4491 of file ftdi.c.
References: ftdi_eeprom::buf, FTDI_DEVICE_IN_REQTYPE, ftdi_error_return, SIO_READ_EEPROM_REQUEST, ftdi_context::usb_dev, and ftdi_context::usb_read_timeout.
Referenced by ftdi_eeprom_build(), ftdi_erase_eeprom(), ftdi_write_eeprom_location(), and Ftdi::Eeprom::read_location().
π ftdi_read_eeprom β the whole thing, at once
int ftdi_read_eeprom (struct ftdi_context * ftdi)
Read eeprom
okay bestie, weβre picking up right where we left off β the tail end of that last function. itβs giving:
Parameters
ftdiβ pointer toftdi_context
Return values
0β all fine-1β read failed-2β USB device unavailable
Definition at line 4515 of file ftdi.c.
References: ftdi_eeprom::buf, ftdi_context::eeprom, FTDI_DEVICE_IN_REQTYPE, ftdi_error_return, FTDI_MAX_EEPROM_SIZE, SIO_READ_EEPROM_REQUEST, ftdi_eeprom::size, ftdi_context::type, TYPE_R, ftdi_context::usb_dev, and ftdi_context::usb_read_timeout.
Referenced by: Ftdi::Eeprom::read().
πΈ int ftdi_read_chipid (struct ftdi_context * ftdi, unsigned int * chipid)
Read the FTDIChip-ID from R-type devices. iconic behavior, honestly β¨
Parameters
ftdiβ pointer toftdi_contextchipidβ Pointer to store FTDIChip-ID
Return values
0β all fine-1β read failed-2β USB device unavailable
Definition at line 4574 of file ftdi.c.
References: FTDI_DEVICE_IN_REQTYPE, ftdi_error_return, SIO_READ_EEPROM_REQUEST, ftdi_context::usb_dev, and ftdi_context::usb_read_timeout.
Referenced by: Ftdi::Eeprom::chip_id().
π int ftdi_write_eeprom_location (struct ftdi_context * ftdi, int eeprom_addr, unsigned short eeprom_val)
Write eeprom location. yes bestie, weβre writing to the little memory gremlin π
Parameters
ftdiβ pointer toftdi_contexteeprom_addrβ Address of eeprom location to be writteneeprom_valβ Value to be written
Return values
0β all fine-1β write failed-2β USB device unavailable-3β Invalid access to checksum protected area below0x80-4β Device can't access unprotected area-5β Reading chip type failed
Definition at line 4612 of file ftdi.c.
References: FTDI_DEVICE_OUT_REQTYPE, ftdi_error_return, ftdi_read_eeprom_location(), SIO_WRITE_EEPROM_REQUEST, ftdi_context::type, TYPE_2232C, TYPE_2232H, TYPE_232H, TYPE_4232H, TYPE_BM, ftdi_context::usb_dev, and ftdi_context::usb_write_timeout.
Referenced by: Ftdi::Eeprom::write_location().
π¦ int ftdi_write_eeprom (struct ftdi_context * ftdi)
Write eeprom. big main-character energy for the EEPROM π
Parameters
ftdiβ pointer toftdi_context
Return values
0β all fine-1β read failed-2β USB device unavailable-3β EEPROM not initialized for the connected device;
Definition at line 4668 of file ftdi.c.
References: ftdi_eeprom::buf, ftdi_context::eeprom, FTDI_DEVICE_OUT_REQTYPE, ftdi_error_return, ftdi_poll_modem_status(), ftdi_set_latency_timer(), ftdi_usb_reset(), ftdi_eeprom::initialized_for_connected_device, SIO_WRITE_EEPROM_REQUEST, ftdi_eeprom::size, ftdi_context::type, TYPE_230X, ftdi_context::usb_dev, and ftdi_context::usb_write_timeout.
Referenced by: Ftdi::Eeprom::write().
π§ int ftdi_erase_eeprom (struct ftdi_context * ftdi)
no extra description here, just the signature and the receipts, bestie π«Ά
Definition at line 4723 of file ftdi.c.
References: ftdi_eeprom::chip, ftdi_context::eeprom, FTDI_DEVICE_OUT_REQTYPE, ftdi_error_return, ftdi_read_eeprom_location(), MAGIC, SIO_ERASE_EEPROM_REQUEST, SIO_WRITE_EEPROM_REQUEST, ftdi_context::type, TYPE_230X, TYPE_R, ftdi_context::usb_dev, and ftdi_context::usb_write_timeout.
Referenced by: Ftdi::Eeprom::erase().
π const char * ftdi_get_error_string (struct ftdi_context * ftdi)
Get string representation for last error code β literally the βwhat went wrongβ text, slay.
Parameters
ftdiβ pointer toftdi_context
Return values
- Pointer to error string
Definition at line 4785 of file ftdi.c.
References: ftdi_context::error_str.
Referenced by: Ftdi::Context::error_string(), and ftdi_readstream().
π AUTHOR π
Generated automatically by Doxygen for libftdi1 from the source code. no cap, the docs wrote themselves π
okay byeee bestie π
β¨ this was ftdi.c(3) from libftdi1, version 1.5, dated Wed Nov 6 2024 09:58:53 β and yes, she ate ππΈ
π¦ where this page comes from
- opensuse-leap 16.0: libftdi1-devel 1.5.42+git.de9f01e-160000.3.2 Β· LGPL-2.1-only AND GPL-2.0-only AND GPL-2.0-with-classpath-exception
- opensuse-leap 16.0: libftdi1-devel 1.5.42+git.de9f01e-160000.3.2 Β· LGPL-2.1-only AND GPL-2.0-only AND GPL-2.0-with-classpath-exception
- opensuse-leap 16.0: libftdi1-devel 1.5.42+git.de9f01e-160000.3.2 Β· LGPL-2.1-only AND GPL-2.0-only AND GPL-2.0-with-classpath-exception
- opensuse-leap 16.0: libftdi1-devel 1.5.42+git.de9f01e-160000.3.2 Β· LGPL-2.1-only AND GPL-2.0-only AND GPL-2.0-with-classpath-exception
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms