-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathst7789_parallel_pio.go
46 lines (38 loc) · 1.36 KB
/
st7789_parallel_pio.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Code generated by pioasm; DO NOT EDIT.
// +build rp2040
package main
import "machine"
// st7789_parallel
const st7789_parallelWrapTarget = 0
const st7789_parallelWrap = 1
var st7789_parallelProgram = machine.PIOProgram{
Instructions: []uint16{
// .wrap_target
0x6008, // 0: out pins, 8 side 0
0xb042, // 1: nop side 1
// .wrap
},
Origin: -1,
}
func st7789_parallelProgramDefaultConfig(offset uint8) machine.PIOStateMachineConfig {
cfg := machine.DefaultStateMachineConfig()
cfg.SetWrap(offset+st7789_parallelWrapTarget, offset+st7789_parallelWrap)
cfg.SetSideSet(1, false, false)
return cfg;
}
// helper function to setup GPIO output and configure the SM to output on needed pins
func parallelST7789Init(sm *machine.PIOStateMachine, offset uint8, d0_pin machine.Pin, wr_pin machine.Pin) {
d0_pin.Configure(machine.PinConfig{Mode: machine.PinPIO0})
sm.SetConsecutivePinDirs(d0_pin, 8, true)
cfg := st7789_parallelProgramDefaultConfig(offset)
cfg.SetSetPins(d0_pin, 8)
cfg.SetSidePins(wr_pin)
cfg.SetFIFOJoin(machine.PIO_FIFO_JOIN_TX)
cfg.SetOutShift(false, true, 8)
maxPIOClk := uint32(32 * machine.MHz)
sysClkHz := machine.CPUFrequency()
clkDiv := (sysClkHz + maxPIOClk -1) / maxPIOClk
cfg.SetClkDivIntFrac(uint16(clkDiv), 1)
sm.Init(offset, &cfg)
sm.SetEnabled(true)
}