func (p *Periph) StoreORC(orc byte) {
	p.orc.Store(uint32(orc))
}
StoreORC sets the value transmitted after TXD.MAXCNT bytes have been
transmitted in the case when RXD.MAXCNT is greater than TXD.MAXCNT.
package spim
import (
	"embedded/mmio"
	"unsafe"
	"github.com/embeddedgo/nrf5/hal/gpio"
	"github.com/embeddedgo/nrf5/hal/internal"
	"github.com/embeddedgo/nrf5/hal/internal/psel"
	"github.com/embeddedgo/nrf5/hal/te"
	"github.com/embeddedgo/nrf5/p/mmap"
)
type Periph struct {
	te.Regs
	stallstat       mmio.U32
	_               [63]uint32
	enable          mmio.U32
	_               uint32
	psel            [4]psel.Reg
	_               [3]uint32
	frequency       mmio.U32
	_               [3]uint32
	rxdptr          mmio.U32
	rxdmaxcnt       mmio.U32
	rxdamount       mmio.U32
	rxdlist         mmio.U32
	txdptr          mmio.U32
	txdmaxcnt       mmio.U32
	txdamount       mmio.U32
	txdlist         mmio.U32
	config          mmio.U32
	_               [2]uint32
	iftimingrxdelay mmio.U32
	iftimingcsndur  mmio.U32
	csnpol          mmio.U32
	pseldcx         psel.Reg
	dcxcnt          mmio.U32
	_               [19]uint32
	orc             mmio.U32
}
func SPIM(n int) *Periph {
	switch n {
	case 0:
		return (*Periph)(unsafe.Pointer(mmap.SPIM0_BASE))
	case 1:
		return (*Periph)(unsafe.Pointer(mmap.SPIM1_BASE))
	case 2:
		return (*Periph)(unsafe.Pointer(mmap.SPIM2_BASE))
	case 3:
		return (*Periph)(unsafe.Pointer(mmap.SPIM3_BASE))
	}
	return nil
}
type Task uint8
const (
	START   Task = 4  
	STOP    Task = 5  
	SUSPEND Task = 7  
	RESUME  Task = 8  
)
type Event uint8
const (
	STOPPED Event = 1   
	ENDRX   Event = 4   
	END     Event = 6   
	ENDTX   Event = 8   
	STARTED Event = 19  
)
func (p *Periph) Task(t Task) *te.Task    { return p.Regs.Task(int(t)) }
func (p *Periph) Event(e Event) *te.Event { return p.Regs.Event(int(e)) }
type Shorts uint32
const (
	END_START Shorts = 1 << 17
)
func (p *Periph) LoadSHORTS() Shorts   { return Shorts(p.Regs.LoadSHORTS()) }
func (p *Periph) StoreSHORTS(s Shorts) { p.Regs.StoreSHORTS(uint32(s)) }
func (p *Periph) LoadSTALSTAT() (rx, tx bool) {
	stallstat := p.stallstat.Load()
	return stallstat&2 != 0, stallstat&1 != 0
}
func (p *Periph) ClearSTALSTAT() {
	p.stallstat.Store(0)
}
func (p *Periph) LoadENABLE() bool {
	return p.enable.Load() == 7
}
func (p *Periph) StoreENABLE(en bool) {
	p.enable.Store(7 * internal.BoolToUint32(en))
}
type Signal uint8
const (
	SCK  Signal = 0
	MOSI Signal = 1
	MISO Signal = 2
	CSN  Signal = 3  
	DCX  Signal = 4  
)
func (p *Periph) LoadPSEL(s Signal) (psel gpio.PSEL, en bool) {
	if s == DCX {
		return p.pseldcx.Load()
	}
	return p.psel[s].Load()
}
func (p *Periph) StorePSEL(s Signal, psel gpio.PSEL, en bool) {
	if s == DCX {
		p.pseldcx.Store(psel, en)
	} else {
		p.psel[s].Store(psel, en)
	}
}
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  
	F32MHz  Freq = 0x14000000  
)
func (p *Periph) LoadFREQUENCY() Freq {
	return Freq(p.frequency.Load())
}
func (p *Periph) StoreFREQUENCY(f Freq) {
	p.frequency.Store(uint32(f))
}
func (p *Periph) LoadRXDPTR() uintptr {
	return uintptr(p.rxdptr.Load())
}
func (p *Periph) StoreRXDPTR(ptr unsafe.Pointer) {
	p.rxdptr.Store(uint32(uintptr(ptr)))
}
func (p *Periph) LoadRXDMAXCNT() int {
	return int(p.rxdmaxcnt.Load())
}
func (p *Periph) StoreRXDMAXCNT(n int) {
	p.rxdmaxcnt.Store(uint32(n))
}
func (p *Periph) LoadRXDAMOUNT() int {
	return int(p.rxdamount.Load())
}
func (p *Periph) LoadRXDLIST() bool {
	return p.rxdlist.Load() != 0
}
func (p *Periph) StoreRXDLIST(arrayListMode bool) {
	p.rxdlist.Store(internal.BoolToUint32(arrayListMode))
}
func (p *Periph) StoreTXDPTR(ptr unsafe.Pointer) {
	p.txdptr.Store(uint32(uintptr(ptr)))
}
func (p *Periph) LoadTXDMAXCNT() int {
	return int(p.txdmaxcnt.Load())
}
func (p *Periph) StoreTXDMAXCNT(n int) {
	p.txdmaxcnt.Store(uint32(n))
}
func (p *Periph) LoadTXDAMOUNT() int {
	return int(p.txdamount.Load())
}
func (p *Periph) LoadTXDLIST() bool {
	return p.txdlist.Load() != 0
}
func (p *Periph) StoreTXDLIST(arrayListMode bool) {
	p.txdlist.Store(internal.BoolToUint32(arrayListMode))
}
type Config uint8
const (
	MSBF  Config = 0 << 0  
	LSBF  Config = 1 << 0  
	CPHA0 Config = 0 << 1  
	CPHA1 Config = 1 << 1  
	CPOL0 Config = 0 << 2  
	CPOL1 Config = 1 << 2  
)
func (p *Periph) LoadCONFIG() Config {
	return Config(p.config.Load())
}
func (p *Periph) StoreCONFIG(cfg Config) {
	p.config.Store(uint32(cfg))
}
func (p *Periph) LoadRXDELAY() int {
	return int(p.iftimingrxdelay.Load())
}
func (p *Periph) StoreRXDELAY(rxdelay int) {
	p.iftimingrxdelay.Store(uint32(rxdelay))
}
func (p *Periph) LoadCSNDUR() int {
	return int(p.iftimingcsndur.Load())
}
func (p *Periph) StoreCSNDUR(csndur int) {
	p.iftimingcsndur.Store(uint32(csndur))
}
func (p *Periph) LoadCSNPOL() int {
	return int(p.csnpol.Load())
}
func (p *Periph) StoreCSNPOL(csnpol int) {
	p.csnpol.Store(uint32(csnpol))
}
func (p *Periph) LoadDCXCNT() int {
	return int(p.dcxcnt.Load())
}
func (p *Periph) StoreDCXCNT(dcxcnt int) {
	p.dcxcnt.Store(uint32(dcxcnt))
}
func (p *Periph) LoadORC() byte {
	return byte(p.orc.Load())
}