eldruin / xca9548a-rs

Platform-agnostic Rust driver for the TCA954xA and PCA954xA I2C switch/multiplexer family.
Apache License 2.0
3 stars 8 forks source link

Plans to Update to embedded-hal v.1.0? #3

Closed mobergmann closed 1 month ago

mobergmann commented 1 month ago

Hi, I wanted to know if there are plans to update the code to the new embedded-hal version (1.0)? I need to use the embedded_hal_bus crate, especially the embedded_hal_bus::i2c::RefCellDevice struct, which is not compatible with this version of the driver AFAICT, and updating this driver would allow such an usage, I think.

eldruin commented 1 month ago

Definitely. Upgrading should be very simple. Mostly just changing the bounds. You can have a try. Otherwise I will see when I find some time for this.

mobergmann commented 1 month ago

I tried, but it seems that there are more issues.

Fist off, I had to change use embedded_hal::blocking::i2c; to use embedded_hal::i2c;, as all functions are blocking. I am new to rust embedded, so my guess is that that was changed. But there are more issues lingering. For example:

error[E0405]: cannot find trait `Write` in module `i2c`
   --> src/lib.rs:225:15
    |
225 |     I2C: i2c::Write<Error = E>,
    |               ^^^^^ not found in `i2c`

Same for Read and WriteRead

mobergmann commented 1 month ago

Found the migration guide on the trait issue: https://github.com/rust-embedded/embedded-hal/blob/master/docs/migrating-from-0.2-to-1.0.md#trait-unification

mobergmann commented 1 month ago

I think I won't be able to do it myself. I am fairly new to the "advanced" rust features and this crate has many of them. Especially the macros are a bit too much for me. I don't really understand what is happening... Sorry. But I am planning to do some research on macros and traits. I will also stare at the code and who knows, maybe it clicks and I can fix it myself.

eldruin commented 1 month ago

I have done this and have now published version 1.0.0 of this driver :tada: