From 804dc8b1f99ad0e5aae2b58eebe757bbbf6a016d Mon Sep 17 00:00:00 2001 From: Yannis Huber Date: Thu, 18 Jun 2020 15:26:38 +0200 Subject: [PATCH] maixbit: init fpioa clock at reset --- src/machine/machine_k210.go | 4 ++-- src/runtime/interrupt/interrupt_k210.go | 9 ++++++--- src/runtime/runtime_k210.go | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/machine/machine_k210.go b/src/machine/machine_k210.go index 3e89305e..3c3b506e 100644 --- a/src/machine/machine_k210.go +++ b/src/machine/machine_k210.go @@ -44,10 +44,10 @@ var ( func (fpioa FPIOA) Init() { // Enable APB0 clock. - kendryte.SYSCTL.CLK_EN_CENT.Set(kendryte.SYSCTL_CLK_EN_CENT_APB0_CLK_EN) + kendryte.SYSCTL.CLK_EN_CENT.SetBits(kendryte.SYSCTL_CLK_EN_CENT_APB0_CLK_EN) // Enable FPIOA peripheral. - kendryte.SYSCTL.CLK_EN_PERI.Set(kendryte.SYSCTL_CLK_EN_PERI_FPIOA_CLK_EN) + kendryte.SYSCTL.CLK_EN_PERI.SetBits(kendryte.SYSCTL_CLK_EN_PERI_FPIOA_CLK_EN) } type UART struct { diff --git a/src/runtime/interrupt/interrupt_k210.go b/src/runtime/interrupt/interrupt_k210.go index c75f85ae..a4cf89f5 100644 --- a/src/runtime/interrupt/interrupt_k210.go +++ b/src/runtime/interrupt/interrupt_k210.go @@ -2,13 +2,16 @@ package interrupt -import "device/kendryte" +import ( + "device/kendryte" + "device/riscv" +) // Enable enables this interrupt. Right after calling this function, the // interrupt may be invoked if it was already pending. func (irq Interrupt) Enable() { - // TODO: Use current hartid - kendryte.PLIC.TARGET_ENABLES[0].ENABLE[irq.num/32].SetBits(1 << (uint(irq.num) % 32)) + hartId := riscv.MHARTID.Get() + kendryte.PLIC.TARGET_ENABLES[hartId].ENABLE[irq.num/32].SetBits(1 << (uint(irq.num) % 32)) } // SetPriority sets the interrupt priority for this interrupt. A higher priority diff --git a/src/runtime/runtime_k210.go b/src/runtime/runtime_k210.go index b33ff512..b53ec106 100644 --- a/src/runtime/runtime_k210.go +++ b/src/runtime/runtime_k210.go @@ -100,7 +100,7 @@ func handleInterrupt() { // initPeripherals configures periperhals the way the runtime expects them. func initPeripherals() { - //machine.FPIOA0.Init() + machine.FPIOA0.Init() machine.UART0.Configure(machine.UARTConfig{}) }