Skip to content

Conversation

@AnthonyAlvarez08
Copy link
Contributor

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

  • Updated the relevant files in /docs, or no updates are required.

Formatting

  • Ran make prepush.
Co-author

Jason Hu jasonhu2026@u.northwestern.edu

brghena
brghena previously approved these changes Mar 24, 2025
Copy link
Contributor

@brghena brghena left a 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

alevy
alevy previously approved these changes Mar 24, 2025
Comment on lines 28 to 43
/**
* 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
*/
Copy link
Contributor

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?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably // not //!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went with //

@alevy alevy added the last-call Final review period for a pull request. label Mar 26, 2025
@alevy alevy added this pull request to the merge queue Mar 27, 2025
Merged via the queue into tock:master with commit 2aa27c9 Mar 27, 2025
13 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

last-call Final review period for a pull request.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants