Documentation ¶
Overview ¶
Go binding for libFTDI library http://http://www.intra2net.com/en/developer/libftdi/
Index ¶
- Constants
- func MPSSEDivValue(rate int, div5 bool) int
- type Break
- type CBusFunction
- type Channel
- type ChannelType
- type DataBits
- type Device
- func Open(vendor, product int, description, serial string, index uint, c Channel) (*Device, error)
- func OpenBusAddr(bus, address int, c Channel) (*Device, error)
- func OpenFirst(vendor, product int, c Channel) (*Device, error)
- func OpenString(description string, c Channel) (*Device, error)
- func OpenUSBDev(u *USBDev, c Channel) (*Device, error)
- func (d *Device) ChipID() (uint32, error)
- func (d *Device) Close() error
- func (d *Device) EEPROM() EEPROM
- func (d *Device) LatencyTimer() (int, error)
- func (d *Device) Pins() (b byte, err error)
- func (d *Device) PurgeBuffers() error
- func (d *Device) PurgeReadBuffer() error
- func (d *Device) PurgeWriteBuffer() error
- func (d *Device) Read(data []byte) (int, error)
- func (d *Device) ReadByte() (byte, error)
- func (d *Device) ReadChunkSize() (int, error)
- func (d *Device) Reset() error
- func (d *Device) SetBaudrate(br int) error
- func (d *Device) SetBitmode(iomask byte, mode Mode) error
- func (d *Device) SetDTR(dtr int) error
- func (d *Device) SetDTRRTS(dtr, rts int) error
- func (d *Device) SetFlowControl(flowctrl FlowCtrl) error
- func (d *Device) SetLatencyTimer(lt int) error
- func (d *Device) SetLineProperties(bits DataBits, stopbits StopBits, parity Parity) error
- func (d *Device) SetLineProperties2(bits DataBits, stopbits StopBits, parity Parity, breaks Break) error
- func (d *Device) SetRTS(rts int) error
- func (d *Device) SetReadChunkSize(cs int) error
- func (d *Device) SetWriteChunkSize(cs int) error
- func (d *Device) SubmitRead(data []byte) (*Transfer, error)
- func (d *Device) SubmitWrite(data []byte) (*Transfer, error)
- func (d *Device) Type() Type
- func (d *Device) Write(data []byte) (int, error)
- func (d *Device) WriteByte(b byte) error
- func (d *Device) WriteChunkSize() (int, error)
- func (d *Device) WriteString(s string) (int, error)
- type EEPROM
- func (e EEPROM) Build() error
- func (e EEPROM) CBusFunction(n int) CBusFunction
- func (e EEPROM) ChannelDriver(c Channel) bool
- func (e EEPROM) ChannelRS485(c Channel) bool
- func (e EEPROM) ChannelType(c Channel) ChannelType
- func (e EEPROM) ChipSize() int
- func (e EEPROM) ChipType() byte
- func (e EEPROM) Decode() error
- func (e EEPROM) HighCurrent(c Channel) bool
- func (e EEPROM) Invert() int
- func (e EEPROM) IsNotPNP() bool
- func (e EEPROM) IsochronousInp() bool
- func (e EEPROM) IsochronousOut() bool
- func (e EEPROM) ManufacturerString() string
- func (e EEPROM) MaxPower() int
- func (e EEPROM) ProductId() uint16
- func (e EEPROM) ProductString() string
- func (e EEPROM) Read() error
- func (e EEPROM) ReleaseNumber() uint16
- func (e EEPROM) RemoteWakeup() bool
- func (e EEPROM) SelfPowered() bool
- func (e EEPROM) SerialString() string
- func (e EEPROM) SetCBusFunction(n int, v CBusFunction)
- func (e EEPROM) SetChannelDriver(c Channel, v bool)
- func (e EEPROM) SetChannelRS485(c Channel, v bool)
- func (e EEPROM) SetChannelType(c Channel, v ChannelType)
- func (e EEPROM) SetChipType(v byte)
- func (e EEPROM) SetHighCurrent(c Channel, v bool)
- func (e EEPROM) SetInvert(v int)
- func (e EEPROM) SetIsNotPNP(v bool)
- func (e EEPROM) SetIsochronousInp(v bool)
- func (e EEPROM) SetIsochronousOut(v bool)
- func (e EEPROM) SetManufacturerString(s string)
- func (e EEPROM) SetMaxPower(v int)
- func (e EEPROM) SetProductId(v uint16)
- func (e EEPROM) SetProductString(s string)
- func (e EEPROM) SetReleaseNumber(v uint16)
- func (e EEPROM) SetRemoteWakeup(v bool)
- func (e EEPROM) SetSelfPowered(v bool)
- func (e EEPROM) SetSerialString(s string)
- func (e EEPROM) SetSuspendDBus7(v bool)
- func (e EEPROM) SetSuspendPullDowns(v bool)
- func (e EEPROM) SetUSBVersion(v uint16)
- func (e EEPROM) SetUseSerial(v bool)
- func (e EEPROM) SetUseUSBVersion(v bool)
- func (e EEPROM) SetVendorId(v uint16)
- func (e EEPROM) String() string
- func (e EEPROM) SuspendDBus7() bool
- func (e EEPROM) SuspendPullDowns() bool
- func (e EEPROM) USBVersion() uint16
- func (e EEPROM) UseSerial() bool
- func (e EEPROM) UseUSBVersion() bool
- func (e EEPROM) VendorId() uint16
- func (e EEPROM) Write() error
- type Error
- type FlowCtrl
- type Mode
- type Parity
- type StopBits
- type Transfer
- type Type
- type USBDev
- type USBError
Constants ¶
const ( MPSSEWriteNeg byte = C.MPSSE_WRITE_NEG MPSSEBitMode byte = C.MPSSE_BITMODE MPSSEReadNeg byte = C.MPSSE_READ_NEG MPSSELSB byte = C.MPSSE_LSB MPSSEDoWrite byte = C.MPSSE_DO_WRITE MPSSEDoRead byte = C.MPSSE_DO_READ MPSSEWriteTMS byte = C.MPSSE_WRITE_TMS MPSSESetBitsLow byte = C.SET_BITS_LOW MPSSESetBitsHigh byte = C.SET_BITS_HIGH MPSSEGetBitsLow byte = C.GET_BITS_LOW MPSSELoopbackStart byte = C.LOOPBACK_START MPSSELoopbackEnd byte = C.LOOPBACK_END MPSSETCKDivisor byte = C.TCK_DIVISOR MPSSEDisableDiv5 byte = C.DIS_DIV_5 MPSSEEnableDiv5 byte = C.EN_DIV_5 MPSSEEnable3Phase byte = C.EN_3_PHASE MPSSEDisable3Phase byte = C.DIS_3_PHASE MPSSEClockBits byte = C.CLK_BITS MPSSEClockBytes byte = C.CLK_BYTES MPSSEClockWaitHigh byte = C.CLK_WAIT_HIGH MPSSEClockWaitLow byte = C.CLK_WAIT_LOW MPSSEEnableAdaptive byte = C.EN_ADAPTIVE MPSSEDisableAdaptive byte = C.DIS_ADAPTIVE MPSSEClockBytesOrHigh byte = C.CLK_BYTES_OR_HIGH MPSSEClockBytesOrLow byte = C.CLK_BYTES_OR_LOW MPSSEDriveOpenCollector byte = C.DRIVE_OPEN_COLLECTOR MPSSESendImmediate byte = C.SEND_IMMEDIATE MPSSEWaitOnHigh byte = C.WAIT_ON_HIGH MPSSEWaitOnLow byte = C.WAIT_ON_LOW MPSSEReadShort byte = C.READ_SHORT MPSSEReadExtended byte = C.READ_EXTENDED MPSSEWriteShort byte = C.WRITE_SHORT MPSSEWriteExtended byte = C.WRITE_EXTENDED )
MPSSE commands See https://www.ftdichip.com/Documents/AppNotes/AN_108_Command_Processor_for_MPSSE_and_MCU_Host_Bus_Emulation_Modes.pdf for full details
Variables ¶
This section is empty.
Functions ¶
func MPSSEDivValue ¶
MPSSEDivValue calculates the two bytes that are required to be supplied after MPSSETCKDivisor to get the desired clock speed (in Hz). Set the dvi5 flag if MPSSEEnableDiv5 has been sent, to use a 12MHz base clock, instead of 60MHz.
Types ¶
type CBusFunction ¶
type CBusFunction byte
const ( CBusTxEn CBusFunction = iota CBusPwrEn CBusRxLED CBusTxLED CBusTxRxLED CBusSleep CBusClk48 CBusClk24 CBusClk12 CBusClk6 CBusIOMode CBusBBWR CBusBBRD )
func (CBusFunction) String ¶
func (c CBusFunction) String() string
type Channel ¶
type Channel uint32
Channel represents channel (interface) of FTDI device. Some devices have more than one channel (eg. FT2232 has 2 channels, FT4232 has 4 channels).
type ChannelType ¶
type ChannelType byte
const ( ChannelUART ChannelType = iota ChannelFIFO ChannelOPTO ChannelCPU ChannelFT1284 )
func (ChannelType) String ¶
func (ct ChannelType) String() string
type Device ¶
type Device struct {
// contains filtered or unexported fields
}
Device represents FTDI device.
func Open ¶
Open opens the index-th device with a given vendor id, product id, description and serial. Uses specified channel c.
func OpenBusAddr ¶
OpenBusAddr opens the device at a given USB bus and device address. Uses specified channel c.
func OpenFirst ¶
OpenFirst opens the first device with a given vendor and product ids. Uses specified channel c.
func OpenString ¶
OpenString opens the ftdi-device described by a description-string. Uses specified channel c.
func OpenUSBDev ¶
OpenUSBDev opens channel (interface) c of USB device u. u must be FTDI device.
func (*Device) LatencyTimer ¶
LatencyTimer returns latency timer value [ms].
func (*Device) PurgeBuffers ¶
PurgeBuffers clears both (Tx and Rx) buffers.
func (*Device) PurgeReadBuffer ¶
PurgeReadBuffer clears Tx buffer (buffer for data that will be sent to USB?).
func (*Device) PurgeWriteBuffer ¶
PurgeWriteBuffer clears Rx buffer (buffer for data received from USB?).
func (*Device) ReadChunkSize ¶
ReadChunkSize returns current value of read buffer chunk size.
func (*Device) SetBaudrate ¶
SetBaudrate sets the rate of data transfer.
For standard USB-UART adapter it sets UART baudrate.
For bitbang mode the clock is actually 16 times the br. From the FTDI documentation for FT232R bitbang mode: "The clock for the Asynchronous Bit Bang mode is actually 16 times the Baud rate. A value of 9600 Baud would transfer the data at (9600x16) = 153600 bytes per second, or 1 every 6.5 μS."
FT232R suports baudrates from 183.1 baud to 3 Mbaud but for real applications it should be <= 1 Mbaud: Actual baudrate is set to discrete value that satisfies the equation br = 3000000 / (n + x) where n can be an integer between 2 and 16384 and x can be a sub-integer of the value 0, 0.125, 0.25, 0.375, 0.5, 0.625, 0.75, or 0.875. When n == 1 then x should be 0, i.e. baud rate divisors with values between 1 and 2 are not possible.
func (*Device) SetBitmode ¶
SetBitmode sets operation mode for device d to mode. iomask bitmask configures lines corresponding to its bits as input (bit=0) or output (bit=1).
func (*Device) SetDTR ¶
SetDTR manually sets the DTR output line from the least significant bit of dtr.
func (*Device) SetDTRRTS ¶
SetDTRRTS manually sets the DTR and RTS output lines from the least significant bit of dtr and rts.
func (*Device) SetFlowControl ¶
SetFlowControl sets the flow control parameter
func (*Device) SetLatencyTimer ¶
SetLatencyTimer sets latency timer to lt (value beetwen 1 and 255). If FTDI device has fewer data to completely fill one USB packet (<62 B) it waits for lt ms before sending data to USB.
func (*Device) SetLineProperties ¶
SetLineProperties sets the uart data bit count, stop bits count, and parity mode
func (*Device) SetLineProperties2 ¶
func (d *Device) SetLineProperties2(bits DataBits, stopbits StopBits, parity Parity, breaks Break) error
SetLineProperties2 sets the uart data bit count, stop bits count, parity mode, and break usage
func (*Device) SetRTS ¶
SetRTS manually sets the RTS output line from the least significant bit of rts.
func (*Device) SetReadChunkSize ¶
SetReadChunkSize configure read chunk size for device (default is 4096B) and size of software buffer dedicated for reading data from device...
func (*Device) SetWriteChunkSize ¶
SetWriteChunkSize configure write chunk size (default is 4096). If more than cs bytes need to be send to device, they will be split to chunks of size cs.
func (*Device) WriteChunkSize ¶
WriteChunkSize returns current value of write chunk size.
type EEPROM ¶
type EEPROM struct {
// contains filtered or unexported fields
}
func (EEPROM) CBusFunction ¶
func (e EEPROM) CBusFunction(n int) CBusFunction
func (EEPROM) ChannelDriver ¶
ChannelDriver returns true if c channel has a driver. c can be from range: ChannelA - ChannelD
func (EEPROM) ChannelRS485 ¶
ChannelDriver returns true if c is RS485 channel. c can be from range: ChannelA - ChannelD
func (EEPROM) ChannelType ¶
func (e EEPROM) ChannelType(c Channel) ChannelType
ChannelType returns type of c channel. c can be: ChannelA, ChannelB
func (EEPROM) HighCurrent ¶
ChannelDriver returns true if c channel is in high current mode . c can be from range: ChannAny - ChannelD (use ChannAny for TypeR device).
func (EEPROM) IsochronousInp ¶
func (EEPROM) IsochronousOut ¶
func (EEPROM) ManufacturerString ¶
func (EEPROM) ProductString ¶
func (EEPROM) ReleaseNumber ¶
func (EEPROM) RemoteWakeup ¶
func (EEPROM) SelfPowered ¶
func (EEPROM) SerialString ¶
func (EEPROM) SetCBusFunction ¶
func (e EEPROM) SetCBusFunction(n int, v CBusFunction)
func (EEPROM) SetChannelDriver ¶
func (EEPROM) SetChannelRS485 ¶
func (EEPROM) SetChannelType ¶
func (e EEPROM) SetChannelType(c Channel, v ChannelType)
func (EEPROM) SetChipType ¶
func (EEPROM) SetHighCurrent ¶
func (EEPROM) SetIsNotPNP ¶
func (EEPROM) SetIsochronousInp ¶
func (EEPROM) SetIsochronousOut ¶
func (EEPROM) SetManufacturerString ¶
func (EEPROM) SetMaxPower ¶
SetMaxPower sets maximum power consumption (max. current) from USB in mA
func (EEPROM) SetProductId ¶
func (EEPROM) SetProductString ¶
func (EEPROM) SetReleaseNumber ¶
func (EEPROM) SetRemoteWakeup ¶
func (EEPROM) SetSelfPowered ¶
func (EEPROM) SetSerialString ¶
func (EEPROM) SetSuspendDBus7 ¶
func (EEPROM) SetSuspendPullDowns ¶
func (EEPROM) SetUSBVersion ¶
func (EEPROM) SetUseSerial ¶
func (EEPROM) SetUseUSBVersion ¶
func (EEPROM) SetVendorId ¶
func (EEPROM) SuspendDBus7 ¶
func (EEPROM) SuspendPullDowns ¶
func (EEPROM) USBVersion ¶
func (EEPROM) UseUSBVersion ¶
type FlowCtrl ¶
type FlowCtrl int
const ( // FlowCtrlDisable disables all automatic flow control. FlowCtrlDisable FlowCtrl = (1 << iota) >> 1 // FlowCtrlRTSCTS enables RTS CTS flow control. FlowCtrlRTSCTS // FlowCtrlDTRDSR enables DTR DSR flow control. FlowCtrlDTRDSR // FlowCtrlXONXOFF enables XON XOF flow control. FlowCtrlXONXOFF )
type Parity ¶
type Parity int
Parity represents the parity mode
const ( // ParityNone indicates no parity bit is used ParityNone Parity = C.NONE // ParityOdd indicates an odd parity bit is used ParityOdd Parity = C.ODD // ParityEven indicates an even parity bit is used ParityEven Parity = C.EVEN // ParityMark indicates that the parity bit should be a 1 ParityMark Parity = C.MARK // ParitySpace indicates that the parity bit should be a 0 ParitySpace Parity = C.SPACE )
type StopBits ¶
type StopBits int
StopBits represents the number of stop bits to expect
const ( // StopBits1 indicates only one stop bit is expected StopBits1 StopBits = C.STOP_BIT_1 // StopBits15 indicates one and a half stop bits are expected StopBits15 StopBits = C.STOP_BIT_15 // StopBits2 indicates two stop bits are expected StopBits2 StopBits = C.STOP_BIT_2 )