File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -118,3 +118,21 @@ func SetPriority(irq uint32, priority uint32) {
118118 priority = priority << (regpos * 8 ) // bits to set
119119 NVIC .IPR [regnum ] = RegValue ((uint32 (NVIC .IPR [regnum ]) &^ mask ) | priority )
120120}
121+
122+ // DisableInterrupts disables all interrupts, and returns the old state.
123+ //
124+ // TODO: it doesn't actually return the old state, meaning that it cannot be
125+ // nested.
126+ func DisableInterrupts () uintptr {
127+ Asm ("cpsid if" )
128+ return 0
129+ }
130+
131+ // EnableInterrupts enables all interrupts again. The value passed in must be
132+ // the mask returned by DisableInterrupts.
133+ //
134+ // TODO: it doesn't actually use the old state, meaning that it cannot be
135+ // nested.
136+ func EnableInterrupts (mask uintptr ) {
137+ Asm ("cpsie if" )
138+ }
You can’t perform that action at this time.
0 commit comments