Documentation ¶
Overview ¶
Package spi provides Gobot drivers for spi devices. Uses "golang.org/x/exp/io/spi" for spi Installing:
go get -d -u gobot.io/x/gobot
For further information refer to spi README: https://github.com/hybridgroup/gobot/blob/master/drivers/spi/README.md
Index ¶
- Constants
- func WithBus(bus int) func(Config)
- type Config
- type Connection
- type Connector
- type SPIDevice
- type SPIOperations
- type SpiConnection
- func (c *SpiConnection) Close() error
- func (c *SpiConnection) SetBitOrder(o xspi.Order) error
- func (c *SpiConnection) SetBitsPerWord(bits int) error
- func (c *SpiConnection) SetCSChange(leaveEnabled bool) error
- func (c *SpiConnection) SetDelay(t time.Duration) error
- func (c *SpiConnection) SetMaxSpeed(speed int) error
- func (c *SpiConnection) SetMode(mode xspi.Mode) error
- func (c *SpiConnection) Tx(w, r []byte) error
Constants ¶
const (
// BusNotInitialized is the initial value for a bus
BusNotInitialized = -1
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config interface { // WithBus sets which bus to use WithBus(bus int) // GetBusOrDefault gets which bus to use GetBusOrDefault(def int) int }
Config is the interface which describes how a Driver can specify optional SPI params such as which SPI bus it wants to use.
type Connection ¶
type Connection SPIOperations
Connection is a connection to an SPI device with a specified address on a specific bus. Used as an alternative to the SPI interface. Implements SPIOperations to talk to the device, wrapping the calls in SetAddress to always target the specified device. Provided by an Adaptor by implementing the SPIConnector interface.
type Connector ¶
type Connector interface { // GetConnection returns a connection to device at the specified bus. // Bus numbering starts at index 0, the range of valid buses is // platform specific. GetSpiConnection(busNum, mode int, maxSpeed int64) (device Connection, err error) // GetDefaultBus returns the default SPI bus index GetSpiDefaultBus() int // GetDefaultMode returns the default SPI mode (0/1/2/3) GetSpiDefaultMode() int // GetSpiDefaultMaxSpeed returns the max SPI speed GetSpiDefaultMaxSpeed() int64 }
Connector lets Adaptors provide the interface for Drivers to get access to the SPI buses on platforms that support SPI.
type SPIDevice ¶
type SPIDevice interface { SPIOperations }
SPIDevice is the interface to a specific spi bus
type SPIOperations ¶
type SpiConnection ¶
type SpiConnection struct {
// contains filtered or unexported fields
}
func NewConnection ¶
func NewConnection(bus SPIDevice) (connection *SpiConnection)
NewConnection creates and returns a new connection to a specific spi device on a bus and address
func (*SpiConnection) Close ¶
func (c *SpiConnection) Close() error
func (*SpiConnection) SetBitOrder ¶
func (c *SpiConnection) SetBitOrder(o xspi.Order) error
func (*SpiConnection) SetBitsPerWord ¶
func (c *SpiConnection) SetBitsPerWord(bits int) error
func (*SpiConnection) SetCSChange ¶
func (c *SpiConnection) SetCSChange(leaveEnabled bool) error
func (*SpiConnection) SetMaxSpeed ¶
func (c *SpiConnection) SetMaxSpeed(speed int) error
func (*SpiConnection) Tx ¶
func (c *SpiConnection) Tx(w, r []byte) error