-
Notifications
You must be signed in to change notification settings - Fork 55
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
Transactional read/write via I2C_RDWR ioctl - take 2 #51
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @posborne (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
@andy-sdc confirmed that using this in the implementation of |
Hi @posborne, did you have any chance to look at this? |
Sorry, will try to take a look later today, but bug me again if I haven't submitted a review by tomorrow. |
Hi @posborne, here is the reminder :) |
src/ffi.rs
Outdated
|
||
unsafe { | ||
let n = ioctl::i2c_rdwr(fd, &i2c_data)?; | ||
Ok(n as 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.
Nit: move safe portions of code out of unsafe block.
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.
done.
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.
Changes look very good overall. I left a couple nits to be cleaned up. I'll wait for those but otherwise, I'm happy moving forward with this and can give bors the go-ahead once those are in.
Great, I just fixed them. |
bors r+ |
Ah, haven't set bors up on this one yet. Merging, thanks for the changes! |
44: Implement transactional I2C interface and add example r=ryankurte a=eldruin I implemented the transactional I2C interface from rust-embedded/embedded-hal#223 and added an example with a driver which does a combined Write/Read transaction. This is based on previous work from #33 by @ryankurte, rust-embedded/rust-i2cdev#51 and is similar to #35. Co-authored-by: Diego Barrios Romero <eldruin@gmail.com>
44: Implement transactional I2C interface and add example r=ryankurte a=eldruin I implemented the transactional I2C interface from rust-embedded/embedded-hal#223 and added an example with a driver which does a combined Write/Read transaction. This is based on previous work from #33 by @ryankurte, rust-embedded/rust-i2cdev#51 and is similar to #35. Co-authored-by: Diego Barrios Romero <eldruin@gmail.com>
533: Add eldruin to embedded linux team r=therealprof a=eldruin I was approached by @ryankurte about joining the embedded linux team and I would be happy to. So far I have contributed to `rust-i2cdev` and `linux-embedded-hal` adding support for transactional I2C among other smaller fixes. See: - rust-embedded/rust-i2cdev#51 - rust-embedded/linux-embedded-hal#26 Other than that I guess everyone here knows me already. Nevertheless, please feel free to raise any concerns. Co-authored-by: Diego Barrios Romero <eldruin@gmail.com>
This alternative is based on #50 but goes further and implements the
I2CTransfer
trait forI2CDevice
s.With this proposal, it is possible to use the bus directly and send messages as well as send messages to a existing
I2CDevice
.The most relevant change compared to #50 is in the
I2CMessage
trait, where the address has been separated into a separate method similar towith_flags()
so that the same trait can be used for transfers with anI2CDevice
without having to specify the address repeatedly as this is fixed for a givenI2CDevice
.