Files
magrob/firmware/base/pio/blink.pio
Pimpest a4691caeed Add firmware code to repo (#8)
* Added primary stepper motor driver code to repo
* Added odometery encoder code to repo
* Added the ability to update encoder wheel ratio via ros service
Co-authored-by: Pimpest <82343504+Pimpest@users.noreply.github.com>
Co-committed-by: Pimpest <82343504+Pimpest@users.noreply.github.com>
2025-04-09 14:49:19 +00:00

31 lines
890 B
Plaintext

.program oscillate
pause:
pull block
out x,32
.wrap_target
pull noblock
out x, 32
mov y, x
set pins, 1 ; Pin ON
jmp y-- lp1 ; Delay for (x + 1) cycles, x is a 32 bit number
jmp pause
lp1:
jmp y-- lp1 ; Delay for (x + 1) cycles, x is a 32 bit number
mov y, x
set pins, 0 [2] ; Pin OFF
lp2:
jmp y-- lp2 ; Delay for the same number of cycles again
.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 oscillate_program_init(PIO pio, uint sm, uint offset, uint pin) {
pio_gpio_init(pio, pin);
pio_sm_set_consecutive_pindirs(pio, sm, pin, 1, true);
pio_sm_config c = oscillate_program_get_default_config(offset);
sm_config_set_set_pins(&c, pin, 1);
pio_sm_init(pio, sm, offset, &c);
}
%}