periph: periph.io/x/periph/conn/spi/spitest Index | Files

package spitest

import "periph.io/x/periph/conn/spi/spitest"

Package spitest is meant to be used to test drivers over a fake SPI port.

Index

Package Files

spitest.go

type Log Uses

type Log struct {
    spi.PortCloser
}

Log logs all operations done on an spi.PortCloser.

func (*Log) Close Uses

func (l *Log) Close() error

Close implements spi.PortCloser.

func (*Log) Connect Uses

func (l *Log) Connect(f physic.Frequency, mode spi.Mode, bits int) (spi.Conn, error)

Connect implements spi.PortCloser.

func (*Log) LimitSpeed Uses

func (l *Log) LimitSpeed(f physic.Frequency) error

LimitSpeed implements spi.PortCloser.

type LogConn Uses

type LogConn struct {
    spi.Conn
}

LogConn logs all operations done on an spi.Conn.

func (*LogConn) Tx Uses

func (l *LogConn) Tx(w, r []byte) error

Tx implements spi.Conn.

func (*LogConn) TxPackets Uses

func (l *LogConn) TxPackets(p []spi.Packet) error

TxPackets is not yet implemented.

type Playback Uses

type Playback struct {
    conntest.Playback
    CLKPin      gpio.PinIO
    MOSIPin     gpio.PinIO
    MISOPin     gpio.PinIO
    CSPin       gpio.PinIO
    Initialized bool
}

Playback implements spi.PortCloser and plays back a recorded I/O flow.

While "replay" type of unit tests are of limited value, they still present an easy way to do basic code coverage.

func (*Playback) CLK Uses

func (p *Playback) CLK() gpio.PinOut

CLK implements spi.Pins.

func (*Playback) CS Uses

func (p *Playback) CS() gpio.PinOut

CS implements spi.Pins.

func (*Playback) Close Uses

func (p *Playback) Close() error

Close implements spi.PortCloser.

Close() verifies that all the expected Ops have been consumed.

func (*Playback) Connect Uses

func (p *Playback) Connect(f physic.Frequency, mode spi.Mode, bits int) (spi.Conn, error)

Connect implements spi.PortCloser.

func (*Playback) LimitSpeed Uses

func (p *Playback) LimitSpeed(f physic.Frequency) error

LimitSpeed implements spi.PortCloser.

func (*Playback) MISO Uses

func (p *Playback) MISO() gpio.PinIn

MISO implements spi.Pins.

func (*Playback) MOSI Uses

func (p *Playback) MOSI() gpio.PinOut

MOSI implements spi.Pins.

type Record Uses

type Record struct {
    sync.Mutex
    Port        spi.PortCloser // Port can be nil if only writes are being recorded.
    Ops         []conntest.IO
    Initialized bool
}

Record implements spi.PortCloser that records everything written to it.

This can then be used to feed to Playback to do "replay" based unit tests.

func (*Record) CLK Uses

func (r *Record) CLK() gpio.PinOut

CLK implements spi.Pins.

func (*Record) CS Uses

func (r *Record) CS() gpio.PinOut

CS implements spi.Pins.

func (*Record) Close Uses

func (r *Record) Close() error

Close implements spi.PortCloser.

func (*Record) Connect Uses

func (r *Record) Connect(f physic.Frequency, mode spi.Mode, bits int) (spi.Conn, error)

Connect implements spi.PortCloser.

func (*Record) LimitSpeed Uses

func (r *Record) LimitSpeed(f physic.Frequency) error

LimitSpeed implements spi.PortCloser.

func (*Record) MISO Uses

func (r *Record) MISO() gpio.PinIn

MISO implements spi.Pins.

func (*Record) MOSI Uses

func (r *Record) MOSI() gpio.PinOut

MOSI implements spi.Pins.

func (*Record) String Uses

func (r *Record) String() string

type RecordRaw Uses

type RecordRaw struct {
    conntest.RecordRaw
    Initialized bool
}

RecordRaw implements spi.PortCloser.

It sends everything written to it to W.

func NewRecordRaw Uses

func NewRecordRaw(w io.Writer) *RecordRaw

NewRecordRaw is a shortcut to create a RecordRaw

func (*RecordRaw) Close Uses

func (r *RecordRaw) Close() error

Close is a no-op.

func (*RecordRaw) Connect Uses

func (r *RecordRaw) Connect(f physic.Frequency, mode spi.Mode, bits int) (spi.Conn, error)

Connect is a no-op.

func (*RecordRaw) LimitSpeed Uses

func (r *RecordRaw) LimitSpeed(f physic.Frequency) error

LimitSpeed is a no-op.

Package spitest imports 8 packages (graph) and is imported by 5 packages. Updated 2018-08-19. Refresh now. Tools for package owners.