-
Notifications
You must be signed in to change notification settings - Fork 1
/
blink.pio
34 lines (29 loc) · 886 Bytes
/
blink.pio
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
;
; Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
;
; SPDX-License-Identifier: BSD-3-Clause
;
; SET pin 0 should be mapped to your LED GPIO
.program blink
pull block
out y, 32
.wrap_target
mov x, y
set pins, 1 ; Turn LED on
lp1:
jmp x-- lp1 ; Delay for (x + 1) cycles, x is a 32 bit number
mov x, y
set pins, 0 ; Turn LED off
lp2:
jmp x-- lp2 ; Delay for the same number of cycles again
.wrap ; Blink forever!
% go {
// 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)
}
%}