Package ftdi provides support for FT232H/FT232R/FT2232H devices via the Future Technology “D2XX” driver with minimal configuration on your side.
The driver implements:
This includes Raspbian and Ubuntu.
Run this command after connecting your FTDI device:
sudo rmmod ftdi_sio usbserial
Run these commands before connecting your FTDI device:
curl https://raw.githubusercontent.com/periph/host/main/ftdi/debian/98-ft232h.rules > 98-ft232h.rules
sudo cp 98-ft232h.rules /etc/udev/rules.d/
sudo udevadm control --reload-rules
sudo udevadm trigger --verbose
This temporarily unload Apple’s FTDI driver. This needs to be done after each OS startup:
sudo kextunload -b com.apple.driver.AppleUSBFTDI
This permanently disable Apple’s FTDI driver.
D2xxHelper_xxx.pkg
you just downloaded.Use SPI on a FT232H.
package main
import (
"fmt"
"log"
"periph.io/x/conn/v3/physic"
"periph.io/x/conn/v3/spi"
"periph.io/x/host/v3"
"periph.io/x/host/v3/ftdi"
)
func main() {
if _, err := host.Init(); err != nil {
log.Fatal(err)
}
all := ftdi.All()
if len(all) == 0 {
log.Fatal("found no FTDI device on the USB bus")
}
// Use channel A.
ft232h, ok := all[0].(*ftdi.FT232H)
if !ok {
log.Fatal("not FTDI device on the USB bus")
}
s, err := ft232h.SPI()
if err != nil {
log.Fatal(err)
}
c, err := s.Connect(physic.KiloHertz*100, spi.Mode3, 8)
write := []byte{0x10, 0x00}
read := make([]byte, len(write))
if err := c.Tx(write, read); err != nil {
log.Fatal(err)
}
// Use read.
fmt.Printf("%v\n", read[1:])
}
These links are for the FT232H, which is higher speed than the FT232R for nearly the same price:
It is not recommended to buy chips on AliExpress or Amazon (except for the adafruit branded boards). Most of these are cheap counterfeit that have incomplete support. They are often sold under the brand “CJMCU”.
The periph authors do not endorse any specific seller. These are only provided for your convenience.