Documentation
¶
Overview ¶
Go binding for libFTDI library http://http://www.intra2net.com/en/developer/libftdi/
Index ¶
- type Break
- type CBusFunction
- type Channel
- type ChannelType
- type DataBits
- type Device
- 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) MaxPower() int
- func (e EEPROM) ProductId() uint16
- func (e EEPROM) Read() error
- func (e EEPROM) ReleaseNumber() uint16
- func (e EEPROM) RemoteWakeup() bool
- func (e EEPROM) SelfPowered() bool
- 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) SetMaxPower(v int)
- func (e EEPROM) SetProductId(v uint16)
- func (e EEPROM) SetReleaseNumber(v uint16)
- func (e EEPROM) SetRemoteWakeup(v bool)
- func (e EEPROM) SetSelfPowered(v bool)
- 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 ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
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 OpenFirst ¶
OpenFirst opens the first device with a given vendor and product ids. 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) ReleaseNumber ¶
func (EEPROM) RemoteWakeup ¶
func (EEPROM) SelfPowered ¶
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) SetMaxPower ¶
SetMaxPower sets maximum power consumption (max. current) from USB in mA
func (EEPROM) SetProductId ¶
func (EEPROM) SetReleaseNumber ¶
func (EEPROM) SetRemoteWakeup ¶
func (EEPROM) SetSelfPowered ¶
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
FlowCtrl represents the flow control mode.
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 )
Directories
¶
Path | Synopsis |
---|---|
examples
|
|
ftdi_lcd
Pin connection between FT232R and LCD (HD44780 compatible): TxD (DBUS0) <--> D4 RxD (DBUS1) <--> D5 RTS# (DBUS2) <--> D6 CTS# (DBUS3) <--> D7 DTR# (DBUS4) <--> E DSR# (DBUS5) <--> R/W# DCD# (DBUS6) <--> RS
|
Pin connection between FT232R and LCD (HD44780 compatible): TxD (DBUS0) <--> D4 RxD (DBUS1) <--> D5 RTS# (DBUS2) <--> D6 CTS# (DBUS3) <--> D7 DTR# (DBUS4) <--> E DSR# (DBUS5) <--> R/W# DCD# (DBUS6) <--> RS |
ftdi_naive_lcd
Pin connection between FT232R and LCD (HD44780 compatible): TxD (DBUS0) <--> D4 RxD (DBUS1) <--> D5 RTS# (DBUS2) <--> D6 CTS# (DBUS3) <--> D7 DTR# (DBUS4) <--> E DSR# (DBUS5) <--> R/W# DCD# (DBUS6) <--> RS
|
Pin connection between FT232R and LCD (HD44780 compatible): TxD (DBUS0) <--> D4 RxD (DBUS1) <--> D5 RTS# (DBUS2) <--> D6 CTS# (DBUS3) <--> D7 DTR# (DBUS4) <--> E DSR# (DBUS5) <--> R/W# DCD# (DBUS6) <--> RS |