Open mbartlett21 opened 1 year ago
In case it's useful, Pico W communicates with the wifi chip using SPI where MOSI and MISO are the same pin (also used as the interrupt line). It uses the pio to do this.
@peterharperuk So this would be the pertinent code?
https://github.com/raspberrypi/pico-sdk/blob/f396d05f8252d4670d4ea05c8b7ac938ef0cd381/src/rp2_common/pico_cyw43_driver/cyw43_bus_pio_spi.pio#L20-L32 (comments added below with what I can tell)
.program spi_gap01_sample0
.side_set 1
; mb: this only handles the clock and the data pin
; mb: x and y store the transmit and receive bit counts respectively
; mb: clock is low on transmit.
; always transmit multiple of 32 bytes
lp: out pins, 1 side 0
jmp x-- lp side 1
public lp1_end:
set pindirs, 0 side 0 ; mb: set it to read. the first bit read is discarded
nop side 1
lp2:
in pins, 1 side 0
jmp y-- lp2 side 1
public end:
; mb: at the end, there isn't any data still waiting in the fifo, so we pause at lp
; with the clock low
Just wondering, are any of the other PIO programs in that file used? There doesn't seem to be any references to them.
any of the other PIO programs in that file used
No - they were used for bringup and are just kept for reference. Different devices might behave differently and the pio program might need tweaking. The code is in cyw43_spi_transfer and as written currently only supports a) write b) write then read, but that could be fixed I imagine.
For example, communicating with an SSD1677 eink display chip. (Datasheet)
Rather than having separate in/out data pins, they instead have a single SDA bidirectional pin, which depending on the command sent, is written to by either the display or the master. (SDI and SDO in the chart are actually a single pin)