Merge SpiDma and SpiDmaBus drivers#5272
Conversation
Ah that works. My first thought is how big is the buffer gonna be, but I'll just read the PR. I guess you're closing #3125? |
As much as you give it, I'm not ure about #3125 I'm not actually targeting that issue. |
46e339f to
53d4d59
Compare
|
New commits in main has made this PR unmergable. Please resolve the conflicts. |
53d4d59 to
9594e3e
Compare
|
New commits in main has made this PR unmergable. Please resolve the conflicts. |
9594e3e to
73a920a
Compare
|
New commits in main has made this PR unmergable. Please resolve the conflicts. |
df3e40d to
cd81695
Compare
|
New commits in main has made this PR unmergable. Please resolve the conflicts. |
9ef9f05 to
1abb1b7
Compare
1abb1b7 to
be67f63
Compare
There was a problem hiding this comment.
Pull request overview
This PR consolidates the SPI DMA driver surface by removing the separate SpiDmaBus type and making SpiDma directly support both the slice-based API (copying via internal buffers) and the externally-managed buffer API (via DmaRxBuf/DmaTxBuf), including embedded-hal(-async) trait implementations.
Changes:
- Replace
SpiDmaBususage by moving copy-buffers intoSpiDmaglobal DMA state and exposingSpiDma::with_buffers(...)directly. - Rename DMA buffer-oriented APIs to
_buffer/_bufferssuffixed methods (e.g.read_buffer,transfer_buffers,half_duplex_read_buffer). - Update examples/tests to use the renamed buffer-based methods.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| qa-test/src/bin/qspi_flash.rs | Update QSPI flash QA test to use half_duplex_{read,write}_buffer APIs. |
| hil-test/src/bin/spi_half_duplex_write_psram.rs | Update HIL half-duplex PSRAM test to use half_duplex_write_buffer. |
| hil-test/src/bin/spi_half_duplex_slave_qspi.rs | Update HIL QSPI slave test to use half_duplex_{read,write}_buffer. |
| hil-test/src/bin/spi_full_duplex.rs | Update full-duplex DMA HIL tests to use read_buffer, write_buffer, transfer_buffers. |
| examples/peripheral/spi/loopback_dma_psram/src/main.rs | Update loopback DMA+PSRAM example to use transfer_buffers. |
| esp-hal/src/spi/master/dma.rs | Core refactor: merge SpiDmaBus into SpiDma, add embedded-hal(-async) trait impls, add async slice-based methods, and update buffer handling. |
be67f63 to
6843586
Compare
1e5de94 to
5c10761
Compare
| /// buffers to be transferred. The buffer objects ensure that data is located in appropriate | ||
| /// memory regions. The buffers and the driver object are moved into transfer objects for the | ||
| /// duration of the transfer. These functions take [`DmaRxBuf`] and [`DmaTxBuf`] objects as | ||
| /// arguments as well as the number of bytes to transfer, and their names end with `_buffer`. |
There was a problem hiding this comment.
The SpiDma docs say the buffer-based API method names end with _buffer, but one of the renamed methods is transfer_buffers (plural). Consider tweaking the wording to mention both _buffer and _buffers (or list the method names) to avoid confusion.
| /// arguments as well as the number of bytes to transfer, and their names end with `_buffer`. | |
| /// arguments as well as the number of bytes to transfer, and their names end with `_buffer` or | |
| /// `_buffers`. |
|
New commits in main have made this PR unmergeable. Please resolve the conflicts. |
5c10761 to
a0163f9
Compare
MabezDev
left a comment
There was a problem hiding this comment.
Just some nits, overall LGTM!
| } | ||
|
|
||
| fn flush(&mut self) -> Result<(), Self::Error> { | ||
| // All operations currently flush so this is no-op. |
There was a problem hiding this comment.
Is this a limitation, or a design decision we've made for our ease of impl? IIRC eh discourages early flushing because we can be more efficient by queuing up transfers, but I will admit this nugget of knowledge is a bit fuzzy
There was a problem hiding this comment.
We can't not flush with DMA if we want any semblance of soundness - we can't release the borrow on the buffers before the transfers finish.
We don't need two, when one can do the job. Further work needs to be done:
This PR allows using the buffer-based API together with drivers that require embedded-hal(-async) implementations. It's implemented by adding copy buffers to the global state of the SpiDma driver. These buffers are used in place of EmptyBuf, which is mostly unnecessary at this point.