-
Notifications
You must be signed in to change notification settings - Fork 232
spi: add Read and separate-buffers Transfer #287
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
Conversation
r? @therealprof (rust-highfive has picked a reviewer for you, use r? to override) |
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.
Other than my comments below, looks good to me, thanks!
Closes #286
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.
Looks good to me, thanks!
Any objections @rust-embedded/hal ?
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.
thanks for the PR! i'm not convinced all of these are improvements. have left a couple of comments, though it's possible i missed some discussion of this already?
Merge conflicts |
Any chance of this getting into 1.0? |
44e18d2
to
4696969
Compare
Rebased. Now that Default is gone, the diff is much smaller :D |
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.
Other than my nitpicks, looks good to me, thanks!
@ryankurte do you have any further concerns about implementation-defined fill values?
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.
hey generally seems good, one question about the updated docs and, though it appears to be minor changes, i would quite like to see a couple of impls updated to support this to make sure we're not missing anything.
/// The transfer runs for `max(read.len(), write.len())` words. If `read` is shorter, | ||
/// incoming words after `read` has been filled will be discarded. If `write` is shorter, | ||
/// the value of words sent in MOSI after all `write` has been sent is implementation-defined, | ||
/// typically `0x00`, `0xFF`, or configurable. |
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.
has this always been the case or have we implicitly been assuming read.len() == write.len()
? and is this sensible to represent for more complex implementors (ie. using DMA, linux)?
we have Transactional
for building sequences, if you need to do varying length things, it would seem to me to be simpler (or maybe, less surprising to demand the same lengths here?
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.
have we implicitly been assuming read.len() == write.len()?
Before this PR, only the single-buffer Transfer
(now TransferInplace
) existed. Single-buffer already enforced read len = write len
.
The idea for the runs for max(read.len(), write.len())
comes from the nRF SPI DMA, which automatically does this. It's somewhat handy, for example to do "write command byte, read big data" you can make the write buf small (1 byte) and only need memory for a big read buf (1 + N bytes).
I agree it's not that useful if we have TransferInplace or Transactional, and it could be annoying to support using stm32 DMA for example...
If we require same-length for both bufs, do we mandate that impls panic on length mismatch, or return an error?
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 was discussed in today's REWG meeting. TLDR: seems people are OK with differing lengths.
Also the possibility of allowing impls to support it or not was discussed, but IMO it defeats the point since drivers wouldn't be able to use it.
@Dirbaio This is good to go! Could you resolve the conflict? |
151a658
to
459e935
Compare
@eldruin rebased |
459e935
to
db92100
Compare
db92100
to
f972218
Compare
Ach, a new conflict appeared due to the default |
nooooo 🤣 |
f972218
to
d15e817
Compare
@eldruin rebased |
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.
Alright, thanks!
bors merge
Depends on #286Open question
Should Transactional gain Read, Transfer (not-inplace) support?yes, done