spim

package
v0.5.6 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2024 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config uint8
const (
	MSBF  Config = 0 << 0 // Most significant bit first.
	LSBF  Config = 1 << 0 // Least significant bit first.
	CPHA0 Config = 0 << 1 // Sample on leading edge.
	CPHA1 Config = 1 << 1 // Sample on trailing edge.
	CPOL0 Config = 0 << 2 // Clock idle state is 0.
	CPOL1 Config = 1 << 2 // Clock idle state is 1.
)

type Driver

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

func NewDriver

func NewDriver(p *Periph) *Driver

NewDriver returns a new driver for p.

func (*Driver) Disable

func (d *Driver) Disable()

Disable disables SPIM peripheral.

func (*Driver) Enable

func (d *Driver) Enable()

Enable enables SPIM peripheral.

func (*Driver) IRQ

func (d *Driver) IRQ() rtos.IRQ

IRQ returns the interrupt assigned to UART peripheral used by driver.

func (*Driver) ISR

func (d *Driver) ISR()

func (*Driver) Periph

func (d *Driver) Periph() *Periph

func (*Driver) Setup

func (d *Driver) Setup(cfg Config, f Freq)

Setup sets the SPI mode and clock frequency.

func (*Driver) UsePin

func (d *Driver) UsePin(pin gpio.Pin, s Signal)

UsePin configurs the specified pin to be used as signal s.

func (*Driver) WriteRead

func (d *Driver) WriteRead(out, in []byte) int

type Event

type Event uint8
const (
	STOPPED Event = 1  // SPI transaction has stopped.
	ENDRX   Event = 4  // End of RXD buffer reached.
	END     Event = 6  // End of RXD buffer and TXD buffer reached.
	ENDTX   Event = 8  // End of TXD buffer reached.
	STARTED Event = 19 // Transaction started.
)

type Freq

type Freq uint32
const (
	F125kHz Freq = 0x02000000
	F250kHz Freq = 0x04000000
	F500kHz Freq = 0x08000000
	F1MHz   Freq = 0x10000000
	F2MHz   Freq = 0x20000000
	F4MHz   Freq = 0x40000000
	F8MHz   Freq = 0x80000000
	F16MHz  Freq = 0x0A000000 // SPIM3 only.
	F32MHz  Freq = 0x14000000 // SPIM3 only.
)

type Periph

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

func SPIM

func SPIM(n int) *Periph

func (*Periph) ClearSTALSTAT

func (p *Periph) ClearSTALSTAT()

ClearSTALSTAT clears stall status. SPIM3 only.

func (*Periph) Event

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

func (*Periph) LoadCONFIG

func (p *Periph) LoadCONFIG() Config

LoadCONFIG returns the SPI protocol configuration.

func (*Periph) LoadCSNDUR

func (p *Periph) LoadCSNDUR() int

LoadCSNDUR returns the number of 64 MHz clock cycles of minimum duration between edge of CSN and edge of SCK and minimum duration CSN must stay high between transactions. SPIM3 only.

func (*Periph) LoadCSNPOL

func (p *Periph) LoadCSNPOL() int

LoadCSNPOL returns CSN polarity (0: active low, 1 active high). SPIM3 only.

func (*Periph) LoadDCXCNT

func (p *Periph) LoadDCXCNT() int

LoadDCXCNT returns the number of command bytes preceding the data bytes. SPIM3 only.

func (*Periph) LoadENABLE

func (p *Periph) LoadENABLE() bool

LoadENABLE reports whether the UART peripheral is enabled.

func (*Periph) LoadFREQUENCY

func (p *Periph) LoadFREQUENCY() Freq

LoadFREQUENCY returns SPI frequency (SCK clock).

func (*Periph) LoadORC

func (p *Periph) LoadORC() byte

LoadORC returns the value transmitted after TXD.MAXCNT bytes have been transmitted in the case when RXD.MAXCNT is greater than TXD.MAXCNT.

func (*Periph) LoadPSEL

func (p *Periph) LoadPSEL(s Signal) (psel gpio.PSEL, en bool)

LoadPSEL returns configuration of signal s.

func (*Periph) LoadRXDAMOUNT

func (p *Periph) LoadRXDAMOUNT() int

LoadRXDAMOUNT returns the Number of bytes transferred in the last Rx transaction

func (*Periph) LoadRXDELAY

func (p *Periph) LoadRXDELAY() int

LoadRXDELAY returns the number of 64 MHz clock cycles delay from sampling edge of SCK until the input serial data is sampled. SPIM3 only.

func (*Periph) LoadRXDLIST

func (p *Periph) LoadRXDLIST() bool

LoadRXDLIST reports EasyDMA array list mode for received data.

func (*Periph) LoadRXDMAXCNT

func (p *Periph) LoadRXDMAXCNT() int

LoadRXDMAXCNT returns the maximum number of bytes in receive buffer.

func (*Periph) LoadRXDPTR

func (p *Periph) LoadRXDPTR() uintptr

LoadRXDPTR returns the Rx data pointer.

func (*Periph) LoadSHORTS

func (p *Periph) LoadSHORTS() Shorts

func (*Periph) LoadSTALSTAT

func (p *Periph) LoadSTALSTAT() (rx, tx bool)

LoadSTALSTAT returns stall status for EasyDMA acesses. SPIM3 only.

func (*Periph) LoadTXDAMOUNT

func (p *Periph) LoadTXDAMOUNT() int

LoadTXDAMOUNT returns the number of bytes transferred in the last Tx transaction

func (*Periph) LoadTXDLIST

func (p *Periph) LoadTXDLIST() bool

LoadTXDLIST reports EasyDMA array list mode for transmitted data.

func (*Periph) LoadTXDMAXCNT

func (p *Periph) LoadTXDMAXCNT() int

LoadTXDMAXCNT returns the maximum number of bytes in transmit buffer.

func (*Periph) StoreCONFIG

func (p *Periph) StoreCONFIG(cfg Config)

StoreCONFIG sets the SPI protocol configuration.

func (*Periph) StoreCSNDUR

func (p *Periph) StoreCSNDUR(csndur int)

StoreCSNDUR sets the number of 64 MHz clock cycles [0..255] of minimum duration between edge of CSN and edge of SCK and minimum duration CSn must stay high between transactions. SPIM3 only.

func (*Periph) StoreCSNPOL

func (p *Periph) StoreCSNPOL(csnpol int)

StoreCSNPOL sets CSN polarity (0: active low, 1 active high). SPIM3 only.

func (*Periph) StoreDCXCNT

func (p *Periph) StoreDCXCNT(dcxcnt int)

StoreDCXCNT sets the number of command bytes preceding the data bytes. SPIM3 only.

func (*Periph) StoreENABLE

func (p *Periph) StoreENABLE(en bool)

StoreENABLE enables or disables UART peripheral.

func (*Periph) StoreFREQUENCY

func (p *Periph) StoreFREQUENCY(f Freq)

StoreFREQUENCY sets SPI frequency (SCK clock).

func (*Periph) StoreORC

func (p *Periph) StoreORC(orc byte)

StoreORC sets the value transmitted after TXD.MAXCNT bytes have been transmitted in the case when RXD.MAXCNT is greater than TXD.MAXCNT.

func (*Periph) StorePSEL

func (p *Periph) StorePSEL(s Signal, psel gpio.PSEL, en bool)

StorePSEL configures signal s.

func (*Periph) StoreRXDELAY

func (p *Periph) StoreRXDELAY(rxdelay int)

StoreRXDELAY sets the number of 64 MHz clock cycles [0..7] delay from sampling edge of SCK until the input serial data is sampled. SPIM3 only.

func (*Periph) StoreRXDLIST

func (p *Periph) StoreRXDLIST(arrayListMode bool)

StoreRXDLIST enables/disables EasyDMA array list mode for received data.

func (*Periph) StoreRXDMAXCNT

func (p *Periph) StoreRXDMAXCNT(n int)

StoreRXDMAXCNT sets the maximum number of bytes in receive buffer.

func (*Periph) StoreRXDPTR

func (p *Periph) StoreRXDPTR(ptr unsafe.Pointer)

StoreRXDPTR sets the Rx data pointer.

func (*Periph) StoreSHORTS

func (p *Periph) StoreSHORTS(s Shorts)

func (*Periph) StoreTXDLIST

func (p *Periph) StoreTXDLIST(arrayListMode bool)

StoreTXDLIST enables/disables EasyDMA array list mode for transmitted data.

func (*Periph) StoreTXDMAXCNT

func (p *Periph) StoreTXDMAXCNT(n int)

StoreTXDMAXCNT sets the maximum number of bytes in transmit buffer.

func (*Periph) StoreTXDPTR

func (p *Periph) StoreTXDPTR(ptr unsafe.Pointer)

StoreTXDPTR sets the Tx data pointer.

func (*Periph) Task

func (p *Periph) Task(t Task) *te.Task

type Shorts

type Shorts uint32
const (
	END_START Shorts = 1 << 17
)

type Signal

type Signal uint8
const (
	SCK  Signal = 0
	MOSI Signal = 1
	MISO Signal = 2
	CSN  Signal = 3 // SPIM3 only.
	DCX  Signal = 4 // SPIM3 only.
)

type Task

type Task uint8
const (
	START   Task = 4 // Start SPI transaction.
	STOP    Task = 5 // Stop SPI transaction.
	SUSPEND Task = 7 // Suspend SPI transaction.
	RESUME  Task = 8 // Resume SPI transaction.
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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