-
Notifications
You must be signed in to change notification settings - Fork 234
I2c unify #339
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
I2c unify #339
Conversation
r? @eldruin (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.
Seems like a good idea, although the trait has a lot of methods now.
Are we sure it is always possible to implement the iterator methods?
Also, for consistency, if we rename the exec
method in SPI
batch
we should do so here as well.
For stm32, rp2040 yes. For nRF it'd need to drain the iterator into a temp buffer then DMA that out. However there are other cases that nRF has to do similar copies to temp bufs (for example, it can't DMA out of flash, so if TXing from flash it has to be copied to RAM) so I don't think it's that bad. If the iterator methods were separate traits, we'd have the usual problem: some HALs wouldn't impl them, so driver authors wouldn't use them since they want their driver to work everywhere. IMO they should be either in the main trait, or removed.
Agreed they should be consistent! I'm not 100% happy with the |
Yes for writing. Probably not for reading. For correct ending of read operation we need to know length of remaining piece. |
There's no iterator-based reading. |
For this reason it is not there. Same as Transactional. |
@burrbull not sure if I understand. The trait proposed in this PR has a write_iter, but no read_iter, so AFAIK all the methods should be implementable for stm32s. Are you saying a method is not implementable, or just "if there was a read_iter method, it wouldn't be"? |
Oh, sorry. I was sure I'd seen it. |
c71675b
to
dd27ab5
Compare
Renamed |
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.
Great work, thank you!
bors r+
👎 Rejected by too few approved reviews |
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.
bors r+
348: async: add i2c r=eldruin a=Dirbaio This mirrors the blocking i2c trait (including the changes proposed in #339 ), except the following: - Removed all `iter` methods since they don't play well with DMA. Co-authored-by: Dario Nieuwenhuis <[email protected]>
Depends on #336
Equivalent of #323 but for I2c.
I think for i2c unifying everything in a single trait makes the most sense. The i2c bus is specified to be bidirectional, I believe no hardware out there can "only write" or "only read" (and writing requires reading ACK bits anyway!).