Created
November 1, 2022 09:15
-
-
Save justacec/39a5c67af8b0737735739378422b7274 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Initialize and start PIO | |
let (mut pio, sm0, sm1, _, _) = pac.PIO0.split(&mut pac.RESETS); | |
let program_sm0 = pio_proc::pio_file!("src/pio0.pio", select_program("morse")); | |
let installed_sm0 = pio.install(&program_sm0.program).unwrap(); | |
info!("sm0 offset: {}", installed_sm0.offset()); | |
let (mut sm_0, _, _) = pio::PIOBuilder::from_program(installed_sm0) | |
.set_pins(led_pin_id, 1) | |
.clock_divisor(50000.0) | |
.build(sm0); | |
let program_sm1 = pio_proc::pio_file!("src/pio0.pio", select_program("delay")); | |
let installed_sm1 = pio.install(&program_sm1.program).unwrap(); | |
info!("sm1 offset: {}", installed_sm1.offset()); | |
let (mut sm_1, _, _) = pio::PIOBuilder::from_program(installed_sm1) | |
.clock_divisor(50000.0) | |
.build(sm1); | |
// The GPIO pin needs to be configured as an output. | |
sm_0.set_pindirs([(led_pin_id, pio::PinDir::Output)]); | |
// let sm = sm_0.with(sm_1); | |
// sm.sync().start(); | |
sm_0.start(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.program morse | |
.wrap_target | |
get_data: | |
;pull | |
on_state: | |
; 3 clock cycles | |
set x 1 | |
set pins 1 | |
; Tunable parameter for timing | |
nop [0] | |
;jmp delay | |
off_state: | |
; 3 clock cycles | |
set x 0 | |
set pins 0 | |
; Tunable parameter for timing | |
nop [0] | |
;jmp delay | |
delay: | |
;irq wait 4 | |
;jmp x-- off_state | |
.wrap | |
.program delay | |
.wrap_target | |
wait 1 irq 4 | |
set y 17 | |
delay1: | |
nop [31] | |
nop [31] | |
jmp y-- delay1 | |
irq clear 4 | |
.wrap |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment