RP2040-code/Function Generator/blink.pio

28 wiersze
896 B
Plaintext

.program pio_blink
.wrap_target
set y,0b00001
mov pins, y
set x, 31
label01:
jmp x--, label01 [31]
;
set y,0b00000
mov pins, y
set x, 31
label02:
jmp x--, label02 [31]
.wrap ; Blink forever!
% c-sdk {
// 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
void blink_program_init(PIO pio, uint sm, uint offset, uint pin, uint div) {
pio_gpio_init(pio, pin);
pio_sm_set_consecutive_pindirs(pio, sm, pin, 1, true);
pio_sm_config c = pio_blink_program_get_default_config(offset);
sm_config_set_clkdiv(&c, div); // Set the clock divider for the state machine
sm_config_set_out_pins(&c, pin, 1);
pio_sm_init(pio, sm, offset, &c);
}
%}