github.com/tinygo-org/tinygo@v0.31.3-0.20240404173401-90b0bf646c27/src/runtime/interrupt/interrupt_k210.go (about)

     1  //go:build k210
     2  
     3  package interrupt
     4  
     5  import (
     6  	"device/kendryte"
     7  	"device/riscv"
     8  )
     9  
    10  // Enable enables this interrupt. Right after calling this function, the
    11  // interrupt may be invoked if it was already pending.
    12  func (irq Interrupt) Enable() {
    13  	hartId := riscv.MHARTID.Get()
    14  	kendryte.PLIC.TARGET_ENABLES[hartId].ENABLE[irq.num/32].SetBits(1 << (uint(irq.num) % 32))
    15  }
    16  
    17  // SetPriority sets the interrupt priority for this interrupt. A higher priority
    18  // number means a higher priority (unlike Cortex-M). Priority 0 effectively
    19  // disables the interrupt.
    20  func (irq Interrupt) SetPriority(priority uint8) {
    21  	kendryte.PLIC.PRIORITY[irq.num].Set(uint32(priority))
    22  }
    23  
    24  // GetNumber returns the interrupt number for this interrupt.
    25  func (irq Interrupt) GetNumber() int {
    26  	return irq.num
    27  }