Improve performance of ILI9341 on ATSAMD5X

This commit is contained in:
sago35
2020-04-27 22:09:03 +09:00
committed by Ron Evans
parent fd9b1ba89b
commit 41694085a1
+14 -6
View File
@@ -5,14 +5,14 @@ package ili9341
import ( import (
"machine" "machine"
"runtime/volatile" "runtime/volatile"
"unsafe"
) )
type parallelDriver struct { type parallelDriver struct {
d0 machine.Pin d0 machine.Pin
wr machine.Pin wr machine.Pin
setPort *uint32 setPort *uint8
setMask uint32
clrPort *uint32 clrPort *uint32
clrMask uint32 clrMask uint32
@@ -46,8 +46,12 @@ func (pd *parallelDriver) configure(config *Config) {
pd.wr.Configure(output) pd.wr.Configure(output)
pd.wr.High() pd.wr.High()
pd.setPort, _ = pd.d0.PortMaskSet() // Calculates the address of the OUT register from the OUTSET register and obtains an address that allows 8-bit access.
pd.setMask = uint32(pd.d0) & 0x1f // OUT : offset = 0x10
// OUTSET : offset = 0x18
setPort, _ := pd.d0.PortMaskSet()
setMask := uint32(pd.d0) & 0x1f
pd.setPort = (*uint8)(unsafe.Pointer(uintptr(unsafe.Pointer(setPort)) - uintptr(8) + uintptr(setMask/8)))
pd.clrPort, _ = (pd.d0).PortMaskClear() pd.clrPort, _ = (pd.d0).PortMaskClear()
pd.clrMask = 0xFF << uint32(pd.d0) pd.clrMask = 0xFF << uint32(pd.d0)
@@ -58,8 +62,12 @@ func (pd *parallelDriver) configure(config *Config) {
//go:inline //go:inline
func (pd *parallelDriver) write8(b byte) { func (pd *parallelDriver) write8(b byte) {
volatile.StoreUint32(pd.clrPort, pd.clrMask) volatile.StoreUint8(pd.setPort, uint8(b))
volatile.StoreUint32(pd.setPort, uint32(b)<<pd.setMask) pd.wrx()
}
//go:inline
func (pd *parallelDriver) wrx() {
volatile.StoreUint32(pd.wrPortClr, pd.wrMaskClr) volatile.StoreUint32(pd.wrPortClr, pd.wrMaskClr)
volatile.StoreUint32(pd.wrPortSet, pd.wrMaskSet) volatile.StoreUint32(pd.wrPortSet, pd.wrMaskSet)
} }