Skip to content

Commit 4dbb5dd

Browse files
committed
nrf: avoid too high priority interrupt on SoftDevice
The highest priority interrupts are reserved by the SoftDevice, the SoftDevice will refuse to start if any of them are used for other purposes.
1 parent 9979743 commit 4dbb5dd

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/machine/machine_nrf.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,15 +145,17 @@ func (p Pin) SetInterrupt(change PinChange, callback func(Pin)) error {
145145

146146
// Set and enable the GPIOTE interrupt. It's not a problem if this happens
147147
// more than once.
148-
interrupt.New(nrf.IRQ_GPIOTE, func(interrupt.Interrupt) {
148+
intr := interrupt.New(nrf.IRQ_GPIOTE, func(interrupt.Interrupt) {
149149
for i := range nrf.GPIOTE.EVENTS_IN {
150150
if nrf.GPIOTE.EVENTS_IN[i].Get() != 0 {
151151
nrf.GPIOTE.EVENTS_IN[i].Set(0)
152152
pin := Pin((nrf.GPIOTE.CONFIG[i].Get() & nrf.GPIOTE_CONFIG_PSEL_Msk) >> nrf.GPIOTE_CONFIG_PSEL_Pos)
153153
pinCallbacks[i](pin)
154154
}
155155
}
156-
}).Enable()
156+
})
157+
intr.SetPriority(0x40) // interrupt priority 2 (highest priority not reserved by the SoftDevice)
158+
intr.Enable()
157159

158160
// Everything was configured correctly.
159161
return nil

0 commit comments

Comments
 (0)