mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-05 19:43:44 +00:00
maixbit: changes according to feedback
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
#ifdef F_EXTENSION
|
||||
#ifdef __riscv_flen
|
||||
#define NREG 48
|
||||
#define LFREG flw
|
||||
#define SFREG fsw
|
||||
@@ -6,7 +6,7 @@
|
||||
#define NREG 16
|
||||
#endif
|
||||
|
||||
#ifdef RV64
|
||||
#if __riscv_xlen==64
|
||||
#define REGSIZE 8
|
||||
#define SREG sd
|
||||
#define LREG ld
|
||||
@@ -41,7 +41,7 @@ handleInterruptASM:
|
||||
SREG t4, 13*REGSIZE(sp)
|
||||
SREG t5, 14*REGSIZE(sp)
|
||||
SREG t6, 15*REGSIZE(sp)
|
||||
#ifdef F_EXTENSION
|
||||
#ifdef __riscv_flen
|
||||
SFREG f0, (0 + 16)*REGSIZE(sp)
|
||||
SFREG f1, (1 + 16)*REGSIZE(sp)
|
||||
SFREG f2, (2 + 16)*REGSIZE(sp)
|
||||
@@ -76,7 +76,7 @@ handleInterruptASM:
|
||||
SFREG f31,(31 + 16)*REGSIZE(sp)
|
||||
#endif
|
||||
call handleInterrupt
|
||||
#ifdef F_EXTENSION
|
||||
#ifdef __riscv_flen
|
||||
LFREG f0, (31 + 16)*REGSIZE(sp)
|
||||
LFREG f1, (30 + 16)*REGSIZE(sp)
|
||||
LFREG f2, (29 + 16)*REGSIZE(sp)
|
||||
|
||||
+17
-24
@@ -4,6 +4,7 @@ package machine
|
||||
|
||||
import (
|
||||
"device/kendryte"
|
||||
"device/riscv"
|
||||
"errors"
|
||||
"runtime/interrupt"
|
||||
)
|
||||
@@ -33,11 +34,9 @@ const (
|
||||
|
||||
// GPIOHS pin interrupt events.
|
||||
const (
|
||||
PinRising PinChange = iota + 1
|
||||
PinRising PinChange = 1 << iota
|
||||
PinFalling
|
||||
PinToggle
|
||||
PinHigh
|
||||
PinLow = 8
|
||||
PinToggle = PinRising | PinFalling
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -224,12 +223,6 @@ func (p Pin) SetInterrupt(change PinChange, callback func(Pin)) error {
|
||||
if change&PinFalling != 0 {
|
||||
kendryte.GPIOHS.FALL_IE.SetBits(1 << gpioPin)
|
||||
}
|
||||
if change&PinHigh != 0 {
|
||||
kendryte.GPIOHS.HIGH_IE.SetBits(1 << gpioPin)
|
||||
}
|
||||
if change&PinLow != 0 {
|
||||
kendryte.GPIOHS.LOW_IE.SetBits(1 << gpioPin)
|
||||
}
|
||||
|
||||
handleInterrupt := func(inter interrupt.Interrupt) {
|
||||
|
||||
@@ -237,28 +230,28 @@ func (p Pin) SetInterrupt(change PinChange, callback func(Pin)) error {
|
||||
|
||||
if kendryte.GPIOHS.RISE_IE.HasBits(1 << pin) {
|
||||
kendryte.GPIOHS.RISE_IE.ClearBits(1 << pin)
|
||||
kendryte.GPIOHS.RISE_IP.SetBits(1 << pin)
|
||||
// Acknowledge interrupt atomically.
|
||||
riscv.AsmFull(
|
||||
"amoor.w {}, {mask}, {reg}",
|
||||
map[string]interface{}{
|
||||
"mask": uint32(1 << pin),
|
||||
"reg": &kendryte.GPIOHS.RISE_IP.Reg,
|
||||
})
|
||||
kendryte.GPIOHS.RISE_IE.SetBits(1 << pin)
|
||||
}
|
||||
|
||||
if kendryte.GPIOHS.FALL_IE.HasBits(1 << pin) {
|
||||
kendryte.GPIOHS.FALL_IE.ClearBits(1 << pin)
|
||||
kendryte.GPIOHS.FALL_IP.SetBits(1 << pin)
|
||||
// Acknowledge interrupt atomically.
|
||||
riscv.AsmFull(
|
||||
"amoor.w {}, {mask}, {reg}",
|
||||
map[string]interface{}{
|
||||
"mask": uint32(1 << pin),
|
||||
"reg": &kendryte.GPIOHS.FALL_IP.Reg,
|
||||
})
|
||||
kendryte.GPIOHS.FALL_IE.SetBits(1 << pin)
|
||||
}
|
||||
|
||||
if kendryte.GPIOHS.HIGH_IE.HasBits(1 << pin) {
|
||||
kendryte.GPIOHS.HIGH_IE.ClearBits(1 << pin)
|
||||
kendryte.GPIOHS.HIGH_IP.SetBits(1 << pin)
|
||||
kendryte.GPIOHS.HIGH_IE.SetBits(1 << pin)
|
||||
}
|
||||
|
||||
if kendryte.GPIOHS.LOW_IE.HasBits(1 << pin) {
|
||||
kendryte.GPIOHS.LOW_IE.ClearBits(1 << pin)
|
||||
kendryte.GPIOHS.LOW_IP.SetBits(1 << pin)
|
||||
kendryte.GPIOHS.LOW_IE.SetBits(1 << pin)
|
||||
}
|
||||
|
||||
pinCallbacks[pin](Pin(pin))
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#ifdef RV64
|
||||
#if __riscv_xlen==64
|
||||
#define REGSIZE 8
|
||||
#define SREG sd
|
||||
#define LREG ld
|
||||
|
||||
Reference in New Issue
Block a user