Go module for FTDI FT232H USB to GPIO/SPI/I²C/JTAG/UART protocol converter
This software is a work-in-progress (WIP) and not ready for use. The following features have been implemented, but their interfaces maywill change.
- Documented and integration tested
- Multi-platform support (see: build matrix)
go1.11
,gp1.12
,go1.13
,go1.14
,go1.15
,go-master
- Linux:
amd64
,386
,arm64
,arm
- macOS:
amd64
- Linux:
-
GPIO
- read/write- 8 dedicated pins available in any mode
- 8-bit parallel, and 1-bit serial read/write operations
-
SPI
- read/write- SPI modes
0
and2
only, i.e.CPHA=1
- configurable clock rate up to 30 MHz
- chip/slave-select
CS
on both ports (pinsD3—D7
,C0—C7
), including:- automatic assert-on-write/read with configurable polarity
- multi-slave support with independent clocks
SCLK
, SPI modes,CPOL
, etc.
- unlimited effective transfer time/size
- USB uses 64 KiB packets internally
- SPI modes
-
I2C
- read/write- configurable clock rate up to high speed mode (3.4 Mb/s)
- internal or external SDA pullup option
- unlimited effective transfer time/size
- USB uses 64 KiB packets internally
-
JTAG
- not yet implementented -
UART
- not yet implementented - TBD (WIP)
If you are not using Go modules for your application (or are unsure), use the built-in go
package manager:
go get -u -v github.com/ardnew/ft232h
Otherwise, you are using Go modules, either use the same command above (sans -u
), or simply add the import statement to your source code and the module will be installed automatically:
import (
// ... other imports ...
"github.com/ardnew/ft232h"
)
No other files or configuration to your build process are necessary.
Many Linux distributions ship with the FTDI Virtual COM Port (VCP) driver pre-installed (as a kernel module, usually ftdi_sio
). However, according to FTDI:
For Linux, Mac OS X (10.4 and later) and Windows CE (4.2 and later) the D2XX driver and VCP driver are mutually exclusive options as only one driver type may be installed at a given time for a given device ID.
There are a lot of ways to resolve the issue, including fancy udev rules to swap out modules when (un)plugging devices, but I don't personally use the VCP driver.
On Ubuntu, you can simply prevent the VCP module from being auto-loaded at bootup by blacklisting the module. For example, create a new file /etc/modprobe.d/blacklist-ftdi.conf
with a single directive:
# the official FTDI driver D2XX is incompatible with the VCP driver,
# preventing communication with FT232H breakouts
blacklist ftdi_sio
Be sure to unload the module if it was already loaded:
sudo rmmod ftdi_sio
Despite FTDI's own quote from the D2XX Programmer's Guide
above, I've found that the current versions of macOS (10.13 and later, personal experience) have no problem co-existing with the D2XX
driver included with this ft232h
Go module. It Just Works and no configuration is necessary.
Markdown | godoc | |
---|---|---|
Primary API reference | github.com/ardnew/ft232h |
|
Supported peripheral devices | github.com/ardnew/ft232h/drv |
|
Native FTDI drivers | github.com/ardnew/ft232h/native |
Demo applications using this module and its device drivers can be found in examples/
.
Usage examples for the API can be found in the godoc package documentation.
Adafruit sells a very nice breakout with a bunch of extras:
- USB-C and Stemma QT/Qwiic I²C connectors (with a little switch to short the chip's two awkward
SDA
pins!) - On-board EEPROM (for storing chip configuration)
- 5V (
VBUS
) and 3.3V (on-board regulator, up to 500mA draw) outputs