Documentation
¶
Index ¶
- Constants
- type CR0
- type CR1
- type Config
- type DMACR
- type INT
- type Master
- func (d *Master) Baudrate() int
- func (d *Master) Config() Config
- func (d *Master) DMAISR()
- func (d *Master) Disable()
- func (d *Master) Enable()
- func (d *Master) Periph() *Periph
- func (d *Master) Read(s []byte) (n int, err error)
- func (d *Master) Read16(s []uint16) (n int, err error)
- func (d *Master) ReadByte() (b byte, err error)
- func (d *Master) ReadWord16() (w uint16, err error)
- func (d *Master) SetBaudrate(baudrate int) (actual int)
- func (d *Master) SetConfig(cfg Config)
- func (d *Master) SetRepW(repw uint16)
- func (d *Master) Setup(cfg Config, baudrate int) (actualBaud int)
- func (d *Master) UsePin(pin iomux.Pin, sig Signal) bool
- func (d *Master) WaitTxDone()
- func (d *Master) Write(s []byte) (n int, err error)
- func (d *Master) Write16(s []uint16) (n int, err error)
- func (d *Master) WriteByte(b byte) error
- func (d *Master) WriteByteN(b byte, n int)
- func (d *Master) WriteRead(out, in []byte) (n int)
- func (d *Master) WriteRead16(out, in []uint16) (n int)
- func (d *Master) WriteReadByte(b byte) byte
- func (d *Master) WriteReadWord16(w uint16) uint16
- func (d *Master) WriteString(s string) (n int, err error)
- func (d *Master) WriteStringRead(out string, in []byte) int
- func (d *Master) WriteWord16(w uint16) error
- func (d *Master) WriteWord16N(w uint16, n int)
- type Periph
- type SR
- type Signal
Constants ¶
const ( DSSn = 0 FRFn = 4 SPOn = 6 SPHn = 7 SCRn = 8 )
const ( PARTNUMBER1 uint32 = 0x0F << 0 //+ These bits read back as 0x0 DESIGNER0 uint32 = 0x0F << 4 //+ These bits read back as 0x1 )
PERIPHID1 bits
const ( PARTNUMBER1n = 0 DESIGNER0n = 4 )
const ( DESIGNER1 uint32 = 0x0F << 0 //+ These bits read back as 0x4 REVISION uint32 = 0x0F << 4 //+ These bits return the peripheral revision )
PERIPHID2 bits
const ( DESIGNER1n = 0 REVISIONn = 4 )
const ( FrameFormat = Config(FRF) // Frame format: MSPI = Config(0) // - Motorola SPI SyncSerial = Config(FTI) // - Texas Instruments Synchronous Serial Microwire = Config(FNM) // - National Semiconductor Microwire // For Motorola SPI frame format: CPHA0 = Config(0) // sample on leading edge. CPHA1 = Config(SPH) // sample on trailing edge. CPOL0 = Config(0) // clock idle state is 0. CPOL1 = Config(SPO) // clock idle state is 1. WordLen = Config(15) // Data word length: Word4b = Config(3) // - 4 bit Word5b = Config(4) // - 5 bit Word6b = Config(5) // - 6 bit Word7b = Config(6) // - 7 bit Word8b = Config(7) // - 8 bit Word9b = Config(8) // - 9 bit Word10b = Config(9) // - 10 bit Word11b = Config(10) // - 11 bit Word12b = Config(11) // - 12 bit Word13b = Config(12) // - 13 bit Word14b = Config(13) // - 14 bit Word15b = Config(14) // - 15 bit Word16b = Config(15) // - 16 bit )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CR0 ¶
type CR0 uint32
const ( DSS CR0 = 0x0F << 0 //+ Data Size Select: DS4 CR0 = 0x03 << 0 // 4-bit data DS5 CR0 = 0x04 << 0 // 5-bit data DS6 CR0 = 0x05 << 0 // 6-bit data DS7 CR0 = 0x06 << 0 // 7-bit data DS8 CR0 = 0x07 << 0 // 8-bit data DS9 CR0 = 0x08 << 0 // 9-bit data DS10 CR0 = 0x09 << 0 // 10-bit data DS11 CR0 = 0x0A << 0 // 11-bit data DS12 CR0 = 0x0B << 0 // 12-bit data DS13 CR0 = 0x0C << 0 // 13-bit data DS14 CR0 = 0x0D << 0 // 14-bit data DS15 CR0 = 0x0E << 0 // 15-bit data DS16 CR0 = 0x0F << 0 // 16-bit data FRF CR0 = 0x03 << 4 //+ Frame format: FMO CR0 = 0x00 << 4 // Motorola SPI frame format FTI CR0 = 0x01 << 4 // TI synchronous serial frame format FNM CR0 = 0x02 << 4 // National Microwire frame format SPO CR0 = 0x01 << 6 //+ SSPCLKOUT polarity for Motorola SPI frame format. SPH CR0 = 0x01 << 7 //+ SSPCLKOUT phase for Motorola SPI frame format. SCR CR0 = 0xFF << 8 //+ Serial clock rate. )
CR0 bits
type Master ¶
type Master struct { sync.Mutex // helps in case of concurent use of Master (not used internally) // contains filtered or unexported fields }
A Master is a driver to the SPI peripheral used in master mode.
func NewMaster ¶
NewMaster returns a new master-mode driver for p. If valid DMA channels are given, the DMA will be used for bigger data transfers.
func (*Master) DMAISR ¶
func (d *Master) DMAISR()
DMAISR should be configured as a DMA interrupt handler if DMA is used.
func (*Master) Disable ¶
func (d *Master) Disable()
Disable waits for the last bit of the last transfer to be sent and next it disables the SPI peripheral.
func (*Master) ReadWord16 ¶
func (*Master) SetBaudrate ¶
func (*Master) Setup ¶
Setup resets the underlying SPI peripheral and configures it according to the master driver needs. Next it calls the SetConfig and SetBaudrate methods with the provided arguments and enables the peripheral.
func (*Master) UsePin ¶
UsePin is a helper function that can be used to configure IO pins as required by the SPI peripheral. Only certain pins can be used (see datasheet). UsePin returns true on succes or false if it isn't possible to use a pin as a sig. See also Periph.Pins.
func (*Master) WaitTxDone ¶
func (d *Master) WaitTxDone()
func (*Master) WriteByteN ¶
func (*Master) WriteRead ¶
WriteRead writes n = min(len(out), len(in)) bytes to the transmit FIFO. At the same time it reads n bytes into in.
func (*Master) WriteRead16 ¶
WriteRead16 writes n = min(len(out), len(in)) 16-bit words to the transmit FIFO. At the same time it reads n words into in.
func (*Master) WriteReadByte ¶
func (*Master) WriteReadWord16 ¶
func (*Master) WriteString ¶
WriteString implements io.StringWriter.
func (*Master) WriteStringRead ¶
WriteStringRead works like WriteRead but writes a string.
func (*Master) WriteWord16 ¶
func (*Master) WriteWord16N ¶
type Periph ¶
type Periph struct { CR0 mmio.R32[CR0] CR1 mmio.R32[CR1] DR mmio.U32 SR mmio.R32[SR] CPSR mmio.U32 IMSC mmio.R32[INT] RIS mmio.R32[INT] MIS mmio.R32[INT] ICR mmio.R32[INT] DMACR mmio.R32[DMACR] PERIPHID0 mmio.U32 PERIPHID1 mmio.U32 PERIPHID2 mmio.U32 PERIPHID3 mmio.U32 PCELLID0 mmio.U32 PCELLID1 mmio.U32 PCELLID2 mmio.U32 PCELLID3 mmio.U32 // contains filtered or unexported fields }