-
Notifications
You must be signed in to change notification settings - Fork 171
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
Add spi bus and device options #68
Conversation
src/spi.rs
Outdated
@@ -102,6 +102,9 @@ pub mod config { | |||
pub struct Config { | |||
pub baudrate: Hertz, | |||
pub data_mode: embedded_hal::spi::Mode, | |||
pub no_dummy: bool, | |||
pub dma_channel: u32, |
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.
This is very unsafe in that the user has to consult the ESP-IDF documentation to figure out what to pass. I would prefer an enum
here. Something like:
pub enum DMA {
Disabled,
Channel1,
Channel2,
Auto,
}
And then From<DMA>
implementation for spi_dma_chan_t
.
src/spi.rs
Outdated
@@ -102,6 +102,9 @@ pub mod config { | |||
pub struct Config { | |||
pub baudrate: Hertz, | |||
pub data_mode: embedded_hal::spi::Mode, | |||
pub no_dummy: bool, | |||
pub dma_channel: u32, | |||
pub max_transfer_size: i32, |
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.
i32
? I think we should be using usize
here.
However the real issue is that the SPI driver code is heavily utilizing this, which means that all transfers - including new shiny DMA - are constrained to multiple transactions of 64 bytes each. What is the point of using DMA in the first place, if we'll use it for small chunks of 64 bytes?
I think the PR must be more comprehensive, in that it should inspect all code-paths, and lift the chunking of 64 bytes restriction where possible. Note that this would not be that easy when your read and write buffers are both non-null and of a different size, but should be still quite possible. And would also allow us to get rid of these on-stack allocated buffers of TRANS_LEN
, which seem unnecessary.
Thank you for your suggestions. Anyway, would it be easier to split this PR ? Addressing only |
Absolutely. |
Yeah, I'm struggling with the dummy replacement myself. :( Maybe making it a tad more explicit: |
If we refer to the documentation, maybe something like |
|
I've been sitting on #70 for a while but finally pushed it after seeing this PR, it should help you with the |
Sorry for the delay on this, I was struggling with odd errors with my test setup : I kept only the option to control |
…esp-rs#69) * fixes issue esp-rs#68. reenables compilation of ethernet code * import some imports into experimental mod
Add the possibility to configure:
max_transfer_size
anddma_channels
which can be used to improve even more the transfer by minimizing the number of transfers and use the DMA capabilities of the idf implementation of spiAlso, the goal is to address #64