ftdi

package
v0.0.0-...-2b69e68 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2019 License: GPL-3.0 Imports: 12 Imported by: 2

Documentation

Index

Constants

View Source
const (
	D0 gpio.Pin = iota
	D1
	D2
	D3
	D4
	D5
	D6
	D7
	C0
	C1
	C2
	C3
	C4
	C5
	C6
	C7
	// Rarely used pins. Requires EEPROM modifications.
	C8
	C9
)

----------------------------------------------------------------------------- Pins -----------------------------------------------------------------------------

Variables

This section is empty.

Functions

This section is empty.

Types

type FTDI232H

type FTDI232H struct {
	Vender  int
	Product int

	// If SleepingPoll = true then a 1 microsecond sleep occurs between each buffer
	// read while polling. Default is `False`
	SleepingPoll bool
	// contains filtered or unexported fields
}

FTDI232H represents the Adafruit USB to GPIO breakout board. Adafruit part number is: P2264

The board exposes all 16 io pins: D0->D7 and C0->C7

func NewFTDI232H

func NewFTDI232H(vender, product int) *FTDI232H

NewFTDI232H creates and configures FTDI. if disableDrivers = true then you need to run as root. [vendor] is typically 0x0403 There are several products, for example: 0x6014 = FT232H

func (*FTDI232H) Close

func (f *FTDI232H) Close() error

Close shutdowns and reload any drivers

func (*FTDI232H) ConfigPin

func (f *FTDI232H) ConfigPin(pin gpio.Pin, mode gpio.IODirection)

ConfigPin sets the input or output mode for a specified pin. Mode should be either OUT or IN.

func (*FTDI232H) ConfigPinNoWrite

func (f *FTDI232H) ConfigPinNoWrite(pin gpio.Pin, mode gpio.IODirection)

ConfigPinNoWrite sets the input or output mode for a specified pin and does not write to pins

func (*FTDI232H) ConfigPins

func (f *FTDI232H) ConfigPins(pins []gpio.PinConfiguration, write bool)

ConfigPins and write out pins

func (*FTDI232H) Configure

func (f *FTDI232H) Configure(sleepingPoll bool) error

Configure arranges default values for MPSSE.

func (*FTDI232H) EnableMPSSE

func (f *FTDI232H) EnableMPSSE()

EnableMPSSE enables MPSSE mode

func (*FTDI232H) GetLevels

func (f *FTDI232H) GetLevels() uint16

GetLevels gets the currently defined levels

func (*FTDI232H) Initialize

func (f *FTDI232H) Initialize(disableDrivers bool) error

Initialize optionally disables any conflicting drivers.

func (*FTDI232H) Open

func (f *FTDI232H) Open(channel ftdi.Channel) error

Open opens the first device on a specific channel.

func (*FTDI232H) OpenFirst

func (f *FTDI232H) OpenFirst() error

OpenFirst opens the first known FTDI device

func (*FTDI232H) Output

func (f *FTDI232H) Output(pin gpio.Pin, value gpio.PinState) error

Output sets AND writes the specified pin to the provided high/low value. Value should be either HIGH/LOW or a boolean (true = high).

func (*FTDI232H) OutputHigh

func (f *FTDI232H) OutputHigh(pin gpio.Pin) error

OutputHigh sets the pin High AND writes it to the device.

func (*FTDI232H) OutputLow

func (f *FTDI232H) OutputLow(pin gpio.Pin) error

OutputLow sets the pin Low AND writes it to the device.

func (*FTDI232H) PinsRead

func (f *FTDI232H) PinsRead() (byte, error)

PinsRead returns current state of pins (circumventing the read buffer).

func (*FTDI232H) PollRead

func (f *FTDI232H) PollRead(expected int, timeout int64) ([]byte, error)

PollRead reads an expected number of bytes by polling for them. This is a "bit-bang" type of read. [timeout] is specified in seconds. If [timeout] == -1 then timeout = 10 seconds

func (*FTDI232H) ReadInput

func (f *FTDI232H) ReadInput(pin gpio.Pin) gpio.PinState

ReadInput reads the specified pin and returns OutputHigh/true if the pin is pulled high, or OutputLow/false if pulled low.

func (*FTDI232H) ReadInputs

func (f *FTDI232H) ReadInputs() (pins gpio.Pins)

ReadInputs returns all pin data as a 16bit value

func (*FTDI232H) SetBaudrate

func (f *FTDI232H) SetBaudrate(baudRate int) error

SetBaudrate sets the transfer speed

func (*FTDI232H) SetBitmode

func (f *FTDI232H) SetBitmode(iomask byte, mode ftdi.Mode) error

SetBitmode sets bit mode of device

func (*FTDI232H) SetClock

func (f *FTDI232H) SetClock(clock int, adaptive, threePhase bool)

SetClock sets the clock speed. [adaptive] has a typical default of `false`, [threePhase] is typically `false` [clock] is specified in Hertzs (Hz) Set the clock speed of the MPSSE engine. Can be any value from 450hz to 30mhz and will pick that speed or the closest speed below it.

func (*FTDI232H) SetConfigPin

func (f *FTDI232H) SetConfigPin(pin gpio.Pin, mode gpio.IODirection)

SetConfigPin sets the input or output mode for a specified pin. Mode should be either OUT or IN. Note: This does NOT write to the device.

func (*FTDI232H) SetHigh

func (f *FTDI232H) SetHigh(pin gpio.Pin)

SetHigh sets the pin High ONLY.

func (*FTDI232H) SetLow

func (f *FTDI232H) SetLow(pin gpio.Pin)

SetLow sets the pin Low ONLY.

func (*FTDI232H) SetPin

func (f *FTDI232H) SetPin(pin gpio.Pin, value gpio.PinState)

SetPin only sets the buffer pin value. It does NOT write the pin to the device.

func (*FTDI232H) SetPortCPins

func (f *FTDI232H) SetPortCPins(pins byte)

SetPortCPins sets C0-C7 pins.

func (*FTDI232H) SetPortDPins

func (f *FTDI232H) SetPortDPins(pins byte)

SetPortDPins sets D0-D7 pins.

func (*FTDI232H) SetTarget

func (f *FTDI232H) SetTarget(vender, product int)

SetTarget sets device identities.

func (*FTDI232H) SoftConfigure

func (f *FTDI232H) SoftConfigure(sleepingPoll bool) error

SoftConfigure sets default values for BitBang.

func (FTDI232H) String

func (f FTDI232H) String() string

func (*FTDI232H) SubmitRead

func (f *FTDI232H) SubmitRead(expected int) (*ftdi.Transfer, error)

SubmitRead sumbits an int using Transfer

func (*FTDI232H) ToStringFullBinary

func (f *FTDI232H) ToStringFullBinary() string

ToStringFullBinary returns a full report of the component

func (*FTDI232H) Write

func (f *FTDI232H) Write(data []byte) (int, error)

Write writes out a byte array of size determined by the array

func (*FTDI232H) WriteByte

func (f *FTDI232H) WriteByte(data byte) (cnt int, err error)

WriteByte wraps byte in a slice, then writes.

func (*FTDI232H) WriteGPIO

func (f *FTDI232H) WriteGPIO() error

WriteGPIO writes pin data to actual device.

func (*FTDI232H) WriteLen

func (f *FTDI232H) WriteLen(data []byte, length int) (int, error)

WriteLen allows writing of variable length fixed size arrays. Reduces memory allocations

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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