]> Git Repo - pico-vscode.git/blob - scripts/blink.pio
Merge branch 'main' into main
[pico-vscode.git] / scripts / blink.pio
1 ;
2 ; Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
3 ;
4 ; SPDX-License-Identifier: BSD-3-Clause
5 ;
6
7 ; SET pin 0 should be mapped to your LED GPIO
8
9 .program blink
10     pull block
11     out y, 32
12 .wrap_target
13     mov x, y
14     set pins, 1   ; Turn LED on
15 lp1:
16     jmp x-- lp1   ; Delay for (x + 1) cycles, x is a 32 bit number
17     mov x, y
18     set pins, 0   ; Turn LED off
19 lp2:
20     jmp x-- lp2   ; Delay for the same number of cycles again
21 .wrap             ; Blink forever!
22
23
24 % c-sdk {
25 // 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
26
27 void blink_program_init(PIO pio, uint sm, uint offset, uint pin) {
28    pio_gpio_init(pio, pin);
29    pio_sm_set_consecutive_pindirs(pio, sm, pin, 1, true);
30    pio_sm_config c = blink_program_get_default_config(offset);
31    sm_config_set_set_pins(&c, pin, 1);
32    pio_sm_init(pio, sm, offset, &c);
33 }
34 %}
This page took 0.023451 seconds and 4 git commands to generate.