Documentation
¶
Overview ¶
Package ft232h drives the FTDI FT232H as a USB-to-I2C bridge (for example the Adafruit FT232H breakout), from pure Go with no cgo.
It uses the chip's MPSSE engine with the same I2C wiring as Adafruit Blinka: D0 is SCL, and D1 and D2 together are SDA. On the Adafruit board, set the I2C switch on (or wire D1 to D2 on older boards without one).
Only Linux is supported for now; Open returns an error elsewhere.
Index ¶
Constants ¶
const ( VendorID = 0x0403 ProductID = 0x6014 )
USB IDs of the FT232H.
Variables ¶
var ( // ErrNoDevice means no FT232H is attached. ErrNoDevice = errors.New("ft232h: no FT232H found") // ErrInUse means another program has the FT232H open. ErrInUse = errors.New("ft232h: FT232H is in use by another program") // ErrNACK means no device acknowledged the I2C address. ErrNACK = errors.New("ft232h: no I2C device acknowledged the address") // ErrTimeout means the chip did not answer in time. ErrTimeout = errors.New("ft232h: timed out waiting for the FT232H") )
Functions ¶
This section is empty.
Types ¶
type Device ¶
type Device struct {
// contains filtered or unexported fields
}
Device is an open FT232H. It is safe for concurrent use.
func Open ¶
Open opens the FT232H attached to this computer, switches it to I2C and sets the bus to 100 kHz. It fails if there is not exactly one FT232H.
While open, the chip's serial port (/dev/ttyUSB*) goes away; Close brings it back. The device is held exclusively: opening it while another program has it fails with ErrInUse.
The USB device file must be readable and writable by the current user; see the README for a udev rule.
func (*Device) I2CTx ¶
I2CTx writes w and then reads into r, with a repeated start between them. Either may be empty, but not both.
func (*Device) Scan ¶
Scan returns the 7-bit addresses (0x08-0x77) of devices that acknowledge their address.
func (*Device) SetI2CSpeed ¶
SetI2CSpeed sets the I2C clock in Hz, from 1 kHz to 1 MHz.