Documentation ¶
Overview ¶
Package d2xx is a thin Go wrapper for the Future Technology "D2XX" driver.
This package is not Go idiomatic. You want to use https://periph.io/x/host/v3/ftdi (or later) instead.
A static library of the d2xx driver is included for linux and macOS. They are from https://ftdichip.com/drivers/d2xx-drivers/. See third_party/README.md for more details.
Configuration ¶
See https://periph.io/device/ftdi/ for more details, and how to configure the host to be able to use this driver.
Index ¶
Examples ¶
Constants ¶
const Available = true
Available is true if the library is available on this system.
Variables ¶
This section is empty.
Functions ¶
func Open ¶
Open opens the ith device discovered.
If the driver is disabled via build tag `no_d2xx`, or on posix `CGO_ENABLED=0` environment variable, NoCGO is returned.
On Windows, Missing is returned if the dynamic library is not found at runtime.
func Version ¶
Version returns the library's version.
0, 0, 0 is returned if the library is unavailable.
Example ¶
package main import ( "fmt" "periph.io/x/d2xx" ) func main() { // Print the d2xx driver version. It will be 0.0.0 if not found. major, minor, build := d2xx.Version() fmt.Printf("Using library %d.%d.%d\n", major, minor, build) }
Output:
Types ¶
type EEPROM ¶
type EEPROM struct { // Raw is the raw EEPROM content. It excludes the strings. Raw []byte // The following condition must be true: len(Manufacturer) + len(Desc) <= 40. Manufacturer string ManufacturerID string Desc string Serial string }
EEPROM is the unprocessed EEPROM content.
The EEPROM is in 3 parts: the defined struct, the 4 strings and the rest which is used as an 'user area'. The size of the user area depends on the length of the strings. The user area content is not included in this struct.
type Err ¶
type Err int
Err is the error type returned by d2xx functions.
const ( // NoCGO is returned when the package was compiled without cgo, thus the d2xx // library is unavailable or the library was disabled via the `no_d2xx` build // tag. NoCGO Err = -2 // Missing is returned when the dynamic library is not available. Missing Err = -1 )
These are additional synthetic error codes.
func CreateDeviceInfoList ¶
CreateDeviceInfoList discovers the currently found devices.
If the driver is disabled via build tag `no_d2xx`, or on posix `CGO_ENABLED=0` environment variable, NoCGO is returned.
On Windows, Missing is returned if the dynamic library is not found at runtime.
type Handle ¶
type Handle interface { Close() Err // ResetDevice takes >1.2ms ResetDevice() Err GetDeviceInfo() (uint32, uint16, uint16, Err) EEPROMRead(devType uint32, e *EEPROM) Err EEPROMProgram(e *EEPROM) Err EraseEE() Err WriteEE(offset uint8, value uint16) Err EEUASize() (int, Err) EEUARead(ua []byte) Err EEUAWrite(ua []byte) Err SetChars(eventChar byte, eventEn bool, errorChar byte, errorEn bool) Err SetUSBParameters(in, out int) Err SetFlowControl() Err SetTimeouts(readMS, writeMS int) Err SetLatencyTimer(delayMS uint8) Err SetBaudRate(hz uint32) Err // GetQueueStatus takes >60µs GetQueueStatus() (uint32, Err) // Read takes <5µs if GetQueueStatus was called just before, // 300µs~800µs otherwise (!) Read(b []byte) (int, Err) // Write takes >0.1ms Write(b []byte) (int, Err) GetBitMode() (byte, Err) // SetBitMode takes >0.1ms SetBitMode(mask, mode byte) Err }
Handle is d2xx device handle.