mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-03 02:27:48 +00:00
a5ed993f8d
This commit lets the compiler know about interrupts and allows optimizations to be performed based on that: interrupts are eliminated when they appear to be unused in a program. This is done with a new pseudo-call (runtime/interrupt.New) that is treated specially by the compiler.
24 lines
659 B
Go
24 lines
659 B
Go
// +build cortexm
|
|
|
|
package interrupt
|
|
|
|
import (
|
|
"device/arm"
|
|
)
|
|
|
|
// Enable enables this interrupt. Right after calling this function, the
|
|
// interrupt may be invoked if it was already pending.
|
|
func (irq Interrupt) Enable() {
|
|
arm.EnableIRQ(uint32(irq.num))
|
|
}
|
|
|
|
// SetPriority sets the interrupt priority for this interrupt. A lower number
|
|
// means a higher priority. Additionally, most hardware doesn't implement all
|
|
// priority bits (only the uppoer bits).
|
|
//
|
|
// Examples: 0xff (lowest priority), 0xc0 (low priority), 0x00 (highest possible
|
|
// priority).
|
|
func (irq Interrupt) SetPriority(priority uint8) {
|
|
arm.SetPriority(uint32(irq.num), uint32(priority))
|
|
}
|