Help us shape the future of Go! Take the 2026 Go Developer Survey

ftdi

package module
v0.0.0-...-4ca7ef6 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2017 License: MIT Imports: 6 Imported by: 0

README

goftdi

Go interface to FTDI D2XX Drivers.

Documentation

Index

Constants

View Source
const (
	RESET         BitMode = 0x00
	ASYNC_BITBANG         = 0x01
	MPSSE                 = 0x02
	SYNC_BITBANG          = 0x04
	HOST_EMU              = 0x08
	FAST_OPTO             = 0x10
	CBUS_BITBANG          = 0x20
	SYNCHRONOUS           = 0x40
)
View Source
const (
	DISABLED FlowControl = 0x0000
	RTS_CTS              = 0x0100
	DTR_DSR              = 0x0200
	XON_XOFF             = 0x0400
)
View Source
const (
	BITS_8 bitsPerWord = 8
	BIST_7 bitsPerWord = 7
	STOP_1 stopBits    = 0
	STOP_2 stopBits    = 2
	NONE   parity      = 0
	ODD    parity      = 1
	EVEN   parity      = 2
	MARK   parity      = 3
	SPACE  parity      = 4
)
View Source
const (
	FT_OK                          = 0
	FT_INVALID_HANDLE              = 1
	FT_DEVICE_NOT_FOUND            = 2
	FT_DEVICE_NOT_OPENED           = 3
	FT_IO_ERROR                    = 4
	FT_INSUFFICIENT_RESOURCES      = 5
	FT_INVALID_PARAMETER           = 6
	FT_INVALID_BAUD_RATE           = 7
	FT_DEVICE_NOT_OPENED_FOR_ERASE = 8
	FT_DEVICE_NOT_OPENED_FOR_WRITE = 9
	FT_FAILED_TO_WRITE_DEVICE      = 10
	FT_EEPROM_READ_FAILED          = 11
	FT_EEPROM_WRITE_FAILED         = 12
	FT_EEPROM_ERASE_FAILED         = 13
	FT_EEPROM_NOT_PRESENT          = 14
	FT_EEPROM_NOT_PROGRAMMED       = 15
	FT_INVALID_ARGS                = 16
	FT_NOT_SUPPORTED               = 17
	FT_OTHER_ERROR                 = 18
)

FT_STATUS (DWORD)

View Source
const (
	DISABLE_X5   = 0x8A
	ENABLE_X5    = 0x8B
	SET_CLK_DIV  = 0x86
	SET_LOW_BITS = 0x80
	SPI_0_WRITE  = 0x11
	SPI_0_READ   = 0x24
	SPI_0_TXRX   = 0x31
)

MPSSE Commands

View Source
const (
	CHECK_RX_DELAY_MS = 200
)
View Source
const CHUNK_SIZE = 1 << 16

Variables

View Source
var (
	ErrInvalidHandle           = errors.New("FTDI :: Invalid device handle")
	ErrDeviceNotFound          = errors.New("FTDI :: Device not found")
	ErrDeviceNotOpened         = errors.New("FTDI :: Device not opened")
	ErrIO                      = errors.New("FTDI :: IO failed")
	ErrInsufficientResources   = errors.New("FTDI :: Insufficient resources")
	ErrInvalidParameter        = errors.New("FTDI :: Invalid parameter")
	ErrInvalidBaudRate         = errors.New("FTDI :: Invalid baud rate")
	ErrDeviceNotOpenedForErase = errors.New("FTDI :: Device not opened for erase")
	ErrDeviceNotOpenedForWrite = errors.New("FTDI :: Device not opened for write")
	ErrFailedToWriteDevice     = errors.New("FTDI :: Failed to write device")
	ErrEReadFailed             = errors.New("FTDI :: EEPROM read failed")
	ErrEWriteFailed            = errors.New("FTDI :: EEPROM write failed")
	ErrEEraseFailed            = errors.New("FTDI :: EEPROM erase failed")
	ErrENotPresent             = errors.New("FTDI :: EEPROM not present")
	ErrENotProgrammed          = errors.New("FTDI :: EEPROM not programmed")
	ErrInvalidArgs             = errors.New("FTDI :: Invalid arguments")
	ErrNotSupported            = errors.New("FTDI :: Device not supported")
	ErrOther                   = errors.New("FTDI :: Unknown FTDI error")
)

Functions

func GetLibraryVersion

func GetLibraryVersion() uint32

Return Library version, formatted to match D2XX

Types

type BitBang

type BitBang struct {
	// contains filtered or unexported fields
}

func InitializeBitBang

func InitializeBitBang(d *Device) (s *BitBang, e error)

func (*BitBang) Read

func (bb *BitBang) Read(b []byte) (n int, e error)

func (*BitBang) Write

func (bb *BitBang) Write(b []byte) (n int, e error)

type BitMode

type BitMode byte

type Device

type Device struct {
	// contains filtered or unexported fields
}

func Open

func Open(di DeviceInfo) (d *Device, e error)

func (*Device) Close

func (d *Device) Close() (e error)

func (*Device) GetStatus

func (d *Device) GetStatus() (rx_queue, tx_queue, events int32, e error)

func (*Device) Purge

func (d *Device) Purge() (e error)

func (*Device) Read

func (d *Device) Read(p []byte) (n int, e error)

func (*Device) Reset

func (d *Device) Reset() (e error)

func (*Device) SetBaudRate

func (d *Device) SetBaudRate(baud uint) (e error)

func (*Device) SetBitMode

func (d *Device) SetBitMode(mode BitMode) (e error)

func (*Device) SetChars

func (d *Device) SetChars(event, err byte) (e error)

func (*Device) SetFlowControl

func (d *Device) SetFlowControl(f FlowControl) (e error)

func (*Device) SetLatency

func (d *Device) SetLatency(latency int) (e error)

func (*Device) SetLineProperty

func (d *Device) SetLineProperty(props LineProperties) (e error)

func (*Device) SetTimeout

func (d *Device) SetTimeout(read_timeout, write_timeout int) (e error)

func (*Device) SetTransferSize

func (d *Device) SetTransferSize(read_size, write_size int) (e error)

func (*Device) Write

func (d *Device) Write(p []byte) (n int, e error)

type DeviceInfo

type DeviceInfo struct {
	// contains filtered or unexported fields
}

func GetDeviceList

func GetDeviceList() (dl []DeviceInfo, e error)

TODO: Need to expand multi-interface devices, and then to other FTDI chips

type FlowControl

type FlowControl uint16

type LineProperties

type LineProperties struct {
	Bits     bitsPerWord
	StopBits stopBits
	Parity   parity
}

type Spi

type Spi struct {
	// contains filtered or unexported fields
}

func InitializeSpi

func InitializeSpi(d *Device) (s *Spi, e error)

Initialize an FTDI device for MPSSE mode

func (*Spi) Read

func (s *Spi) Read(b []byte) (n int, e error)

func (*Spi) ReadGPIO

func (s *Spi) ReadGPIO(state byte) (e error)

func (*Spi) SetClk

func (s *Spi) SetClk(freq int) (e error)

func (*Spi) SetGPIO

func (s *Spi) SetGPIO(outputs byte) (e error)

func (*Spi) Transfer

func (s *Spi) Transfer(b []byte) (r []byte, e error)

Write `w` bytes while also reading into `r`

func (*Spi) Write

func (s *Spi) Write(b []byte) (n int, e error)

func (*Spi) WriteGPIO

func (s *Spi) WriteGPIO(state byte) (e error)

Jump to

Keyboard shortcuts

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