mirror of https://github.com/tinygo-org/tinygo.git
Browse Source
This commit adds support for software vectoring in the PLIC interrupt. The interrupt table is created by the compiler, which leads to very compact code while retaining the flexibility that the interrupt API provides.pull/861/head
Ayke van Laethem
5 years ago
committed by
Ron Evans
8 changed files with 152 additions and 21 deletions
@ -0,0 +1,8 @@ |
|||
// +build avr cortexm
|
|||
|
|||
package interrupt |
|||
|
|||
// Register is used to declare an interrupt. You should not normally call this
|
|||
// function: it is only for telling the compiler about the mapping between an
|
|||
// interrupt number and the interrupt handler name.
|
|||
func Register(id int, handlerName string) int |
@ -0,0 +1,18 @@ |
|||
// +build sifive
|
|||
|
|||
package interrupt |
|||
|
|||
import "device/sifive" |
|||
|
|||
// Enable enables this interrupt. Right after calling this function, the
|
|||
// interrupt may be invoked if it was already pending.
|
|||
func (irq Interrupt) Enable() { |
|||
sifive.PLIC.ENABLE[irq.num/32].SetBits(1 << (uint(irq.num) % 32)) |
|||
} |
|||
|
|||
// SetPriority sets the interrupt priority for this interrupt. A higher priority
|
|||
// number means a higher priority (unlike Cortex-M). Priority 0 effectively
|
|||
// disables the interrupt.
|
|||
func (irq Interrupt) SetPriority(priority uint8) { |
|||
sifive.PLIC.PRIORITY[irq.num].Set(uint32(priority)) |
|||
} |
Loading…
Reference in new issue