File tree Expand file tree Collapse file tree 1 file changed +9
-10
lines changed Expand file tree Collapse file tree 1 file changed +9
-10
lines changed Original file line number Diff line number Diff line change @@ -191,22 +191,21 @@ func SetPriority(irq uint32, priority uint32) {
191191 NVIC .IPR [regnum ].Set ((uint32 (NVIC .IPR [regnum ].Get ()) &^ mask ) | priority )
192192}
193193
194- // DisableInterrupts disables all interrupts, and returns the old state.
195- //
196- // TODO: it doesn't actually return the old state, meaning that it cannot be
197- // nested.
194+ // DisableInterrupts disables all interrupts, and returns the old interrupt
195+ // state.
198196func DisableInterrupts () uintptr {
199- Asm ("cpsid if" )
200- return 0
197+ return AsmFull (`
198+ mrs {}, PRIMASK
199+ cpsid if
200+ ` , nil )
201201}
202202
203203// EnableInterrupts enables all interrupts again. The value passed in must be
204204// the mask returned by DisableInterrupts.
205- //
206- // TODO: it doesn't actually use the old state, meaning that it cannot be
207- // nested.
208205func EnableInterrupts (mask uintptr ) {
209- Asm ("cpsie if" )
206+ AsmFull ("msr PRIMASK, {mask}" , map [string ]interface {}{
207+ "mask" : mask ,
208+ })
210209}
211210
212211// SystemReset performs a hard system reset.
You can’t perform that action at this time.
0 commit comments