mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-21 21:09:02 +00:00
all: add compiler support for interrupts
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.
This commit is contained in:
committed by
Ron Evans
parent
3729fcfa9e
commit
a5ed993f8d
@@ -260,6 +260,7 @@ func writeGo(outdir string, device *Device) error {
|
||||
package {{.pkgName}}
|
||||
|
||||
import (
|
||||
"runtime/interrupt"
|
||||
"runtime/volatile"
|
||||
"unsafe"
|
||||
)
|
||||
@@ -277,6 +278,12 @@ const ({{range .interrupts}}
|
||||
IRQ_max = {{.interruptMax}} // Highest interrupt number on this device.
|
||||
)
|
||||
|
||||
// Map interrupt numbers to function names.
|
||||
// These aren't real calls, they're removed by the compiler.
|
||||
var ({{range .interrupts}}
|
||||
_ = interrupt.Register(IRQ_{{.Name}}, "__vector_{{.Name}}"){{end}}
|
||||
)
|
||||
|
||||
// Peripherals.
|
||||
var ({{range .peripherals}}
|
||||
// {{.Caption}}
|
||||
|
||||
Reference in New Issue
Block a user