-
-
Notifications
You must be signed in to change notification settings - Fork 804
SPI-PIO for RP2040 #4378
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SPI-PIO for RP2040 #4378
Conversation
…, which is what the makefile uses
merge new tock changes
brghena
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One spelling nit, but otherwise this looks good to me
chips/rp2040/src/pio_spi.rs
Outdated
| /** | ||
| * The following programs are in PIO asm | ||
| * SPI_CPHA0 and SPI_CPHA1 are sourced from pico examples | ||
| * https://github.com/raspberrypi/pico-examples/blob/master/pio/spi/spi.pio | ||
| * | ||
| * For the idle high clock programs, we took inspiration of how Zephyr did it | ||
| * which was the simple change of swapping when the side set pin outputs 0 or 1 | ||
| * https://github.com/zephyrproject-rtos/zephyr/blob/main/drivers/spi/spi_rpi_pico_pio.c | ||
| * | ||
| * for further reference consult the RP2040 datasheet chapter 3 (especially sections 3.4 and 3.6) | ||
| * https://datasheets.raspberrypi.com/rp2040/rp2040-datasheet.pdf | ||
| * | ||
| * One can compile pioasm programs locally using the official pico sdk, | ||
| * Or you can use the following website and copy the hex output | ||
| * https://wokwi.com/tools/pioasm | ||
| */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you move this to the //! comments?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably // not //!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went with //
Pull Request Overview
Adds:
SPI driver built on the Programmable IO unit on the RP2040, located in chips/rp2040/src/pio_spi.rs
Fixes:
PIO clear instruction registers function now also clears the bitmap used to keep track of which registers were filled.
IRQ0 Interrupt status register declaration was fixed to have the correct bit offsets for each field (previously all fields had offset 0).
both of these are in chips/rp2040/src/pio.rs
Testing Strategy
We instantiated a PIO SPI and had it write out several strings of bytes to a Saleae logic analyzer set to SPI mode. We used the Saleae to verify that the clock frequencies, clock phase, clock polarity, chip select, and the writing of bytes worked.
For reading and asynchronous reads/writes, we instantiated two different PIO SPIs and wrapped them each in a testing capsule (not included in this PR) and had them send each other an array of bytes asynchronously.
TODO or Help Wanted
N/A
Documentation Updated
/docs, or no updates are required.Formatting
make prepush.Co-author
Jason Hu jasonhu2026@u.northwestern.edu