ryan-summers / shared-bus-rtic

Provides macros and type definitions for using shared-bus in an RTIC application
MIT License
16 stars 3 forks source link

Device implemantation example #8

Closed yann77500 closed 1 year ago

yann77500 commented 1 year ago

Hello, I'am beginer in Rust,

I don't understand how to implement a device. I want to implement a I2C temperature sensor on I2C shared bus with RTIC. Do you have an example to implement a device? Do you know where can I found an example please?

Thank you by advance

ryan-summers commented 1 year ago

If you're interested in implementing the I2C portions specifically, I'd direct you to the awesome-embedded-rust list for some inspiration/examples. This crate only worries about sharing the implementation between multiple RTIC tasks and not the specifics of the device itself :)

ryan-summers commented 1 year ago

Also check out the embedded-hal docs on how to implement it: https://docs.rs/embedded-hal/0.2.7/embedded_hal/blocking/i2c/index.html#device-driver-compatible-only-with-7-bit-addresses

In the example, this crate provides a T (generic type) that implements the e-h traits that you can provide to your driver.

yann77500 commented 1 year ago

Thank you for your links and information. They will help me a lot