-
Notifications
You must be signed in to change notification settings - Fork 2k
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
cpu/rpx0xx: implement periph_spi #19440
Conversation
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.
@fengelhardt Thanks for your contribution !
It already looks really good. I'll try to prepare a quick setup with a sensor or something to give it a try.
I gave this PR a try using a SPI<->SDCARD adapter. |
Sure! I was not able to find time yet. But in the coming week maybe. |
I think I have addressed everything. Also rebased to current master. |
Cool, only to minor changes and a squash missing, it seems :) |
I'd like to test it one more time. I should have some time for that tomorrow. But I am all for a rebase/squash 👍 |
I just give it another shoot. And it still looks good. |
Cool :) |
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.
ACK, thx :)
Anyone still wanting changes should speak up now ;)
bors merge |
Build failed: |
Huh bors static-tests complained quite a lot. |
bors merge |
Build succeeded! The publicly hosted instance of bors-ng is deprecated and will go away soon. If you want to self-host your own instance, instructions are here. If you want to switch to GitHub's built-in merge queue, visit their help page. |
Thanks for your contribution @fengelhardt ! |
Sure! Looking forward to make further contributions. :) |
Contribution description
This PR adds spi functionality to the
rpx0xx
MCU. It also adds spi configurations to therpi-pico
board'speriph_conf.h
.The RP2040 has two SPI blocks of the PL022 type, which are DMA-capable and can be configured in various modes. The SPI clock can be set from
clock_periph
by means of two clock divisors. With the 125MHz clock of the RPi Pico, only the 100 KHz clock setting can be met exactly. See below.DMA is not supported by this PR by now. Implementation should be easy once someone can add DMA support.
I have set the default pinout for the RPi Pico as follows in
periph_conf.h
:The pinout might be worth discussing. There might be collisions soon when someone also ad I2C support. The only other option for SPI1 already collides with UART1. Maybe it is better to just leave out SPI1 in the default board config.
Testing procedure
I have run the standard tests in
tests/periph_spi
on a self-made RP2040-board, which is more or less a Raspberry Pi Pico clone. I have shorted MISO and MOSI with a wire bridge for running this test.I have also tested spi function with CC1101 wireless transceivers. I was able to communicate successfully between two boards.
Issues/PRs references
Integration of
rpx0xx
peripherals is tracked in issue #15822Achieved SPI Clock Speeds
SPI clock is derived from
clock_periph
by dividing it by two divisors, of which one must be an even number. My current algorithm for finding the divisors is inspired by the method from the Pico SDK, but a bit optimized for speed. With the 125 MHz clock on a RPi Pico, the following SPI clocks are achieved: