-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathblink_pio.go
43 lines (35 loc) · 1.26 KB
/
blink_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
// Code generated by pioasm; DO NOT EDIT.
// +build rp2040
package main
import "machine"
// blink
const blinkWrapTarget = 2
const blinkWrap = 7
var blinkProgram = machine.PIOProgram{
Instructions: []uint16{
0x80a0, // 0: pull block
0x6040, // 1: out y, 32
// .wrap_target
0xa022, // 2: mov x, y
0xe001, // 3: set pins, 1
0x0044, // 4: jmp x--, 4
0xa022, // 5: mov x, y
0xe000, // 6: set pins, 0
0x0047, // 7: jmp x--, 7
// .wrap
},
Origin: -1,
}
func blinkProgramDefaultConfig(offset uint8) machine.PIOStateMachineConfig {
cfg := machine.DefaultStateMachineConfig()
cfg.SetWrap(offset+blinkWrapTarget, offset+blinkWrap)
return cfg;
}
// this is a raw helper function for use by the user which sets up the GPIO output, and configures the SM to output on a particular pin
func blinkProgramInit(sm *machine.PIOStateMachine, offset uint8, pin machine.Pin) {
pin.Configure(machine.PinConfig{Mode: machine.PinPIO0})
sm.SetConsecutivePinDirs(pin, 1, true)
cfg := blinkProgramDefaultConfig(offset)
cfg.SetSetPins(pin, 1)
sm.Init(offset, &cfg)
}