ft232h

package
v1.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 14, 2026 License: MIT Imports: 10 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
const (
	VendorID  = 0x0403
	ProductID = 0x6014
)

USB IDs of the FT232H.

Variables

View Source
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

func Open() (*Device, error)

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) Close

func (d *Device) Close() error

Close puts the chip back in serial mode and releases it.

func (*Device) I2CRead

func (d *Device) I2CRead(addr byte, buf []byte) error

I2CRead reads len(buf) bytes from the device at 7-bit address addr.

func (*Device) I2CTx

func (d *Device) I2CTx(addr byte, w, r []byte) error

I2CTx writes w and then reads into r, with a repeated start between them. Either may be empty, but not both.

func (*Device) I2CWrite

func (d *Device) I2CWrite(addr byte, data []byte) error

I2CWrite writes data to the device at 7-bit address addr.

func (*Device) Scan

func (d *Device) Scan() ([]byte, error)

Scan returns the 7-bit addresses (0x08-0x77) of devices that acknowledge their address.

func (*Device) SetI2CSpeed

func (d *Device) SetI2CSpeed(hz int) error

SetI2CSpeed sets the I2C clock in Hz, from 1 kHz to 1 MHz.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL