spimux

package
v0.0.0-...-6570e0f Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2017 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(port spi.PortCloser, selPin gpio.PinIO) (*Conn, *Conn)

New returns two connections for the provided SPI Conn, the first one using Low for the select pin, and the second using High.

Types

type Conn

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

Conn represents a connection to a device on an SPI bus with a multiplexed chip select.

The purpose of spimux.Conn is to allow two devices to be connected to SPI buses that only have a single chip select line. This is accomplished by placing a demux on the CS line such that a an extra gpio pin can direct the chip select to either of the two devices. The way this functions is that the spimux.Conn Tx function sets the demux select for the appropriate device and then performs a std transaction.

A sample circuit is to use an 74LVC1G19 demux with the SPI CS connected to E, the gpio select pin connected to A, and the CS inputs of the two devices attached to Y0 and Y1 respectively. A pull-down resitor on the A input of the demux is recommended to ensure both CS remain inactive when the SPI CS is not driven.

A limitation of the current implementation is that the speed setting and the configuration (SPI mode and number of bits) is shared between the two devices, i.e., it is not possible to use different settings.

func (*Conn) Close

func (c *Conn) Close() error

Close is a no-op. TODO: close once both spimux are closed.

func (*Conn) DevParams

func (c *Conn) DevParams(maxHz int64, mode spi.Mode, bits int) (spi.Conn, error)

DevParams sets the device parameters and returns itself ('cause it's a Port as well as a Conn).

func (*Conn) Duplex

func (c *Conn) Duplex() conn.Duplex

Duplex implements the spi.Conn interface.

func (*Conn) LimitSpeed

func (c *Conn) LimitSpeed(maxHz int64) error

LimitSpeed is not implemented.

func (*Conn) Tx

func (c *Conn) Tx(w, r []byte) error

Tx sets the select pin to the correct value and calls the underlying Tx.

func (*Conn) TxPackets

func (c *Conn) TxPackets(p []spi.Packet) error

TxPackets is not implemented.

Jump to

Keyboard shortcuts

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