#hid #usb-hid #i2c #ftdi #usb #uart #usb-device

ft260hid

Library to control FT260 USB-I2C/UART bridge IC

1 unstable release

0.1.0 May 19, 2024

#890 in Hardware support

Custom license

74KB
2K SLoC

ft260hid

This unofficial library controls FT260 USB-I2C/UART bridge IC made by FTDI.
The library depends on "hidapi" crate mainly.

About FT260

This USB device does not have virtual COM port. Instead, it has HID interface.
For example, HID Input/Output Reports are converted into I2C/UART communication between the FT260 and its external devices.

Examples

Unit tests are executed on the evaluation board UMFT260EV1A.

GPIO

use ft260hid::device;
use ft260hid::io::gpio::{Dir, Group, Pin, Val};
// . . .
    let dev = device::open(0).unwrap();
    let gpio = dev.gpio();
    gpio.enable_pin(Group::Gpio_0_1);
    gpio.set_dir(Pin::Gpio0, Dir::Out);
    gpio.write(Pin::Gpio0, Val::Low);
    gpio.set_dir(Pin::Gpio1, Dir::In);
    gpio.set_pull_up(Pin::Gpio1);

I2C

I2C EEPROM (AT24C02D_SOT23) is mounted on UMFT260EV1A board, and it can be used for unit tests.

use ft260hid::device;
use ft260hid::io::i2c;
// . . .
/// I2C address of EEPROM on UMFT260EV1A
const EEPROM_ADDRESS: u8 = 0x50;
/// page size of EEPROM
const EEPROM_PAGE_SIZE: usize = 8;
// . . .
    let dev = device::open(0).unwrap();
    let mut i2c = dev.i2c();
    i2c.init(i2c::KBPS_DEFAULT);
    // address value to read EEPROM page out
    let addr = [0u8];
    let mut data_read = [0u8; EEPROM_PAGE_SIZE];
    i2c.write_read(EEPROM_ADDRESS,
                &addr,
                1,
                &mut buf,
                EEPROM_PAGE_SIZE,
                i2c::DURATION_WAIT_DEFAULT
            );

UART

The TXD-RXD pins on UMFT260EV1A are shorted for unit tests.

use ft260hid::device;
use ft260hid::io::uart;
// . . .
    // interface number is `1` !!
    let dev = device::open(1).unwrap();
    let mut uart = dev.uart();
    uart.init();
    uart.set_config(&uart::Config::default());
    // UART TX
    let mut buf_tx = [0u8; 256];
    let size_sent = uart.write(&buf_tx, len).unwrap();
    // RX data in FIFO
    let size_to_read = uart.size_to_read();
    // UART RX
    let mut buf_rx = [0u8; 256];
    let size_rec = uart.read(&mut buf_rx, size_to_read, uart::DURATION_WAIT_DEFAULT).unwrap();

Dependencies

~2–13MB
~121K SLoC