package sleep import "mmio" var scr = mmio.NewReg32(0xe000ed10) func EventOnPend() bool { return scr.Bit(4) } func EnableEventOnPend() { scr.SetBit(4) } func DisableEventOnPend() { scr.ClearBit(4) } func SleepDeep() bool { return scr.Bit(2) } func EnableSleepDeep() { scr.SetBit(2) } func DisableSleepDeep() { scr.ClearBit(2) } func SleepOnExit() bool { return scr.Bit(1) }
"sync/barrier" "unsafe" ) // Vector represents element of interrupt table. type Vector struct { handler func() } // VectorFor returns Vector that correspods to the handler. func VectorFor(handler func()) Vector { return Vector{handler} } var ( vto = mmio.NewReg32(0xe000ed08) activeVT []Vector ) // UseTable instructs CPU to use vt as vector table. vt should be properly // aligned. Minimum alignment is 32 words which is enough for up to 16 external // interrupts. For more interrupts, adjust the alignment by rounding up to the // next power of two. UseTable doesn't work for Cortex-M0. // // This function is designed to be used by runtime. You generaly shouldn't use // it if MaxTask > 0 in your linker script. func UseTable(vt []Vector) { activeVT = vt barrier.Memory() vto.Store(uint32(uintptr(unsafe.Pointer(&vt[0])))) }
_ PendSV // prio 5 SysTick // prio 6 ) // First external interrupt const IRQ0 Exce = 16 var ( ise = (*bitReg)(unsafe.Pointer(uintptr(0xe000e100))) ice = (*bitReg)(unsafe.Pointer(uintptr(0xe000e180))) isp = (*bitReg)(unsafe.Pointer(uintptr(0xe000e200))) icp = (*bitReg)(unsafe.Pointer(uintptr(0xe000e280))) iab = (*bitReg)(unsafe.Pointer(uintptr(0xe000e300))) ip = (*byteReg)(unsafe.Pointer(uintptr(0xe000e400))) ics = mmio.NewReg32(0xe000ed04) shp = (*byteReg)(unsafe.Pointer(uintptr(0xe000ed18))) shcs = mmio.NewReg32(0xe000ed24) sti = mmio.NewReg32(0xe000ef00) ) // Enable enables handler for irq. func (e Exce) Enable() { switch { case e >= MemFault && e <= UsageFault: shcs.SetBit(int(18 - UsageFault + e)) case e >= IRQ0: ise.setBit(e - IRQ0) } }
// +build cortexm4f package fpu import "mmio" var cpac = mmio.NewReg32(0xe000ed88) type Perm uint32 const ( Deny Perm = 0 << 20 Priv Perm = 1 << 20 Full Perm = 3 << 20 ) func SetAccess(p Perm) { cpac.StoreBits(uint32(p), 3<<20) } func Access() Perm { return Perm(cpac.LoadBits(3 << 20)) } var fpcc = mmio.NewReg32(0xe000ef34) // SPFlags control/describe FPU state preservation behavior during exception // handling. type SPFlags uint32 const ( DeferSP SPFlags = 1 << iota