-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Allow (unpadded) SPI transfers < 8bits #5542
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
base: master
Are you sure you want to change the base?
Conversation
I have not yet changed the SPI object method signatures, pending a comment from @dpgeorge here: #5225 (comment) |
TODO:
|
What is the performance impact here? E.g. with adding a division into spi_transfer on low-end uC's without HW div? Also, is there no doc update warranted? |
Don't know. Is there current performance metrics to compare against?
Definitely warranted. Added to the TODO. Not all platforms can support per-transaction bit widths in hardware, and for those platforms that do, there's work to be done to implement it, or at least document that it isn't supported on those platforms. @mirko, can you help with documentation? |
I have some displays that use 9-bit SPI, with that extra bit being the data/command bit. |
@mcauser The idea is to allow transfer sizes granular to the bit level. Right now, we're going to support softspi and ESP32. Other HW platforms may have this in the future. Short answer: yes. |
@MrSurly happy to help with docs, got sick for the moment though. Just stating that I follow and highly appreciate that PR. Will give it a test (and think about the docs) as soon as recovered. |
No worries. Get well. I think I'm done with soft SPI, and working on ESP32 at the moment. |
I removed the NRF definitions of |
I might be able to but, to be honest, software SPI on nrf might not be that important. It has very flexible routing of SPI blocks to pins so software fallback should be pretty rare for this chip (hence enabling it by default in mpportconfig). |
@daniel-thompson The softSPI code in extmod will call whatever init or transfer function is defined. For NRF (and ESP32 hw SPI), when you call In NRF, it simply replaced all of the softSPI xfer functions with it's own, which was unnecessary since they were identical to the softSPI versions. "removing" them doesn't functionally change anything in NRF, but it does mean that the method signatures in The method signatures in Essentially, this change removed unnecessary code while keeping the exact same functionality (I hope), and simplifying the implementation. |
Did some basic testing on ESP32 with hardware as well as software SPI stack with various wordsizes in the same session. Patterns captured by LA as expected. |
fcbb05e
to
494ecaf
Compare
928db29
to
494ecaf
Compare
*/*spi.h Support for odd bit lengths in SPI, per discussion at micropython#5225
494ecaf
to
e0f4d2b
Compare
Codecov Report
@@ Coverage Diff @@
## master #5542 +/- ##
==========================================
- Coverage 98.27% 98.24% -0.04%
==========================================
Files 154 154
Lines 20076 20007 -69
==========================================
- Hits 19730 19656 -74
- Misses 346 351 +5
Continue to review full report at Codecov.
|
*/*spi.h Support for odd bit lengths in SPI, per discussion at micropython#5225 Updated to 1.17
*/*spi.h Support for odd bit lengths in SPI, per discussion at micropython#5225 Updated to 1.17
…to fix-5225-upstream
…n-main Translations update from Weblate
Thanks for the PR @MrSurly @dpgeorge, @projectgus and I were just talking about this. We're considering merging this if you're still interested in updating it, but need to address the following:
To expand on (2): spi = machine.SPI(..., bits=3)
spi.write(b'\x07\x02\x04', bits=7) would write the bit pattern spi = machine.SPI(..., bits=8)
spi.write(b'\xaa\x55\x33\x03', bits=26) would write the bit pattern I think this also matches conceptually with the sort of uses cases. i.e. you're using SPI to send an N-bit payload, that's packed into M-bits per byte. cc @mirko |
I'm definitely (still) interested and kept maintaining that PR locally, as I'm heavily using this. |
And at least this commit would need to be applied as well, as otherwise this results in corrupted SPI transfers: |
This is an automated heads-up that we've just merged a Pull Request See #13763 A search suggests this PR might apply the STATIC macro to some C code. If it Although this is an automated message, feel free to @-reply to me directly if |
From #5225, as described by @mirko