mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-12 15:03:41 +00:00
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:
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user