Expand description
Rust safe wrapper for the FTDI D2XX drivers.
This takes the libftd2xx-ffi C bindings crate and extends it with rust safe wrappers.
§Usage
Simply add this crate as a dependency in your Cargo.toml
.
[dependencies.libftd2xx]
version = "0.33.1"
# statically link the vendor library, defaults to dynamic if not set
# this will make things "just work" on Linux and Windows
features = ["static"]
This is a basic example to get your started. Check the source code or documentation for more examples.
use libftd2xx::{Ftdi, FtdiCommon};
let mut ft = Ftdi::new()?;
let info = ft.device_info()?;
println!("Device information: {:?}", info);
This crate is just a wrapper around the FTD2XX driver; I2C, SPI, and GPIO
examples using the embedded-hal
traits can be found in
ftdi-embedded-hal
.
§udev rules
To access the FTDI USB device as a regular user on Linux you need to update the udev rules.
Create a file called /etc/udev/rules.d/99-ftdi.rules
with:
SUBSYSTEM=="usb", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6010", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6011", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6014", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6015", MODE="0666"
Then, reload the rules:
sudo udevadm control --reload-rules
sudo udevadm trigger
§Linking
By default this crate with use dynamic linking for the vendor library.
Use the static
feature flag to enable static linking.
§Dynamic Linking on Linux
The shared object libftd2xx.so
must exist on your system.
See FTDI Drivers Installation Guide for Linux for instructions.
§Dynamic Linking on Windows
The FTD2XX DLL must exist on your system PATH. The easiest way to install this is with the vendor provided setup executable.
§Static Linking on Linux or Windows
No special considerations are needed, the static library is distributed with permission from FTDI in the libftd2xx-ffi crate.
§References
§Troubleshooting
§Unknown Device on Linux
Remove the VCP FTDI driver.
sudo rmmod ftdi_sio
sudo rmmod usbserial
See FTDI Drivers Installation Guide for Linux for more details.
Structs§
- Device
Info - FTDI device information.
- Device
Status - FTDI device status.
- Eeprom232h
- EEPROM structure for the FT232H.
- Eeprom232r
- EEPROM structure for the FT232R.
- Eeprom2232h
- EEPROM structure for the FT2232H.
- Eeprom4232h
- EEPROM structure for the FT4232H.
- Eeprom
Header - FTDI EEPROM header common to all FTDI devices.
- Eeprom
Strings - EEPROM strings structure.
- Eeprom
Strings Error - EEPROM strings error.
- Eeprom
Value Error - EEPROM value error.
- EepromX
Series - EEPROM structure for the FT X series.
- Ft232h
- FT232H device.
- Ft232r
- FT232R device.
- Ft2232h
- FT2232H device.
- Ft4232h
- FT4232H device.
- Ft4232ha
- FT4232HA device.
- FtXSeries
- FT X Series device.
- Ftdi
- Generic FTDI device.
- Modem
Status - FTDI modem status.
- Mpsse
CmdBuilder - FTDI Multi-Protocol Synchronous Serial Engine (MPSSE) command builder.
- Mpsse
Settings - Initialization settings for the MPSSE.
- Version
- D2XX version structure.
Enums§
- BitMode
- BitModes for the FTDI ports.
- Bits
PerWord - Bits per word.
- Byte
Order - FT1248 byte order.
- Cbus232h
- FT232H CBUS options.
- Cbus232r
- FT232R CBUS options.
- CbusX
- FT X Series CBUS options.
- Clock
Bits - Modes for clocking data bits in and out of the FTDI device.
- Clock
Bits In - Modes for clocking data bits into the FTDI device.
- Clock
Bits Out - Modes for clocking bits out of the FTDI device.
- Clock
Data - Modes for clocking data in and out of the FTDI device.
- Clock
Data In - Modes for clocking data into the FTDI device.
- Clock
Data Out - Modes for clocking data out of the FTDI device.
- Clock
Polarity - FT1248 clock polarity
- Device
Type - FTDI device types.
- Device
Type Error - Device type errors.
- Drive
Current - FTDI pin drive currents.
- Driver
Type - FTDI driver type.
- FtStatus
- These are the C API error codes.
- Mpsse
Cmd - MPSSE opcodes.
- Parity
- Serial parity bits.
- Speed
- USB device speed.
- Stop
Bits - Stop bits.
- Timeout
Error - FTDI timeout errors.
Constants§
- FTDI_
VID - FTDI USB vendor id.
Traits§
- Ftdi
Common - FTD2XX functions common to all devices.
- Ftdi
Eeprom - FTDI device-specific EEPROM trait.
- Ftdi
Mpsse - FTDI Multi-Protocol Synchronous Serial Engine (MPSSE).
- Ftx232h
Mpsse - This contains MPSSE commands that are only available on the the FT232H, FT2232H, and FT4232H(A) devices.
- Mpsse
CmdExecutor - FTDI MPSSE configurator and executor
Functions§
- library_
version - Returns the version of the underlying C library.
- list_
devices - This function returns a device information vector with information about the D2XX devices connected to the system.
- list_
devices_ fs - Lists FTDI devices using the Linux file system.
- num_
devices - Returns the number of FTDI devices connected to the system.
- rescan
Windows - Rescan devices on the system.
- set_
vid_ pid Unix - A command to include a custom VID and PID combination within the internal device list table.
- vid_pid
Unix - A command to retrieve the current VID and PID combination from within the internal device list table.