mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-20 04:19:04 +00:00
arm: provide intrinsics to disable/enable interrupts
This commit is contained in:
committed by
Ron Evans
parent
6e8df2fc40
commit
714d98354c
@@ -118,3 +118,21 @@ func SetPriority(irq uint32, priority uint32) {
|
|||||||
priority = priority << (regpos * 8) // bits to set
|
priority = priority << (regpos * 8) // bits to set
|
||||||
NVIC.IPR[regnum] = RegValue((uint32(NVIC.IPR[regnum]) &^ mask) | priority)
|
NVIC.IPR[regnum] = RegValue((uint32(NVIC.IPR[regnum]) &^ mask) | priority)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DisableInterrupts disables all interrupts, and returns the old state.
|
||||||
|
//
|
||||||
|
// TODO: it doesn't actually return the old state, meaning that it cannot be
|
||||||
|
// nested.
|
||||||
|
func DisableInterrupts() uintptr {
|
||||||
|
Asm("cpsid if")
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
// EnableInterrupts enables all interrupts again. The value passed in must be
|
||||||
|
// the mask returned by DisableInterrupts.
|
||||||
|
//
|
||||||
|
// TODO: it doesn't actually use the old state, meaning that it cannot be
|
||||||
|
// nested.
|
||||||
|
func EnableInterrupts(mask uintptr) {
|
||||||
|
Asm("cpsie if")
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user