esp-rs / esp-hal

no_std Hardware Abstraction Layers for ESP32 microcontrollers
https://docs.esp-rs.org/esp-hal/
Apache License 2.0
751 stars 208 forks source link

I2C: support 10-bit addressing #2507

Open bugadani opened 2 hours ago

bugadani commented 2 hours ago

As noted by https://github.com/esp-rs/esp-hal/issues/2493#issuecomment-2464822742

We have a few options to support 10-bit addressing in inherent methods:

Any other, perhaps better ideas?

Dominaezzz commented 2 hours ago
  • too implicit?

There's some precedence for this in the I8080 driver. Just want to note that the decision made here could also be made there as well, for consistency sake.

  • enum Address {Seven(u8), Ten(u16)}

Might be worth considering whether this can also be reused for the slave driver in future, as that may influence the decision.

bugadani commented 2 hours ago

There's some precedence for this in the I8080 driver

I'm just not entirely in love with the idea that users will need to add _u8 or _u16 at the end of their addresses, always. Though I guess we can implement TryFrom<i32> as well and pick one option (or "narrowest that fits") for a bare numeric literal.