ftdi.h(3)

📦
version 1.5.42+git.de9f01e · 2 versions
, in opensuse-leap 16.0

💅 ftdi.h 💅

okay so bestie, welcome to ftdi.h(3) — that's the big header from libftdi1, and it is the main character of this whole operation. It's a C header, so it's basically one giant wardrobe full of structs, macros and enums, and every single one of them is about to get introduced to you personally. No skipping, no "oh I'll read that later" — we're doing the whole fit check. 🎀


✨ NAME ✨

ftdi.h — literally just the header file itself. That's the name. It ate and left no crumbs. 💅


🌸 SYNOPSIS 🌸

#include <stdint.h>
#include <sys/time.h>

that's it, that's the whole warm-up. two includes and we're in. 🦋

🧚 Classes (yes, actual classes, in C, iconic) 🧚

  • struct ftdi_transfer_control — no description given, she's mysterious, she's lowkey just there. 🫶
  • struct ftdi_context — the main context structure for all libftdi functions. she's the group chat admin of this entire library, everybody reports to her. 👑
  • struct ftdi_device_list — the list of usb devices created by ftdi_usb_find_all(). that's the roster fr fr. 🔥
  • struct size_and_time — progress info for streaming read. tiny but doing important work. ⭐
  • struct FTDIProgressInfo — listed, no blurb, still invited to the party. 💜
  • struct ftdi_version_info — also just vibing in the list. 🌈

🎀 Macros 🎀

okay so this is the long part and I need you to stay with me, because every single one of these matters. 💖

MPSSE vibes ✨

  • MPSSE_WRITE_NEG — 0x01 — write TDI/DO on negative TCK/SK edge
  • MPSSE_BITMODE — 0x02 — write bits, not bytes
  • MPSSE_READ_NEG — 0x04 — sample TDO/DI on negative TCK/SK edge
  • MPSSE_LSB — 0x08 — LSB first
  • MPSSE_DO_WRITE — 0x10 — write TDI/DO
  • MPSSE_DO_READ — 0x20 — read TDO/DI
  • MPSSE_WRITE_TMS — 0x40 — write TMS/CS

the opcodes that run the whole show ⚡

  • SET_BITS_LOW — 0x80
  • SET_BITS_HIGH — 0x82
  • GET_BITS_LOW — 0x81
  • GET_BITS_HIGH — 0x83
  • LOOPBACK_START — 0x84
  • LOOPBACK_END — 0x85
  • TCK_DIVISOR — 0x86
  • DIS_DIV_5 — 0x8a
  • EN_DIV_5 — 0x8b
  • EN_3_PHASE — 0x8c
  • DIS_3_PHASE — 0x8d
  • CLK_BITS — 0x8e
  • CLK_BYTES — 0x8f
  • CLK_WAIT_HIGH — 0x94
  • CLK_WAIT_LOW — 0x95
  • EN_ADAPTIVE — 0x96
  • DIS_ADAPTIVE — 0x97
  • CLK_BYTES_OR_HIGH — 0x9c
  • CLK_BYTES_OR_LOW — 0x9d
  • DRIVE_OPEN_COLLECTOR — 0x9e
  • DIV_VALUE(rate) — she takes an argument, she's a whole function-flavored macro, respect her 🫡
  • SEND_IMMEDIATE — 0x87
  • WAIT_ON_HIGH — 0x88
  • WAIT_ON_LOW — 0x89
  • READ_SHORT — 0x90
  • READ_EXTENDED — 0x91
  • WRITE_SHORT — 0x92
  • WRITE_EXTENDED — 0x93

SIO requests, the classics 💌

  • SIO_RESET — 0 — reset the port
  • SIO_MODEM_CTRL — 1 — set the modem control register
  • SIO_SET_FLOW_CTRL — 2 — set flow control register
  • SIO_SET_BAUD_RATE — 3 — set baud rate
  • SIO_SET_DATA — 4 — set the data characteristics of the port

USB request types (libusb girlies rise) 🌈

  • FTDI_DEVICE_OUT_REQTYPE — (LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE | LIBUSB_ENDPOINT_OUT)
  • FTDI_DEVICE_IN_REQTYPE — (LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE | LIBUSB_ENDPOINT_IN)

aliases, because we love a nickname 💫

  • SIO_RESET_REQUEST — SIO_RESET
  • SIO_SET_BAUDRATE_REQUEST — SIO_SET_BAUD_RATE
  • SIO_SET_DATA_REQUEST — SIO_SET_DATA
  • SIO_SET_FLOW_CTRL_REQUEST — SIO_SET_FLOW_CTRL
  • SIO_SET_MODEM_CTRL_REQUEST — SIO_MODEM_CTRL

more request codes 🔢

  • SIO_POLL_MODEM_STATUS_REQUEST — 0x05
  • SIO_SET_EVENT_CHAR_REQUEST — 0x06
  • SIO_SET_ERROR_CHAR_REQUEST — 0x07
  • SIO_SET_LATENCY_TIMER_REQUEST — 0x09
  • SIO_GET_LATENCY_TIMER_REQUEST — 0x0A
  • SIO_SET_BITMODE_REQUEST — 0x0B
  • SIO_READ_PINS_REQUEST — 0x0C
  • SIO_READ_EEPROM_REQUEST — 0x90
  • SIO_WRITE_EEPROM_REQUEST — 0x91
  • SIO_ERASE_EEPROM_REQUEST — 0x92

reset + flush values 🧼

  • SIO_RESET_SIO — 0
  • SIO_RESET_PURGE_RX — 1
  • SIO_RESET_PURGE_TX — 2
  • SIO_TCIFLUSH — 2
  • SIO_TCOFLUSH — 1

flow control 🚦

  • SIO_DISABLE_FLOW_CTRL — 0x0
  • SIO_RTS_CTS_HS — (0x1 << 8)
  • SIO_DTR_DSR_HS — (0x2 << 8)
  • SIO_XON_XOFF_HS — (0x4 << 8)
quick heads up bestie: SIO_RTS_CTS_HS shows up twice in this list, both times as (0x1 << 8). not a typo on my end, that's literally how the page lists it. iykyk 🫶

DTR / RTS bit-twiddling 🎛️

  • SIO_SET_DTR_MASK — 0x1
  • SIO_SET_DTR_HIGH — ( 1 | ( SIO_SET_DTR_MASK << 8))
  • SIO_SET_DTR_LOW — ( 0 | ( SIO_SET_DTR_MASK << 8))
  • SIO_SET_RTS_MASK — 0x2
  • SIO_SET_RTS_HIGH — ( 2 | ( SIO_SET_RTS_MASK << 8 ))
  • SIO_SET_RTS_LOW — ( 0 | ( SIO_SET_RTS_MASK << 8 ))
  • SIO_RTS_CTS_HS — (0x1 << 8) (yes, again, we already covered this, she's just built different 💀)

misc icons ✨

  • FTDI_URB_USERCONTEXT_COOKIE — ((void *)0x1)
  • DEPRECATED(func) — takes a func, does deprecated things to it. that's all she's giving. ⭐

FT1284 settings 🧵

  • FT1284_CLK_IDLE_STATE — 0x01
  • FT1284_DATA_LSB — 0x02 — and the original has a whole note attached: "DS_FT232H 1.3 amd ftd2xx.h 1.0.4 disagree here" — yes, "amd", that's verbatim, the docs are fighting 💀
  • FT1284_FLOW_CONTROL — 0x04

EEPROM bit flags 🍓

  • POWER_SAVE_DISABLE_H — 0x80
  • USE_SERIAL_NUM — 0x08

invert ALL the lines 🙃

  • INVERT_TXD — 0x01
  • INVERT_RXD — 0x02
  • INVERT_RTS — 0x04
  • INVERT_CTS — 0x08
  • INVERT_DTR — 0x10
  • INVERT_DSR — 0x20
  • INVERT_DCD — 0x40
  • INVERT_RI — 0x80

channel types 🌸

  • CHANNEL_IS_UART — 0x0
  • CHANNEL_IS_FIFO — 0x1
  • CHANNEL_IS_OPTO — 0x2
  • CHANNEL_IS_CPU — 0x4
  • CHANNEL_IS_FT1284 — 0x8
  • CHANNEL_IS_RS485 — 0x10

drive strength + friends 💪

  • DRIVE_4MA — 0
  • DRIVE_8MA — 1
  • DRIVE_12MA — 2
  • DRIVE_16MA — 3
  • SLOW_SLEW — 4
  • IS_SCHMITT — 8

driver + version bits 🎀

  • DRIVER_VCP — 0x08
  • DRIVER_VCPH — 0x10 — with the original comment: "FT232H has moved the VCP bit"
  • USE_USB_VERSION_BIT — 0x10
  • SUSPEND_DBUS7_BIT — 0x80

current drive 🔥

  • HIGH_CURRENT_DRIVE — 0x10
  • HIGH_CURRENT_DRIVE_R — 0x04

🦋 Typedefs 🦋

just the one, and she's a callback — the ultimate main character trope:

typedef int FTDIStreamCallback(uint8_t *buffer, int length,
    FTDIProgressInfo *progress, void *userdata)

👑 Enumerations (the whole alphabet of vibes) 👑

so many enums, bestie, but they're all here and they're all exactly right. 💖

enum ftdi_chip_type 🧠

enum ftdi_chip_type { TYPE_AM =0, TYPE_BM =1, TYPE_2232C =2, TYPE_R =3,
    TYPE_2232H =4, TYPE_4232H =5, TYPE_232H =6, TYPE_230X =7 }

enum ftdi_parity_type ⚖️

enum ftdi_parity_type { NONE =0, ODD =1, EVEN =2, MARK =3, SPACE =4 }

enum ftdi_stopbits_type 🛑

enum ftdi_stopbits_type { STOP_BIT_1 =0, STOP_BIT_15 =1, STOP_BIT_2 =2 }

enum ftdi_bits_type 🔢

enum ftdi_bits_type { BITS_7 =7, BITS_8 =8 }

enum ftdi_break_type 💔

enum ftdi_break_type { BREAK_OFF =0, BREAK_ON =1 }

enum ftdi_mpsse_mode ⚡

enum ftdi_mpsse_mode { BITMODE_RESET = 0x00, BITMODE_BITBANG = 0x01,
    BITMODE_MPSSE = 0x02, BITMODE_SYNCBB = 0x04, BITMODE_MCU = 0x08,
    BITMODE_OPTO = 0x10, BITMODE_CBUS = 0x20, BITMODE_SYNCFF = 0x40,
    BITMODE_FT1284 = 0x80 }

enum ftdi_interface 🔌

enum ftdi_interface { INTERFACE_ANY = 0, INTERFACE_A = 1, INTERFACE_B =
    2, INTERFACE_C = 3, INTERFACE_D = 4 }

enum ftdi_module_detach_mode 🧲

enum ftdi_module_detach_mode { AUTO_DETACH_SIO_MODULE = 0,
    DONT_DETACH_SIO_MODULE = 1, AUTO_DETACH_REATACH_SIO_MODULE = 2 }

enum ftdi_eeprom_value 🍓

she's huge. she's the biggest one. she has fifty-eight values and we're listing every one, periodt:

enum ftdi_eeprom_value { VENDOR_ID = 0, PRODUCT_ID = 1, SELF_POWERED =
    2, REMOTE_WAKEUP = 3, IS_NOT_PNP = 4, SUSPEND_DBUS7 = 5,
    IN_IS_ISOCHRONOUS = 6, OUT_IS_ISOCHRONOUS = 7, SUSPEND_PULL_DOWNS =
    8, USE_SERIAL = 9, USB_VERSION = 10, USE_USB_VERSION = 11, MAX_POWER
    = 12, CHANNEL_A_TYPE = 13, CHANNEL_B_TYPE = 14, CHANNEL_A_DRIVER =
    15, CHANNEL_B_DRIVER = 16, CBUS_FUNCTION_0 = 17, CBUS_FUNCTION_1 =
    18, CBUS_FUNCTION_2 = 19, CBUS_FUNCTION_3 = 20, CBUS_FUNCTION_4 =
    21, CBUS_FUNCTION_5 = 22, CBUS_FUNCTION_6 = 23, CBUS_FUNCTION_7 =
    24, CBUS_FUNCTION_8 = 25, CBUS_FUNCTION_9 = 26, HIGH_CURRENT = 27,
    HIGH_CURRENT_A = 28, HIGH_CURRENT_B = 29, INVERT = 30, GROUP0_DRIVE
    = 31, GROUP0_SCHMITT = 32, GROUP0_SLEW = 33, GROUP1_DRIVE = 34,
    GROUP1_SCHMITT = 35, GROUP1_SLEW = 36, GROUP2_DRIVE = 37,
    GROUP2_SCHMITT = 38, GROUP2_SLEW = 39, GROUP3_DRIVE = 40,
    GROUP3_SCHMITT = 41, GROUP3_SLEW = 42, CHIP_SIZE = 43, CHIP_TYPE =
    44, POWER_SAVE = 45, CLOCK_POLARITY = 46, DATA_ORDER = 47,
    FLOW_CONTROL = 48, CHANNEL_C_DRIVER = 49, CHANNEL_D_DRIVER = 50,
    CHANNEL_A_RS485 = 51, CHANNEL_B_RS485 = 52, CHANNEL_C_RS485 = 53,
    CHANNEL_D_RS485 = 54, RELEASE_NUMBER = 55, EXTERNAL_OSCILLATOR = 56,
    USER_DATA_ADDR = 57 }

enum ftdi_cbus_func 🎛️

enum ftdi_cbus_func { CBUS_TXDEN = 0, CBUS_PWREN = 1, CBUS_RXLED = 2,
    CBUS_TXLED = 3, CBUS_TXRXLED = 4, CBUS_SLEEP = 5, CBUS_CLK48 = 6,
    CBUS_CLK24 = 7, CBUS_CLK12 = 8, CBUS_CLK6 = 9, CBUS_IOMODE = 0xa,
    CBUS_BB_WR = 0xb, CBUS_BB_RD = 0xc }

enum ftdi_cbush_func 🧚

enum ftdi_cbush_func { CBUSH_TRISTATE = 0, CBUSH_TXLED = 1, CBUSH_RXLED
    = 2, CBUSH_TXRXLED = 3, CBUSH_PWREN = 4, CBUSH_SLEEP = 5,
    CBUSH_DRIVE_0 = 6, CBUSH_DRIVE1 = 7, CBUSH_IOMODE = 8, CBUSH_TXDEN =
    9, CBUSH_CLK30 = 10, CBUSH_CLK15 = 11, CBUSH_CLK7_5 = 12 }

enum ftdi_cbusx_func 🌟

enum ftdi_cbusx_func { CBUSX_TRISTATE = 0, CBUSX_TXLED = 1, CBUSX_RXLED
    = 2, CBUSX_TXRXLED = 3, CBUSX_PWREN = 4, CBUSX_SLEEP = 5,
    CBUSX_DRIVE_0 = 6, CBUSX_DRIVE1 = 7, CBUSX_IOMODE = 8, CBUSX_TXDEN =
    9, CBUSX_CLK24 = 10, CBUSX_CLK12 = 11, CBUSX_CLK6 = 12,
    CBUSX_BAT_DETECT = 13, CBUSX_BAT_DETECT_NEG = 14, CBUSX_I2C_TXE =
    15, CBUSX_I2C_RXF = 16, CBUSX_VBUS_SENSE = 17, CBUSX_BB_WR = 18,
    CBUSX_BB_RD = 19, CBUSX_TIME_STAMP = 20, CBUSX_AWAKE = 21 }

and that's the top half of the header, bestie — structs, macros, one callback typedef and a frankly unreasonable number of enums, all accounted for. 💜

🦋 FUNCTIONS 🦋

Okay bestie, buckle up — this is the whole roster, every single signature, no skips, no "etc." (the manpage does not do "etc." and neither do I 💅). Where the page gives us zero extra commentary, I'm not gonna invent any — signature only, that's the vibe check.

  • int ftdi_init (struct ftdi_context *ftdi) — the opening move 🎬
  • struct ftdi_context * ftdi_new (void) — returns a pointer to the context, so yes, it's giving "malloc energy" but I'm not saying anything the page didn't
  • int ftdi_set_interface (struct ftdi_context *ftdi, enum ftdi_interface interface) — sets the interface, and no I will not elaborate, the page didn't 🫶
  • int ftdi_set_module_detach_mode (struct ftdi_context *ftdi, enum ftdi_module_detach_mode mode) — takes a mode from enum ftdi_module_detach_mode
  • void ftdi_deinit (struct ftdi_context *ftdi) — returns nothing, cleans up vibes (that's literally all we know here, don't @ me)
  • void ftdi_free (struct ftdi_context *ftdi) — also void, also takes the context
  • void ftdi_set_usbdev (struct ftdi_context *ftdi, struct libusb_device_handle *usbdev) — hands it a struct libusb_device_handle *, iconique
  • struct ftdi_version_info ftdi_get_library_version (void) — ✨ Get libftdi library version. ✨ That's the actual description, straight from the page, and honestly it ate
  • int ftdi_usb_find_all (struct ftdi_context *ftdi, struct ftdi_device_list **devlist, int vendor, int product) — note the double pointer on devlist, she's a pointer-to-pointer, main character energy 💫
  • void ftdi_list_free (struct ftdi_device_list **devlist) — double pointer again 👀
  • void ftdi_list_free2 (struct ftdi_device_list *devlist) — yes there's a 2 and no she is not a sequel, she takes a single pointer, that's it
  • 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) — three buffers, three lengths, a whole little family 🌸
  • 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) — identical-looking signature to the one above, the 2 is doing all the differentiation work 😭
  • int ftdi_eeprom_get_strings (struct ftdi_context *ftdi, char *manufacturer, int mnf_len, char *product, int prod_len, char *serial, int serial_len) — same shape, but note it's product/prod_len here instead of description/desc_len 🎀
  • int ftdi_eeprom_set_strings (struct ftdi_context *ftdi, const char *manufacturer, const char *product, const char *serial) — all three const char *, setter vibes only
  • int ftdi_usb_open (struct ftdi_context *ftdi, int vendor, int product) — the classic, vendor plus product, periodt
  • int ftdi_usb_open_desc (struct ftdi_context *ftdi, int vendor, int product, const char *description, const char *serial) — now with description AND serial besties
  • int ftdi_usb_open_desc_index (struct ftdi_context *ftdi, int vendor, int product, const char *description, const char *serial, unsigned int index) — same but with an unsigned int index tacked on the end, she's the third-act plot twist 🦋
  • int ftdi_usb_open_bus_addr (struct ftdi_context *ftdi, uint8_t bus, uint8_t addr) — two uint8_ts, bus and addr, no notes
  • int ftdi_usb_open_dev (struct ftdi_context *ftdi, struct libusb_device *dev) — you're handing it the device yourself
  • int ftdi_usb_open_string (struct ftdi_context *ftdi, const char *description) — one string, one dream ✨
  • int ftdi_usb_close (struct ftdi_context *ftdi) — the goodbye, sad but necessary 😭
  • int ftdi_usb_reset (struct ftdi_context *ftdi) — the refresh button of the whole situation
  • int ftdi_tciflush (struct ftdi_context *ftdi) — note the spelling: tciflush, with the i in the middle, do NOT typo this 🫶
  • int ftdi_tcoflush (struct ftdi_context *ftdi) — tcoflush, o this time, they're siblings not twins
  • int ftdi_tcioflush (struct ftdi_context *ftdi) — tcioflush, the combo meal 🔥
  • int DEPRECATED (ftdi_usb_purge_rx_buffer(struct ftdi_context *ftdi)) — okay listen. The page literally wraps this one in DEPRECATED (...), so it is deprecated, capital letters, spelled out, do not build new stuff on it bestie 💀
  • int DEPRECATED (ftdi_usb_purge_tx_buffer(struct ftdi_context *ftdi)) — also DEPRECATED (...), also please don't
  • int DEPRECATED (ftdi_usb_purge_buffers(struct ftdi_context *ftdi)) — yep, this one too, DEPRECATED (...) and all
  • int ftdi_set_baudrate (struct ftdi_context *ftdi, int baudrate) — baudrate is an int, keep the exact name
  • int ftdi_set_line_property (struct ftdi_context *ftdi, enum ftdi_bits_type bits, enum ftdi_stopbits_type sbit, enum ftdi_parity_type parity) — note it's sbit for stopbits, not stopbits, respect the typo-adjacent naming 🙈
  • 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) — same three plus enum ftdi_break_type break_type, the 2 strikes again
  • int ftdi_read_data (struct ftdi_context *ftdi, unsigned char *buf, int size) — unsigned char *buf, int size
  • int ftdi_read_data_set_chunksize (struct ftdi_context *ftdi, unsigned int chunksize) — unsigned int chunksize, not int, don't get cute
  • int ftdi_read_data_get_chunksize (struct ftdi_context *ftdi, unsigned int *chunksize) — pointer this time, she writes back into your unsigned int
  • int ftdi_write_data (struct ftdi_context *ftdi, const unsigned char *buf, int size) — const on the buf, she's read-only and she knows it 💅
  • 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_readstream (struct ftdi_context *ftdi, FTDIStreamCallback *callback, void *userdata, int packetsPerTransfer, int numTransfers) — FTDIStreamCallback *callback and a void *userdata, and yes packetsPerTransfer is camelCase, copy it exactly 🎀
  • struct ftdi_transfer_control * ftdi_write_data_submit (struct ftdi_context *ftdi, unsigned char *buf, int size) — returns a struct ftdi_transfer_control *, spice level: async
  • struct ftdi_transfer_control * ftdi_read_data_submit (struct ftdi_context *ftdi, unsigned char *buf, int size) — same return type, reading flavour
  • int ftdi_transfer_data_done (struct ftdi_transfer_control *tc) — takes the tc pointer
  • void ftdi_transfer_data_cancel (struct ftdi_transfer_control *tc, struct timeval *to) — void return, and to is a struct timeval * ⏰
  • int ftdi_set_bitmode (struct ftdi_context *ftdi, unsigned char bitmask, unsigned char mode) — two unsigned chars, bitmask and mode
  • int ftdi_disable_bitbang (struct ftdi_context *ftdi) — "bitbang" is one word, iconic
  • int ftdi_read_pins (struct ftdi_context *ftdi, unsigned char *pins) — writes into pins 📍
  • int ftdi_set_latency_timer (struct ftdi_context *ftdi, unsigned char latency) — unsigned char latency
  • int ftdi_get_latency_timer (struct ftdi_context *ftdi, unsigned char *latency) — pointer version, obviously
  • int ftdi_poll_modem_status (struct ftdi_context *ftdi, unsigned short *status) — careful, it's unsigned short *status, not char, not int 🫶
  • int ftdi_setflowctrl (struct ftdi_context *ftdi, int flowctrl) — all one word, lowercase, no underscore, that's the brand
  • int ftdi_setflowctrl_xonxoff (struct ftdi_context *ftdi, unsigned char xon, unsigned char xoff) — now WITH an underscore and both xon and xoff
  • int ftdi_setdtr_rts (struct ftdi_context *ftdi, int dtr, int rts) — two ints, dtr then rts, in that order, don't flip them
  • int ftdi_setdtr (struct ftdi_context *ftdi, int state) — solo dtr
  • int ftdi_setrts (struct ftdi_context *ftdi, int state) — solo rts
  • int ftdi_set_event_char (struct ftdi_context *ftdi, unsigned char eventch, unsigned char enable) — eventch and enable, both unsigned char
  • int ftdi_set_error_char (struct ftdi_context *ftdi, unsigned char errorch, unsigned char enable) — errorch and enable, same deal
  • int ftdi_eeprom_initdefaults (struct ftdi_context *ftdi, const char *manufacturer, const char *product, const char *serial) — "initdefaults", one word, no underscore, I said what I said
  • int ftdi_eeprom_build (struct ftdi_context *ftdi)
  • int ftdi_eeprom_decode (struct ftdi_context *ftdi, int verbose) — there's a verbose int in there 👀
  • int ftdi_get_eeprom_value (struct ftdi_context *ftdi, enum ftdi_eeprom_value value_name, int *value) — value_name is the enum, value is the int *
  • int ftdi_set_eeprom_value (struct ftdi_context *ftdi, enum ftdi_eeprom_value value_name, int value) — same but int value, not a pointer, the get/set duality ate 🍓
  • 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) — const on this one, spot the difference bestie
  • int ftdi_set_eeprom_user_data (struct ftdi_context *ftdi, const char *buf, int size) — note this buf is plain const char *, not unsigned
  • int ftdi_read_eeprom (struct ftdi_context *ftdi)
  • int ftdi_read_chipid (struct ftdi_context *ftdi, unsigned int *chipid) — unsigned int *chipid, all lowercase, no underscore between chip and id
  • int ftdi_write_eeprom (struct ftdi_context *ftdi)
  • int ftdi_erase_eeprom (struct ftdi_context *ftdi) — ⚠️ "erase" is right there in the name, treat with respect
  • int ftdi_read_eeprom_location (struct ftdi_context *ftdi, int eeprom_addr, unsigned short *eeprom_val) — int eeprom_addr, unsigned short *eeprom_val
  • int ftdi_write_eeprom_location (struct ftdi_context *ftdi, int eeprom_addr, unsigned short eeprom_val) — pointer gone on the write version, that's the whole difference
  • const char * ftdi_get_error_string (struct ftdi_context *ftdi) — returns const char *, your little error poet ✨

✨ MACRO DEFINITION DOCUMENTATION ✨

Yes we're doing macros now and yes there are a LOT of them. All values copied character for character because that's the whole point 💖

🎀 The lonesome pragma 🎀

#define _Ftdi_Pragma( _msg) — her value is:

_Pragma(_msg)

Definition at line 30 of file ftdi.h. — noted, and young, and free 🦋

🔥 MPSSE flag bits 🔥

These are the little bit flags, and every single explanatory comment is staying exactly where it was:

  • #define MPSSE_WRITE_NEG 0x01 — comment: /* Write TDI/DO on negative TCK/SK edge*/ Definition at line 100 of file ftdi.h.
  • #define MPSSE_BITMODE 0x02 — comment: /* Write bits, not bytes */ Definition at line 101 of file ftdi.h.
  • #define MPSSE_READ_NEG 0x04 — comment: /* Sample TDO/DI on negative TCK/SK edge */ Definition at line 102 of file ftdi.h.
  • #define MPSSE_LSB 0x08 — comment: /* LSB first */ Definition at line 103 of file ftdi.h.
  • #define MPSSE_DO_WRITE 0x10 — comment: /* Write TDI/DO */ Definition at line 104 of file ftdi.h.
  • #define MPSSE_DO_READ 0x20 — comment: /* Read TDO/DI */ Definition at line 105 of file ftdi.h.
  • #define MPSSE_WRITE_TMS 0x40 — comment: /* Write TMS/CS */ Definition at line 106 of file ftdi.h.

⭐ The command opcodes ⭐

  • #define SET_BITS_LOW 0x80 — Definition at line 109 of file ftdi.h.
  • #define SET_BITS_HIGH 0x82 — Definition at line 112 of file ftdi.h. (and yes she's listed before GET_BITS_LOW down there — that's the page's order, not mine, don't come for me 🙈)
  • #define GET_BITS_LOW 0x81 — Definition at line 115 of file ftdi.h.
  • #define GET_BITS_HIGH 0x83 — Definition at line 116 of file ftdi.h.
  • #define LOOPBACK_START 0x84 — Definition at line 117 of file ftdi.h.
  • #define LOOPBACK_END 0x85 — Definition at line 118 of file ftdi.h.
  • #define TCK_DIVISOR 0x86 — Definition at line 119 of file ftdi.h.
  • #define DIS_DIV_5 0x8a — Definition at line 121 of file ftdi.h.
  • #define EN_DIV_5 0x8b — Definition at line 122 of file ftdi.h.
  • #define EN_3_PHASE 0x8c — Definition at line 123 of file ftdi.h.
  • #define DIS_3_PHASE 0x8d — Definition at line 124 of file ftdi.h.
  • #define CLK_BITS 0x8e — Definition at line 125 of file ftdi.h.
  • #define CLK_BYTES 0x8f — Definition at line 126 of file ftdi.h.
  • #define CLK_WAIT_HIGH 0x94 — Definition at line 127 of file ftdi.h.
  • #define CLK_WAIT_LOW 0x95 — Definition at line 128 of file ftdi.h.
  • #define EN_ADAPTIVE 0x96 — Definition at line 129 of file ftdi.h.
  • #define DIS_ADAPTIVE 0x97 — Definition at line 130 of file ftdi.h.
  • #define CLK_BYTES_OR_HIGH 0x9c — Definition at line 131 of file ftdi.h.
  • #define CLK_BYTES_OR_LOW 0x9d — Definition at line 132 of file ftdi.h.
  • #define DRIVE_OPEN_COLLECTOR 0x9e — Definition at line 134 of file ftdi.h.

🧚 The divisor macro (she's a whole expression) 🧚

#define DIV_VALUE( rate) — value is this exact beast:

(rate > 6000000)?0:((6000000/rate -1) > 0xffff)? 0xffff: (6000000/rate -1)

Definition at line 137 of file ftdi.h. — nested ternaries, three of them, she's dramatic and I respect it 💅

🌈 The remaining opcodes 🌈

  • #define SEND_IMMEDIATE 0x87 — Definition at line 140 of file ftdi.h.
  • #define WAIT_ON_HIGH 0x88 — Definition at line 141 of file ftdi.h.
  • #define WAIT_ON_LOW 0x89 — Definition at line 142 of file ftdi.h.
  • #define READ_SHORT 0x90 — Definition at line 145 of file ftdi.h.
  • #define READ_EXTENDED 0x91 — Definition at line 147 of file ftdi.h.
  • #define WRITE_SHORT 0x92 — Definition at line 150 of file ftdi.h.
  • #define WRITE_EXTENDED 0x93 — Definition at line 152 of file ftdi.h.

💜 The SIO request codes 💜

  • #define SIO_RESET 0 — comment: /* Reset the port */ Definition at line 157 of file ftdi.h.
  • #define SIO_MODEM_CTRL 1 — comment: /* Set the modem control register */ Definition at line 158 of file ftdi.h.
  • #define SIO_SET_FLOW_CTRL 2 — comment: /* Set flow control register */ Definition at line 159 of file ftdi.h.
  • #define SIO_SET_BAUD_RATE 3 — comment: /* Set baud rate */ Definition at line 160 of file ftdi.h.
  • #define SIO_SET_DATA 4 — comment: /* Set the data characteristics of the port */ Definition at line 161 of file ftdi.h.

👑 The request types (with receipts) 👑

#define FTDI_DEVICE_OUT_REQTYPE — the value, wrapped exactly like this:

(LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE | LIBUSB_ENDPOINT_OUT)

Definition at line 163 of file ftdi.h. And the page lists exactly who references her, so here's the full squad, no cuts:

  • ftdi_disable_bitbang()
  • ftdi_erase_eeprom()
  • ftdi_set_baudrate()
  • ftdi_set_bitmode()
  • ftdi_set_error_char()
  • ftdi_set_event_char()
  • ftdi_set_latency_timer()
  • ftdi_set_line_property2()
  • ftdi_setdtr()
  • ftdi_setdtr_rts()
  • ftdi_setflowctrl()
  • ftdi_setflowctrl_xonxoff()
  • ftdi_setrts()
  • ftdi_tciflush()
  • ftdi_tcoflush()
  • ftdi_usb_purge_rx_buffer()
  • ftdi_usb_purge_tx_buffer()
  • ftdi_usb_reset()
  • ftdi_write_eeprom()
  • ftdi_write_eeprom_location()

#define FTDI_DEVICE_IN_REQTYPE — the value:

(LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE | LIBUSB_ENDPOINT_IN)

Definition at line 164 of file ftdi.h. Only difference from her sibling up there is IN vs OUT at the end, that's the whole plot twist 🦋 Referenced by:

  • ftdi_get_latency_timer()
  • ftdi_poll_modem_status()
  • ftdi_read_chipid()
  • ftdi_read_eeprom()
  • ftdi_read_eeprom_location()
  • ftdi_read_pins()

#define SIO_RESET_REQUEST SIO_RESET — she's just an alias, lowkey minimal of her. Definition at line 167 of file ftdi.h. Referenced by:

  • ftdi_tciflush()
  • ftdi_tcoflush()
  • ftdi_usb_purge_rx_buffer()
  • ftdi_usb_purge_tx_buffer()
  • ftdi_usb_reset()

🦋 SIO_SET_BAUDRATE_REQUEST

#define SIO_SET_BAUDRATE_REQUEST   SIO_SET_BAUD_RATE

Definition at line 168 of file ftdi.h.

Referenced by ftdi_set_baudrate().


🦋 SIO_SET_DATA_REQUEST

#define SIO_SET_DATA_REQUEST   SIO_SET_DATA

Definition at line 169 of file ftdi.h.

Referenced by ftdi_set_line_property2().


🦋 SIO_SET_FLOW_CTRL_REQUEST

#define SIO_SET_FLOW_CTRL_REQUEST   SIO_SET_FLOW_CTRL

Definition at line 170 of file ftdi.h.

Referenced by ftdi_setflowctrl(), and ftdi_setflowctrl_xonxoff().


🦋 SIO_SET_MODEM_CTRL_REQUEST

#define SIO_SET_MODEM_CTRL_REQUEST   SIO_MODEM_CTRL

Definition at line 171 of file ftdi.h.

Referenced by ftdi_setdtr(), ftdi_setdtr_rts(), and ftdi_setrts().


🦋 SIO_POLL_MODEM_STATUS_REQUEST

#define SIO_POLL_MODEM_STATUS_REQUEST   0x05

Definition at line 172 of file ftdi.h.

Referenced by ftdi_poll_modem_status().


🦋 SIO_SET_EVENT_CHAR_REQUEST

#define SIO_SET_EVENT_CHAR_REQUEST   0x06

Definition at line 173 of file ftdi.h.

Referenced by ftdi_set_event_char().


🦋 SIO_SET_ERROR_CHAR_REQUEST

#define SIO_SET_ERROR_CHAR_REQUEST   0x07

Definition at line 174 of file ftdi.h.

Referenced by ftdi_set_error_char().


🦋 SIO_SET_LATENCY_TIMER_REQUEST

#define SIO_SET_LATENCY_TIMER_REQUEST   0x09

Definition at line 175 of file ftdi.h.

Referenced by ftdi_set_latency_timer().


🦋 SIO_GET_LATENCY_TIMER_REQUEST

#define SIO_GET_LATENCY_TIMER_REQUEST   0x0A

Definition at line 176 of file ftdi.h.

Referenced by ftdi_get_latency_timer().


🦋 SIO_SET_BITMODE_REQUEST

#define SIO_SET_BITMODE_REQUEST   0x0B

Definition at line 177 of file ftdi.h.

Referenced by ftdi_disable_bitbang(), and ftdi_set_bitmode().


🦋 SIO_READ_PINS_REQUEST

#define SIO_READ_PINS_REQUEST   0x0C

Definition at line 178 of file ftdi.h.

Referenced by ftdi_read_pins().


🦋 SIO_READ_EEPROM_REQUEST

#define SIO_READ_EEPROM_REQUEST   0x90

Definition at line 179 of file ftdi.h.

Referenced by ftdi_read_chipid(), ftdi_read_eeprom(), and ftdi_read_eeprom_location().


🦋 SIO_WRITE_EEPROM_REQUEST

#define SIO_WRITE_EEPROM_REQUEST   0x91

Definition at line 180 of file ftdi.h.

Referenced by ftdi_erase_eeprom(), ftdi_write_eeprom(), and ftdi_write_eeprom_location().


🦋 SIO_ERASE_EEPROM_REQUEST

#define SIO_ERASE_EEPROM_REQUEST   0x92

Definition at line 181 of file ftdi.h.

Referenced by ftdi_erase_eeprom().


🎀 SIO_RESET_SIO

#define SIO_RESET_SIO   0

Definition at line 184 of file ftdi.h.

Referenced by ftdi_usb_reset().


🎀 SIO_RESET_PURGE_RX

#define SIO_RESET_PURGE_RX   1

Definition at line 218 of file ftdi.h.

Referenced by ftdi_usb_purge_rx_buffer().


🎀 SIO_RESET_PURGE_TX

#define SIO_RESET_PURGE_TX   2

Definition at line 219 of file ftdi.h.

Referenced by ftdi_usb_purge_tx_buffer().


🎀 SIO_TCIFLUSH

#define SIO_TCIFLUSH   2

Definition at line 222 of file ftdi.h.

Referenced by ftdi_tciflush().


🎀 SIO_TCOFLUSH

#define SIO_TCOFLUSH   1

Definition at line 223 of file ftdi.h.

Referenced by ftdi_tcoflush().


💅 flow control vibes, bestie

SIO_DISABLE_FLOW_CTRL is literally her whole personality — definition at line 225 of file ftdi.h:

#define SIO_DISABLE_FLOW_CTRL   0x0

Then the three handshake options, all doing that cute << 8 shift:

  • SIO_RTS_CTS_HS — #define SIO_RTS_CTS_HS (0x1 << 8), definition at line 226 of file ftdi.h.
  • SIO_DTR_DSR_HS — #define SIO_DTR_DSR_HS (0x2 << 8), definition at line 227 of file ftdi.h.
  • SIO_XON_XOFF_HS — #define SIO_XON_XOFF_HS (0x4 << 8), definition at line 228 of file ftdi.h. Referenced by ftdi_setflowctrl_xonxoff().

💅 the DTR / RTS masks, aka "which pin are we even talking about"

First the DTR squad:

  • SIO_SET_DTR_MASK — #define SIO_SET_DTR_MASK 0x1, definition at line 230 of file ftdi.h.
  • SIO_SET_DTR_HIGH — #define SIO_SET_DTR_HIGH ( 1 | ( SIO_SET_DTR_MASK << 8)), definition at line 231 of file ftdi.h. Referenced by ftdi_setdtr(), and ftdi_setdtr_rts().
  • SIO_SET_DTR_LOW — #define SIO_SET_DTR_LOW ( 0 | ( SIO_SET_DTR_MASK << 8)), definition at line 232 of file ftdi.h. Referenced by ftdi_setdtr(), and ftdi_setdtr_rts().

Then the RTS girlies:

  • SIO_SET_RTS_MASK — #define SIO_SET_RTS_MASK 0x2, definition at line 233 of file ftdi.h.
  • SIO_SET_RTS_HIGH — #define SIO_SET_RTS_HIGH ( 2 | ( SIO_SET_RTS_MASK << 8 )), definition at line 234 of file ftdi.h. Referenced by ftdi_setdtr_rts(), and ftdi_setrts().
  • SIO_SET_RTS_LOW — #define SIO_SET_RTS_LOW ( 0 | ( SIO_SET_RTS_MASK << 8 )), definition at line 235 of file ftdi.h. Referenced by ftdi_setdtr_rts(), and ftdi_setrts().
no cap, SIO_RTS_CTS_HS shows up again right after this with the exact same value #define SIO_RTS_CTS_HS (0x1 << 8), definition at line 226 of file ftdi.h. Same line number, same everything — the docs just list it twice and we're not gonna pretend otherwise 💀

#define FTDI_URB_USERCONTEXT_COOKIE   ((void *)0x1)

Definition at line 241 of file ftdi.h.


💀 DEPRECATED

Value:

func

Definition at line 252 of file ftdi.h.


🧚 FT1284 + power save crew (EEPROM-adjacent, highkey iconic)

  • FT1284_CLK_IDLE_STATE — #define FT1284_CLK_IDLE_STATE 0x01, definition at line 401 of file ftdi.h. Referenced by ftdi_eeprom_build(), and ftdi_eeprom_decode().
  • FT1284_DATA_LSB — #define FT1284_DATA_LSB 0x02 /* DS_FT232H 1.3 amd ftd2xx.h 1.0.4 disagree here*/, definition at line 402 of file ftdi.h. Referenced by ftdi_eeprom_build(), and ftdi_eeprom_decode().
  • FT1284_FLOW_CONTROL — #define FT1284_FLOW_CONTROL 0x04, definition at line 403 of file ftdi.h. Referenced by ftdi_eeprom_build(), and ftdi_eeprom_decode().
  • POWER_SAVE_DISABLE_H — #define POWER_SAVE_DISABLE_H 0x80, definition at line 404 of file ftdi.h. Referenced by ftdi_eeprom_build(), and ftdi_eeprom_decode().
  • USE_SERIAL_NUM — #define USE_SERIAL_NUM 0x08, definition at line 406 of file ftdi.h. Referenced by ftdi_eeprom_build(), and ftdi_eeprom_decode().

🌸 the INVERT squad — one bit per pin, living their truth

Every single one of these means exactly what it says: invert that line ✨

  • INVERT_TXD — #define INVERT_TXD 0x01, Invert TXD#, definition at line 431 of file ftdi.h.
  • INVERT_RXD — #define INVERT_RXD 0x02, Invert RXD#, definition at line 433 of file ftdi.h.
  • INVERT_RTS — #define INVERT_RTS 0x04, Invert RTS#, definition at line 435 of file ftdi.h.
  • INVERT_CTS — #define INVERT_CTS 0x08, Invert CTS#, definition at line 437 of file ftdi.h.
  • INVERT_DTR — #define INVERT_DTR 0x10, Invert DTR#, definition at line 439 of file ftdi.h.
  • INVERT_DSR — #define INVERT_DSR 0x20, Invert DSR#, definition at line 441 of file ftdi.h.
  • INVERT_DCD — #define INVERT_DCD 0x40, Invert DCD#, definition at line 443 of file ftdi.h.
  • INVERT_RI — #define INVERT_RI 0x80, Invert RI#, definition at line 445 of file ftdi.h.

🌈 interface modes — pick your channel's whole aesthetic

The header labels this whole family Interface Mode. and honestly, main character energy:

  • CHANNEL_IS_UART — #define CHANNEL_IS_UART 0x0, definition at line 448 of file ftdi.h.
  • CHANNEL_IS_FIFO — #define CHANNEL_IS_FIFO 0x1, definition at line 449 of file ftdi.h.
  • CHANNEL_IS_OPTO — #define CHANNEL_IS_OPTO 0x2, definition at line 450 of file ftdi.h.
  • CHANNEL_IS_CPU — #define CHANNEL_IS_CPU 0x4, definition at line 451 of file ftdi.h.
  • CHANNEL_IS_FT1284 — #define CHANNEL_IS_FT1284 0x8, definition at line 452 of file ftdi.h.
  • CHANNEL_IS_RS485 — #define CHANNEL_IS_RS485 0x10, definition at line 454 of file ftdi.h. Referenced by ftdi_eeprom_build(), and ftdi_eeprom_decode().

🍓 drive strength + slew + schmitt — the electrical slay

  • DRIVE_4MA — #define DRIVE_4MA 0, definition at line 456 of file ftdi.h.
  • DRIVE_8MA — #define DRIVE_8MA 1, definition at line 457 of file ftdi.h.
  • DRIVE_12MA — #define DRIVE_12MA 2, definition at line 458 of file ftdi.h.
  • DRIVE_16MA — #define DRIVE_16MA 3, definition at line 459 of file ftdi.h. Referenced by ftdi_eeprom_build(), and ftdi_eeprom_decode().
  • SLOW_SLEW — #define SLOW_SLEW 4, definition at line 460 of file ftdi.h. Referenced by ftdi_eeprom_build(), and ftdi_eeprom_decode().
  • IS_SCHMITT — #define IS_SCHMITT 8, definition at line 461 of file ftdi.h. Referenced by ftdi_eeprom_build(), and ftdi_eeprom_decode().

👑 driver types + the rest of the EEPROM bit crew

Driver Type. is the label up top, and here's the lineup:

  • DRIVER_VCP — #define DRIVER_VCP 0x08, definition at line 464 of file ftdi.h. Referenced by ftdi_eeprom_build(), and ftdi_eeprom_decode().
  • DRIVER_VCPH — #define DRIVER_VCPH 0x10 /* FT232H has moved the VCP bit */, definition at line 465 of file ftdi.h. Referenced by ftdi_eeprom_build(), and ftdi_eeprom_decode().
  • USE_USB_VERSION_BIT — #define USE_USB_VERSION_BIT 0x10, definition at line 467 of file ftdi.h. Referenced by ftdi_eeprom_build(), and ftdi_eeprom_decode().
  • SUSPEND_DBUS7_BIT — #define SUSPEND_DBUS7_BIT 0x80, definition at line 469 of file ftdi.h. Referenced by ftdi_eeprom_build(), and ftdi_eeprom_decode().

And the high-current drive duo, labeled High current drive. in the header:

  • HIGH_CURRENT_DRIVE — #define HIGH_CURRENT_DRIVE 0x10, definition at line 472 of file ftdi.h. Referenced by ftdi_eeprom_build(), and ftdi_eeprom_decode().
  • HIGH_CURRENT_DRIVE_R — #define HIGH_CURRENT_DRIVE_R 0x04, definition at line 473 of file ftdi.h. Referenced by ftdi_eeprom_build(), and ftdi_eeprom_decode().

✨ Typedef Documentation ✨

💖 FTDIStreamCallback

typedef int FTDIStreamCallback(uint8_t *buffer, int length, FTDIProgressInfo *progress, void *userdata)

Definition at line 494 of file ftdi.h.

✨ ENUMERATION TYPE DOCUMENTATION ✨

okay bestie, this whole part is literally just enums — the little named constants that tell libftdi what chip you're on, what parity you want, what bitbang mode to vibe in, and all that good stuff. every single one is here, no cap. 💅

enum ftdi_chip_type

this one is exactly what it says on the tin: FTDI chip type. that's it. that's the enum. 🫶

  • TYPE_AM
  • TYPE_BM
  • TYPE_2232C
  • TYPE_R
  • TYPE_2232H
  • TYPE_4232H
  • TYPE_232H
  • TYPE_230X

Definition at line 46 of file ftdi.h.

enum ftdi_parity_type

Parity mode for ftdi_set_line_property() — so when you're setting up your serial line, this is the parity vibe check. 🌈

  • NONE
  • ODD
  • EVEN
  • MARK
  • SPACE

Definition at line 58 of file ftdi.h.

enum ftdi_stopbits_type

Number of stop bits for ftdi_set_line_property() — how many stop bits are we sending? this enum has the answer. 🎀

  • STOP_BIT_1
  • STOP_BIT_15
  • STOP_BIT_2

Definition at line 60 of file ftdi.h.

enum ftdi_bits_type

Number of bits for ftdi_set_line_property() — 7 or 8, pick your fighter. ✨

  • BITS_7
  • BITS_8

Definition at line 62 of file ftdi.h.

enum ftdi_break_type

Break type for ftdi_set_line_property2() — break on or break off, that is the question. 💀

  • BREAK_OFF
  • BREAK_ON

Definition at line 64 of file ftdi.h.

enum ftdi_mpsse_mode

MPSSE bitbang modes — this is the main character enum for all the bitbang modes, and each one has its own little lore. 👑

  • BITMODE_RESET — switch off bitbang mode, back to regular serial/FIFO. it's giving "reset era". 🔄
  • BITMODE_BITBANG — classical asynchronous bitbang mode, introduced with B-type chips. old school but iconic. 💅
  • BITMODE_MPSSE — MPSSE mode, available on 2232x chips. the fancy one. ✨
  • BITMODE_SYNCBB — synchronous bitbang mode, available on 2232x and R-type chips. sync up bestie. 🦋
  • BITMODE_MCU — MCU Host Bus Emulation mode, available on 2232x chips. emulation station. 🎮
  • BITMODE_OPTO — Fast Opto-Isolated Serial Interface Mode, available on 2232x chips. isolated and fast, we love to see it. 🏃‍♀️
  • BITMODE_CBUS — Bitbang on CBUS pins of R-type chips, configure in EEPROM before. yes, you gotta configure it in EEPROM first, no skipping. 📝
  • BITMODE_SYNCFF — Single Channel Synchronous FIFO mode, available on 2232H chips. fifo? more like fi-yes. 🍓
  • BITMODE_FT1284 — FT1284 mode, available on 232H chips. 1284 mode has entered the chat. 💬

Definition at line 67 of file ftdi.h.

enum ftdi_interface

Port interface for chips with multiple interfaces — for when your chip has more than one interface and you need to pick your fave. 🌸

  • INTERFACE_ANY
  • INTERFACE_A
  • INTERFACE_B
  • INTERFACE_C
  • INTERFACE_D

Definition at line 82 of file ftdi.h.

enum ftdi_module_detach_mode

Automatic loading / unloading of kernel modules — this enum controls whether we auto-detach the kernel module or not. very "let me do my own thing" energy. 🧚

  • AUTO_DETACH_SIO_MODULE
  • DONT_DETACH_SIO_MODULE
  • AUTO_DETACH_REATACH_SIO_MODULE

Definition at line 92 of file ftdi.h.

enum ftdi_eeprom_value

List all handled EEPROM values. Append future new values only at the end to provide API/ABI stability — okay so this enum is literally every EEPROM value libftdi handles. important vibe: append future new values only at the end so the API/ABI stays stable, periodt. 🔥

  • VENDOR_ID
  • PRODUCT_ID
  • SELF_POWERED
  • REMOTE_WAKEUP
  • IS_NOT_PNP
  • SUSPEND_DBUS7
  • IN_IS_ISOCHRONOUS
  • OUT_IS_ISOCHRONOUS
  • SUSPEND_PULL_DOWNS
  • USE_SERIAL
  • USB_VERSION
  • USE_USB_VERSION
  • MAX_POWER
  • CHANNEL_A_TYPE
  • CHANNEL_B_TYPE
  • CHANNEL_A_DRIVER
  • CHANNEL_B_DRIVER
  • 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
  • HIGH_CURRENT
  • HIGH_CURRENT_A
  • HIGH_CURRENT_B
  • INVERT
  • GROUP0_DRIVE
  • GROUP0_SCHMITT
  • GROUP0_SLEW
  • GROUP1_DRIVE
  • GROUP1_SCHMITT
  • GROUP1_SLEW
  • GROUP2_DRIVE
  • GROUP2_SCHMITT
  • GROUP2_SLEW
  • GROUP3_DRIVE
  • GROUP3_SCHMITT
  • GROUP3_SLEW
  • CHIP_SIZE
  • CHIP_TYPE
  • POWER_SAVE
  • CLOCK_POLARITY
  • DATA_ORDER
  • FLOW_CONTROL
  • CHANNEL_C_DRIVER
  • CHANNEL_D_DRIVER
  • CHANNEL_A_RS485
  • CHANNEL_B_RS485
  • CHANNEL_C_RS485
  • CHANNEL_D_RS485
  • RELEASE_NUMBER
  • EXTERNAL_OSCILLATOR
  • USER_DATA_ADDR

Definition at line 329 of file ftdi.h.

enum ftdi_cbus_func

no description given, just the CBUS function constants. slay. 💅

  • CBUS_TXDEN
  • CBUS_PWREN
  • CBUS_RXLED
  • CBUS_TXLED
  • CBUS_TXRXLED
  • CBUS_SLEEP
  • CBUS_CLK48
  • CBUS_CLK24
  • CBUS_CLK12
  • CBUS_CLK6
  • CBUS_IOMODE
  • CBUS_BB_WR
  • CBUS_BB_RD

Definition at line 407 of file ftdi.h.

enum ftdi_cbush_func

again, no description, just the CBUSH constants. keep scrolling bestie. 🦋

  • CBUSH_TRISTATE
  • CBUSH_TXLED
  • CBUSH_RXLED
  • CBUSH_TXRXLED
  • CBUSH_PWREN
  • CBUSH_SLEEP
  • CBUSH_DRIVE_0
  • CBUSH_DRIVE1
  • CBUSH_IOMODE
  • CBUSH_TXDEN
  • CBUSH_CLK30
  • CBUSH_CLK15
  • CBUSH_CLK7_5

Definition at line 414 of file ftdi.h.

enum ftdi_cbusx_func

and finally the CBUSX constants. no description, but they're all here. 🌟

  • CBUSX_TRISTATE
  • CBUSX_TXLED
  • CBUSX_RXLED
  • CBUSX_TXRXLED
  • CBUSX_PWREN
  • CBUSX_SLEEP
  • CBUSX_DRIVE_0
  • CBUSX_DRIVE1
  • CBUSX_IOMODE
  • CBUSX_TXDEN
  • CBUSX_CLK24
  • CBUSX_CLK12
  • CBUSX_CLK6
  • CBUSX_BAT_DETECT
  • CBUSX_BAT_DETECT_NEG
  • CBUSX_I2C_TXE
  • CBUSX_I2C_RXF
  • CBUSX_VBUS_SENSE
  • CBUSX_BB_WR
  • CBUSX_BB_RD
  • CBUSX_TIME_STAMP
  • CBUSX_AWAKE

Definition at line 421 of file ftdi.h.


🛠️ FUNCTION DOCUMENTATION 🛠️

okay now we're getting into the actual functions. these are the ones you'll be calling in your code, so pay attention bestie. 💖

int ftdi_init (struct ftdi_context * ftdi)

Initializes a ftdi_context. — it sets everything up so you can actually use libftdi. think of it as the "getting ready" montage. 🎬

Parameters

  • ftdi — pointer to ftdi_context

Return values

  • 0 — all fine
  • -1 — couldn't allocate read buffer
  • -2 — couldn't allocate struct buffer
  • -3 — libusb_init() failed

Remarks

This should be called before all functions. like, literally all of them. don't skip this step. 🙈

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 )

Allocate and initialize a new ftdi_context — this is the "give me a fresh context" function. it does the alloc and the init in one go. ✨

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)

Open selected channels on a chip, otherwise use first channel. — so if your chip has multiple interfaces, you can pick which one you want. otherwise it just uses the first one. main character energy. 👑

Parameters

  • ftdi — pointer to ftdi_context
  • interface — Interface to use for FT2232C/2232H/4232H chips.

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().

int ftdi_set_module_detach_mode (struct ftdi_context * ftdi, enum ftdi_module_detach_mode mode)

Set module detach mode. — controls whether libftdi auto-detaches the kernel module or not. very "i'll handle it myself" vibes. 🧚

Parameters

  • ftdi — pointer to ftdi_context
  • mode — 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.

void ftdi_deinit (struct ftdi_context * ftdi)

Deinitializes a ftdi_context. — cleans things up, frees the buffers, says goodbye. 🫶

Parameters

  • ftdi — pointer to ftdi_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. — the full cleanup: deinit first, then free. don't forget to call this or you'll leak, bestie. 😭

Parameters

  • ftdi — pointer to ftdi_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. — if you already have a libusb_device_handle open, you can pass it in here. sharing is caring. 🫶

Parameters

  • ftdi — pointer to ftdi_context
  • usb — libusb libusb_device_handle to 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 libftdi library version. — returns the version info struct so you know what you're working with. iconic. 🌈

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 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) — okay so this scans the usb bus for every ftdi device matching your VID:PID. it creates a fresh ftdi_device_list that you must deallocate with ftdi_list_free() after you're done, k? and if you pass VID:PID 0:0, it searches for the default devices: 0x403:0x6001, 0x403:0x6010, 0x403:0x6011, 0x403:0x6014, 0x403:0x6015. 💅

Parameters

  • 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

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. — pass in the list you got from ftdi_usb_find_all() and it cleans it up. bye bye list. 👋

Parameters

  • devlist — USB device list created by ftdi_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. — same energy as ftdi_list_free() but takes the list directly instead of a pointer to a pointer. still frees it. 🦋

Parameters

  • devlist — USB device list created by ftdi_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. — grabs the manufacturer, description, and serial strings from the 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 with ftdi_usb_find_all() as it closes the internal "usb_dev" after use. so don't call it on its own, bestie. 💀

Parameters — and like, every single one matters, no skipping:

  • 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

Return values, aka the vibe check results 💅

  • 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)

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. cute little string fetcher, one might say 🎀

The parameters manufacturer, description and serial may be NULL or pointer to buffers to store the fetched strings. so like, pass NULL if you literally don't care, bestie, it's fine.

Note — the old function ftdi_usb_get_strings() always closes the device. This version only closes the device if it was opened by it. iconique behaviour honestly, we love a function that cleans up after itself and nobody else 🙌

Parameters:

  • 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

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_eeprom_get_strings (struct ftdi_context * ftdi, char * manufacturer, int mnf_len, char * product, int prod_len, char * serial, int serial_len)

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, so like, plug it in first bestie 🔌

The parameters manufacturer, description and serial may be NULL or pointer to buffers to store the fetched strings.

Parameters:

  • ftdi — pointer to ftdi_context
  • manufacturer — store manufacturer string here if not NULL
  • mnf_len — buffer size of manufacturer string
  • product — store product description string here if not NULL
  • prod_len — buffer size of product description string
  • serial — store serial string here if not NULL
  • serial_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.


int ftdi_eeprom_set_strings (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)

ngl the original gives us literally no blurb for this one — no description, no return values, just the receipts. so here's exactly that, no invented lore 🫶

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_usb_open (struct ftdi_context * ftdi, int vendor, int product)

int ftdi_usb_open (struct ftdi_context * ftdi, int vendor, int product)

Opens the first device with a given vendor and product ids. first come first served energy, she's not picky 💅

Parameters:

  • ftdi — pointer to ftdi_context
  • vendor — Vendor ID
  • product — 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)

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. the full glow-up filter: four criteria, one match, slay 🔥

Parameters:

  • 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.

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)

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. so when there's like five of the same device plugged in and you gotta pick one — main character selection screen fr fr 👑

Parameters:

  • 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.
  • index — Number of matching device to open if there are more than one, starts with 0.

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)

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. like giving someone the exact coordinates of the device instead of describing it 🗺️

Parameters:

  • ftdi — pointer to ftdi_context
  • bus — Bus number
  • addr — Device address

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 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_dev (struct ftdi_context * ftdi, libusb_device * dev)

int ftdi_usb_open_dev (struct ftdi_context * ftdi, libusb_device * dev)

Opens a ftdi device given by an usb_device. you already got the device object? hand it over, she'll take it from here 🫴

Parameters:

  • ftdi — pointer to ftdi_context
  • dev — libusb usb_dev to 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_string (struct ftdi_context * ftdi, const char * description)

int ftdi_usb_open_string (struct ftdi_context * ftdi, const char * description)

Opens the ftdi-device described by a description-string. Intended to be used for parsing a device-description given as commandline argument. so like, someone types a little string in the terminal and this function decodes the whole mood 🎀

Parameters:

  • ftdi — pointer to ftdi_context
  • description — 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 with 0) if there are more than one
    • s:<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 syntax, bestie, it could grow 👀

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_close (struct ftdi_context * ftdi)

int ftdi_usb_close (struct ftdi_context * ftdi)

Closes the ftdi device. Call ftdi_deinit() if you're cleaning up. like, closing the tab vs actually shutting the laptop down — know the difference 💅

Parameters:

  • ftdi — pointer to ftdi_context

Return values:

  • 0 — all fine 💖
  • -1 — usb_release failed
  • -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 ftdi_usb_reset (struct ftdi_context * ftdi)

int ftdi_usb_reset (struct ftdi_context * ftdi)

Resets the ftdi device.

okay so picking up right where we left off — here's the deets for that reset function 💅

  • ftdi — pointer to ftdi_context

Return values — read 'em and weep (lovingly):

  • 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, the actually-right way to do it, not the fake way 🧚

  • ftdi — pointer to ftdi_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_tcoflush (struct ftdi_context * ftdi)

Clears the write buffer on the chip. This is correct behavior for a TX flush — same energy as above but for the other direction 🦋

  • ftdi — pointer to ftdi_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_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 overachiever of the flush family, honestly iconic 👑

  • ftdi — pointer to ftdi_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 DEPRECATED (ftdi_usb_purge_rx_buffer(struct ftdi_context *ftdi) )

int DEPRECATED (ftdi_usb_purge_tx_buffer(struct ftdi_context *ftdi) )

int DEPRECATED (ftdi_usb_purge_buffers(struct ftdi_context *ftdi) )

These three come pre-labeled DEPRECATED, bestie — the DEPRECATED is literally baked into the signature, so it's not even subtle 🙈 The page lists them just like this and gives no further deets, no parameters, no return values, nothing. Deprecated means deprecated: don't go building new stuff on these.


int ftdi_set_baudrate (struct ftdi_context * ftdi, int baudrate)

Sets the chip baud rate — your speed dial, literally 🏎️

  • ftdi — pointer to ftdi_context
  • baudrate — 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: the break type can only be set via ftdi_set_line_property2() and it defaults to "off" — so if you're wondering where break went, it's over there 👀

  • ftdi — pointer to ftdi_context
  • bits — Number of bits
  • sbit — Number of stop bits
  • parity — 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 — this is the deluxe version that actually lets you pick the break type 💖

  • ftdi — pointer to ftdi_context
  • bits — Number of bits
  • sbit — Number of stop bits
  • parity — Parity mode
  • break_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_read_data (struct ftdi_context * ftdi, unsigned char * buf, int size)

Reads data in chunks (see ftdi_read_data_set_chunksize()) from the chip 🍓

It automatically strips the two modem status bytes that get transferred during every read — not you having to deal with those, bestie, it's handled 😌

  • ftdi — pointer to ftdi_context
  • buf — Buffer to store data in
  • size — Size of the buffer

Return values:

  • -666 — USB device unavailable 💀
  • <0 — error code from libusb_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().

int ftdi_read_data_set_chunksize (struct ftdi_context * ftdi, unsigned int chunksize)

Configure read buffer chunk size. Default is 4096 🎀

It automatically reallocates the buffer for you — no manual memory chores, we love a self-sufficient function.

  • ftdi — pointer to ftdi_context
  • chunksize — 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().

int ftdi_read_data_get_chunksize (struct ftdi_context * ftdi, unsigned int * chunksize)

Get read buffer chunk size — the lowercase-g getter to the uppercase-S setter above 🌸

  • ftdi — pointer to ftdi_context
  • chunksize — 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().

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 — the sending-side twin of ftdi_read_data() 🦋

  • ftdi — pointer to ftdi_context
  • buf — Buffer with the data
  • size — Size of the buffer

Return values:

  • -666 — USB device unavailable 💀
  • <0 — error code from usb_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().

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

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().

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

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().


int ftdi_readstream (struct ftdi_context * ftdi, FTDIStreamCallback * callback, void * userdata, int packetsPerTransfer, int numTransfers)

Streaming reading of data from the device — this is the main-character high-performance one 👑

It uses async transfers in libusb-1.0 to stream data from a device interface back to the PC at speed. It keeps transferring continuously until either an error happens or the callback returns a nonzero value. Then it returns a libusb error code or whatever the callback returned — so the return value is a lil' bit of both worlds, iykyk 💅

For every contiguous block of received data, the callback gets invoked.

  • ftdi — pointer to ftdi_context
  • callback — to user supplied function for one block of data
  • userdata — (listed with no description, so no notes from me 🔥)
  • packetsPerTransfer — number of packets per transfer
  • numTransfers — Number of transfers per callback

Definition at line 151 of file ftdi_stream.c.

References: FTDIStreamState::activity, BITMODE_RESET, BITMODE_SYNCFF, FTDIStreamState::callback, FTDIProgressInfo::current, FTDIProgressInfo::currentRate, FTDIProgressInfo::first, ftdi_get_error_string(), ftdi_set_bitmode(), ftdi_tcioflush(), ftdi_context::max_packet_size, ftdi_context::out_ep, FTDIProgressInfo::prev, FTDIStreamState::progress, FTDIStreamState::result, size_and_time::time, size_and_time::totalBytes, FTDIProgressInfo::totalRate, FTDIProgressInfo::totalTime, ftdi_context::type, TYPE_2232H, TYPE_232H, ftdi_context::usb_ctx, ftdi_context::usb_dev, ftdi_context::usb_read_timeout, and FTDIStreamState::userdata.

struct ftdi_transfer_control * ftdi_write_data_submit (struct ftdi_context * ftdi, unsigned char * buf, int size)

Writes data to the chip — but bestie, listen: it does not wait for the transfer to complete, and it does not make sure the transfer was successful. It's fire-and-forget, so don't come crying if you needed confirmation 😭

It uses the libusb 1.0 asynchronous API.

  • ftdi — pointer to ftdi_context
  • buf — Buffer with the data
  • size — Size of the buffer

Return values:

  • NULL — Some error happens when submit transfer 💀
  • !NULL — Pointer to a ftdi_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.

struct ftdi_transfer_control * ftdi_read_data_submit (struct ftdi_context * ftdi, unsigned char * buf, int size)

Reads data from the chip. Same deal as its write twin: it does not wait for completion and does not confirm the transfer actually worked 🙈

It uses the libusb 1.0 asynchronous API.

  • Parameters
    • ftdi — pointer to ftdi_context
    • buf — Buffer with the data
    • size — Size of the buffer
  • Return values
    • NULL — Some error happens when submit transfer 😭
    • !NULL — Pointer to a ftdi_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.


int ftdi_transfer_data_done (struct ftdi_transfer_control * tc)

okay so this one is literally the "are we there yet" function 💅 it waits for the transfer to actually finish.

It uses the libusb 1.0 asynchronous API, bestie. no cap.

  • Parameters
    • tc — pointer to ftdi_transfer_control
  • Return values
    • < 0 — Some error happens 😭
    • >= 0 — Data size transferred 🎉

real talk though: tc->transfer could be NULL if (size <= ftdi->readbuffer_remaining) at ftdi_read_data_submit(). So that's exactly why we gotta check it here, fr fr. 👀

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.


void ftdi_transfer_data_cancel (struct ftdi_transfer_control * tc, struct timeval * to)

cancel the transfer and then wait for it to complete — it's giving "we're done here, pack it up" energy 🧚

Also uses the libusb 1.0 asynchronous API.

  • Parameters
    • tc — pointer to ftdi_transfer_control
    • to — pointer to timeout value or NULL for 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.


int ftdi_set_bitmode (struct ftdi_context * ftdi, unsigned char bitmask, unsigned char mode)

enable/disable bitbang modes 🎛️ the main character of GPIO energy.

  • Parameters
    • ftdi — pointer to ftdi_context
    • bitmask — Bitmask to configure lines. HIGH/ON value configures a line as output. 🔥
    • mode — Bitbang mode: use the values defined in ftdi_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().


int ftdi_disable_bitbang (struct ftdi_context * ftdi)

disable bitbang mode. that's it, that's the whole vibe 🙈

  • Parameters
    • ftdi — pointer to ftdi_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().


int ftdi_read_pins (struct ftdi_context * ftdi, unsigned char * pins)

directly read pin state, circumventing the read buffer 🕵️‍♀️ super useful for bitbang mode, iykyk.

  • Parameters
    • ftdi — pointer to ftdi_context
    • pins — 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().


int ftdi_set_latency_timer (struct ftdi_context * ftdi, unsigned char latency)

set latency timer ⏱️

okay so the lore: the FTDI chip keeps data in the internal buffer for a specific amount of time if the buffer is not full yet — all to decrease load on the usb bus. iconic efficiency tbh 🎀

  • Parameters
    • ftdi — pointer to ftdi_context
    • latency — Value between 1 and 255
  • 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().


int ftdi_get_latency_timer (struct ftdi_context * ftdi, unsigned char * latency)

get latency timer — the read half of the duo 🫶

  • Parameters
    • ftdi — pointer to ftdi_context
    • latency — 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().


int ftdi_poll_modem_status (struct ftdi_context * ftdi, unsigned short * status)

poll modem status information 📡 this one's a whole mood, stay with me.

This function allows you to retrieve the two status bytes of the device. The device also sends these bytes as a header for each read access — where they get discarded by ftdi_read_data(). And get this: 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 to ftdi_context
    • status — 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().


int ftdi_setflowctrl (struct ftdi_context * ftdi, int flowctrl)

set flowcontrol for the ftdi chip 🌊

⚠️ Note: Do not use this function to enable XON/XOFF mode, use ftdi_setflowctrl_xonxoff() instead. like, genuinely, don't. 🙅‍♀️
  • Parameters
    • ftdi — pointer to ftdi_context
    • flowctrl — flow control to use. should be SIO_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)

set XON/XOFF flowcontrol for the ftdi chip — this is the one you actually want for that 💅

  • Parameters
    • ftdi — pointer to ftdi_context
    • xon — 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_rts (struct ftdi_context * ftdi, int dtr, int rts)

set dtr and rts line in one pass ✌️ two lines, one call, efficiency queen behavior 👑

  • Parameters
    • 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)
  • 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_setdtr (struct ftdi_context * ftdi, int state)

set dtr line, just the one 🎀

  • Parameters
    • ftdi — pointer to ftdi_context
    • state — 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 🦋

  • Parameters
    • ftdi — pointer to ftdi_context
    • state — 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_set_event_char (struct ftdi_context * ftdi, unsigned char eventch, unsigned char enable)

set the special event character ⭐ it's giving "notice me" energy.

  • Parameters
    • ftdi — pointer to ftdi_context
    • eventch — Event character
    • enable — 0 to 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

okay so we’re hopping back in mid-function — no recap era, just vibes and the rest of the deets 💅

Parameters

  • ftdi — pointer to ftdi_context
  • errorch — the error character
  • enable — 0 to 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().


🧚 ftdi_eeprom_initdefaults()

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 — it’s giving “set up my little EEPROM bestie before we get fancy” 🌸

Parameters

  • ftdi — pointer to ftdi_context
  • manufacturer — String to use as Manufacturer
  • product — String to use as Product description
  • serial — String to use as Serial number description

Return values

  • 0 — all fine ✨
  • -1 — No struct ftdi_context 😭
  • -2 — No struct 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().


🔥 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(). Literally turning the struct into the EEPROM image, no cap 💅

Parameters

  • ftdi — pointer to ftdi_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().


🦋 ftdi_eeprom_decode()

int ftdi_eeprom_decode (struct ftdi_context * ftdi, int verbose)

Decode binary EEPROM image into an ftdi_eeprom structure.

For FT-X devices use AN_201 FT-X MTP memory Configuration to decode.

Parameters

  • ftdi — pointer to ftdi_context
  • verbose — Decode EEPROM 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

Definition at line 3592 of file ftdi.c.

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.


👑 ftdi_get_eeprom_value()

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 — query szn, bestie ✨

Parameters

  • ftdi — pointer to ftdi_context
  • value_name — Enum of the value to query
  • value — Pointer to store read value

Return values

  • 0 — all fine ✨
  • -1 — Value doesn't exist 💀

Definition at line 4029 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, 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.


💜 ftdi_set_eeprom_value()

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. No parameter checking is performed.

Parameters:

  • ftdi — pointer to ftdi_context
  • value_name — enum of the value to set
  • value — value to set

Return values:

  • 0 — all fine
  • -1 — Value doesn't exist
  • -2 — Value not user settable

Definition 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.


int ftdi_get_eeprom_buf (struct ftdi_context * ftdi, unsigned char * buf, int size)

Get the read-only buffer to the binary EEPROM content. Read-only bestie, so no sneaky writes through this one.

Parameters:

  • ftdi — pointer to ftdi_context
  • buf — buffer to receive EEPROM content
  • size — Size of receiving buffer

Return values:

  • 0 — All fine
  • -1 — struct ftdi_contxt or ftdi_eeprom missing
  • -2 — Not enough room to store eeprom

Definition 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.


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. You bring the bytes, it handles the vibes.

Parameters:

  • ftdi — pointer to ftdi_context
  • buf — buffer to read EEPROM content
  • size — Size of buffer

Return values:

  • 0 — All fine
  • -1 — struct ftdi_context or ftdi_eeprom or buf missing

Definition 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.


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. User data gets its own little moment ✨

Parameters:

  • ftdi — pointer to ftdi_context
  • buf — buffer to read EEPROM user data content
  • size — Size of buffer

Return values:

  • 0 — All fine
  • -1 — struct ftdi_context or ftdi_eeprom or buf missing

Definition 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.


int ftdi_read_eeprom (struct ftdi_context * ftdi)

Read eeprom. Go off, read that EEPROM 💅

Parameters:

  • ftdi — pointer to ftdi_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. R-type girlies get their own special chip ID, iykyk.

Parameters:

  • ftdi — pointer to ftdi_context
  • chipid — 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 (struct ftdi_context * ftdi)

Write eeprom. This is the commit-to-it moment, bestie.

Parameters:

  • ftdi — pointer to ftdi_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 description line here, just the definition and the receipts. Lowkey iconic 🫶

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().


int ftdi_read_eeprom_location (struct ftdi_context * ftdi, int eeprom_addr, unsigned short * eeprom_val)

Read eeprom location. One little address at a time.

Parameters:

  • ftdi — pointer to ftdi_context
  • eeprom_addr — Address of eeprom location to be read
  • eeprom_val — Pointer to store read eeprom location

Return values:

  • 0 — all fine
  • -1 — read failed
  • -2 — USB device unavailable

Definition 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().


int ftdi_write_eeprom_location (struct ftdi_context * ftdi, int eeprom_addr, unsigned short eeprom_val)

Write eeprom location. Address + value, and boom — that location gets updated.

Parameters:

  • ftdi — pointer to ftdi_context
  • eeprom_addr — Address of eeprom location to be written
  • eeprom_val — Value to be written

Return values:

  • 0 — all fine
  • -1 — write failed
  • -2 — USB device unavailable
  • -3 — Invalid access to checksum protected area below 0x80
  • -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().


const char * ftdi_get_error_string (struct ftdi_context * ftdi)

Get string representation for last error code. So when things go sideways, this gives you the words.

Parameters:

  • ftdi — pointer to ftdi_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 ✨

Author: generated automatically by Doxygen for libftdi1 from the source code. Not a human author, just Doxygen doing its auto-gen slay 💅


⭐ Cute sign-off: this is ftdi.h(3) from libftdi1, Version 1.5, dated Wed Nov 6 2024 09:58:53. Byeee bestie, go flash something iconic 💖

📦 where this page comes from