spi

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

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

Go to latest
Published: Apr 20, 2015 License: MIT Imports: 6 Imported by: 1

Documentation

Index

Constants

View Source
const (
	CPHA       uint8 = 0x01 /* clock phase */
	CPOL       uint8 = 0x02 /* clock polarity */
	CS_HIGH    uint8 = 0x04 /* chipselect active high? */
	LSB_FIRST  uint8 = 0x08 /* per-word bits-on-wire */
	THREE_WIRE uint8 = 0x10 /* SI/SO signals shared */
	LOOP       uint8 = 0x20 /* loopback mode */
)
View Source
const (
	NO_CS   = 0x40  /* 1 dev/bus, no chipselect */
	READY   = 0x80  /* slave pulls low to pause */
	TX_DUAL = 0x100 /* transmit with 2 wires */
	TX_QUAD = 0x200 /* transmit with 4 wires */
	RX_DUAL = 0x400 /* receive with 2 wires */
	RX_QUAD = 0x800 /* receive with 4 wires */
)

not used yet

Variables

This section is empty.

Functions

func Init

func Init(deviceTree string)

Types

type Mode

type Mode uint8

SPI mode as two bit pattern of Clock Polarity and Phase [CPOL|CPHA] min: 0b00 = 0 max: 0b11 = 3

const (
	MODE_0 Mode = 0 /* (original MicroWire) */
	MODE_1 Mode = Mode(CPHA)
	MODE_2 Mode = Mode(CPOL)
	MODE_3 Mode = Mode(CPOL | CPHA)
)

type SPI

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

func NewSPI

func NewSPI(bus, device int) (spi *SPI, err error)

NewSPI returns a new SPI object that is connected to the specified SPI device interface.

NewSPI(X,Y) will open /dev/spidev-X.Y

SPI is an object type that allows SPI transactions on hosts running the Linux kernel. The host kernel must have SPI support and SPI device interface support. All of these can be either built-in to the kernel, or loaded from modules.

Because the SPI device interface is opened R/W, users of this module usually must have root permissions.

func (*SPI) BitsPerWord

func (spi *SPI) BitsPerWord() uint8

func (*SPI) CSHigh

func (spi *SPI) CSHigh() bool

CS active high

func (*SPI) Close

func (spi *SPI) Close() error

Disconnects the object from the interface.

func (*SPI) LSBFirst

func (spi *SPI) LSBFirst() bool

func (*SPI) Loop

func (spi *SPI) Loop() bool

Loop returns the loopback configuration.

func (*SPI) MaxSpeedHz

func (spi *SPI) MaxSpeedHz() uint32

func (*SPI) Mode

func (spi *SPI) Mode() Mode

func (*SPI) Read

func (spi *SPI) Read(data []byte) (n int, err error)

Read len(data) bytes from SPI device.

func (*SPI) SetBitsPerWord

func (spi *SPI) SetBitsPerWord(bits uint8) error

func (*SPI) SetCSHigh

func (spi *SPI) SetCSHigh(csHigh bool) error

CS active high

func (*SPI) SetLSBFirst

func (spi *SPI) SetLSBFirst(lsbFirst bool) error

func (*SPI) SetLoop

func (spi *SPI) SetLoop(loop bool) error

SetLoop sets the loopback configuration.

func (*SPI) SetMaxSpeedHz

func (spi *SPI) SetMaxSpeedHz(maxSpeedHz uint32) error

func (*SPI) SetMode

func (spi *SPI) SetMode(mode Mode) error

func (*SPI) SetThreeWire

func (spi *SPI) SetThreeWire(threeWire bool) error

func (*SPI) ThreeWire

func (spi *SPI) ThreeWire() bool

func (*SPI) Write

func (spi *SPI) Write(data []byte) (n int, err error)

Write data to SPI device.

func (*SPI) Xfer

func (spi *SPI) Xfer(txBuf []byte, delay_usecs uint16) (rxBuf []byte, err error)

Xfer performs a SPI transaction. CS will be released and reactivated between blocks. delay specifies delay in usec between blocks.

func (*SPI) Xfer2

func (spi *SPI) Xfer2(txBuf []byte, delay_usecs uint16) (rxBuf []byte, err error)

Xfer2 performs a SPI transaction. CS will be held active between blocks.

Jump to

Keyboard shortcuts

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