device/arm: clear pending interrupts before enabling them

Without this change, a pending interrupt would spuriously trigger
immediately after enabling. This happens if an interrupt is triggered
during flashing (e.g. by DMA), which survives the subsequent reset.

This behaviour matches e.g. `machine.irqSet` in machine_rp2_rp2350.go.

See 7f970a45, whose symptoms were likely caused by spurious interrupts.
This commit is contained in:
Elias Naur
2025-04-11 21:40:56 +02:00
committed by Ron Evans
parent 0fdf08d14f
commit 0f06f59c6e
3 changed files with 10 additions and 2 deletions
+5
View File
@@ -146,6 +146,11 @@ const (
SYST_CALIB_NOREF = 0x80000000 // Bit NOREF.
)
// ClearPendingIRQ clears the pending status of the interrupt.
func ClearPendingIRQ(irq uint32) {
NVIC.ICPR[irq>>5].Set(1 << (irq & 0x1F))
}
// Enable the given interrupt number.
func EnableIRQ(irq uint32) {
NVIC.ISER[irq>>5].Set(1 << (irq & 0x1F))