spi

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2020 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Overview

Package spi provides access to the registers of SPI peripheral. It also provides the driver that implements asynchronous and synchronous I/O.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config byte

Config is a bitfield that describes SPI configuration.

const (
	MSBF  Config = 0      // Most significant bit shifted out first.
	LSBF  Config = 1 << 0 // Most significant bit shifted out first.
	CPHA0 Config = 0      // Sample on leading SCK edge, shift data on trailing edge.
	CPHA1 Config = 1 << 1 // Sample on trailing SCK edge, shift data on leading edge.
	CPOL0 Config = 0      // SCK polarity: active high.
	CPOL1 Config = 1 << 2 // SCK polarity: active low.
)

type Event

type Event byte
const (
	READY Event = 2 // TXD byte sent and RXD byte received.
)

type Freq

type Freq uint32

Freq sets

const (
	Freq125k Freq = 0x02000000 // 125 kbps
	Freq250k Freq = 0x04000000 // 250 kbps
	Freq500k Freq = 0x08000000 // 500 kbps
	Freq1M   Freq = 0x10000000 // 1 Mbps
	Freq2M   Freq = 0x20000000 // 2 Mbps
	Freq4M   Freq = 0x40000000 // 4 Mbps
	Freq8M   Freq = 0x80000000 // 8 Mbps
)

type Periph

type Periph struct {
	te.Regs
	// contains filtered or unexported fields
}

func SPI

func SPI(n int) *Periph

func (*Periph) Event

func (p *Periph) Event(e Event) *te.Event

func (*Periph) LoadCONFIG

func (p *Periph) LoadCONFIG() Config

LoadCONFIG returns current SPI configuration.

func (*Periph) LoadENABLE

func (p *Periph) LoadENABLE() bool

LoadENABLE reports whether the SPI peripheral is enabled.

func (*Periph) LoadFREQUENCY

func (p *Periph) LoadFREQUENCY() Freq

LoadFREQUENCY returns configured SCK frequency.

func (*Periph) LoadPSEL

func (p *Periph) LoadPSEL(s Signal) (pin gpio.Pin, connected bool)

LoadPSEL returns configuration of signal s.

func (*Periph) LoadRXD

func (p *Periph) LoadRXD() byte

LoadRX returns data received (double buffered).

func (*Periph) StoreCONFIG

func (p *Periph) StoreCONFIG(c Config)

StoreCONFIG stores SPI configuration..

func (*Periph) StoreENABLE

func (p *Periph) StoreENABLE(en bool)

StoreENABLE enables or disables SPI peripheral.

func (*Periph) StoreFREQUENCY

func (p *Periph) StoreFREQUENCY(f Freq)

StoreFREQUENCY stores SCK frequency.

func (*Periph) StorePSEL

func (p *Periph) StorePSEL(s Signal, pin gpio.Pin, connected bool)

StorePSEL configures signal s.

func (*Periph) StoreTXD

func (p *Periph) StoreTXD(b byte)

StoreTXD stores data to send (double buffered).

type Signal

type Signal byte
const (
	SCK  Signal = 0
	MOSI Signal = 1
	MISO Signal = 2
)

Jump to

Keyboard shortcuts

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