spi

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SPI

type SPI struct {
	Mu sync.Mutex
	// time between clock edges (i.e. half the cycle time)
	Tclk time.Duration
	Sclk *gpio.Pin
	Ssz  *gpio.Pin
	Mosi *gpio.Pin
	Miso *gpio.Pin
}

SPI represents a device connected to the Raspberry Pi via an SPI bus using 3 or 4 GPIO lines.

Depending on the device, the two data pins, Mosi and Miso, may be tied and connected to a single GPIO pin. This is the basis for bit bashed SPI interfaces using GPIO pins. It is not related to the SPI device drivers provided by Linux.

func New

func New(tclk time.Duration, sclk, ssz, mosi, miso int) *SPI

New creates a SPI.

func (*SPI) ClockIn

func (spi *SPI) ClockIn() gpio.Level

ClockIn clocks in a data bit from the SPI device on Miso. Assumes clock starts high and ends with the rising edge of the next clock. Assumes caller already holds the Mu lock.

func (*SPI) ClockOut

func (spi *SPI) ClockOut(l gpio.Level)

ClockOut clocks out a data bit to the SPI device on Mosi. Assumes clock starts low and ends with the falling edge of the next clock. Assumes caller already holds the Mu lock.

func (*SPI) Close

func (spi *SPI) Close()

Close disables the output pins used to drive the SPI device.

Directories

Path Synopsis
Package mcp3w0c provides device drivers for MCP3004/3008/3204/3208 SPI ADCs.
Package mcp3w0c provides device drivers for MCP3004/3008/3204/3208 SPI ADCs.

Jump to

Keyboard shortcuts

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