Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/pio/spi_slave_sender.pio
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
.program clocked_output

; Send using an external clock on the SPI interface
; - OUT pin 0 is the data pin
; - IN pin 0 is the CLK pin
; - Autopush is enabled, threshold 32
;
; wait 0 pin 1
; Pico is a slave and constantly keeps track of incoming SCK

.wrap_target
out pins 1
wait 1 pin 0
wait 0 pin 0
wait 1 pin 0 ; rising edge: Pi is sampling the current bit
out pins, 1 ; put the NEXT bit on MISO
wait 0 pin 0 ; falling edge: prepare for the next rising edge
.wrap


Expand Down Expand Up @@ -46,6 +42,10 @@ static inline void clocked_output_program_init(PIO pio, uint sm, uint offset, ui

// Load our configuration, and start the program from the beginning
pio_sm_init(pio, sm, offset, &c);

// SPI mode 0 needs to have the first bit preloaded, will break otherwise
pio_sm_exec(pio, sm, pio_encode_out(pio_pins, 1));

pio_sm_set_enabled(pio, sm, true);
}
%}
Loading