Skip to content
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

embedded_hal::i2c::I2c no longer implemented for async I2c in esp-hal 0.21 #2342

Closed
tomried opened this issue Oct 12, 2024 · 5 comments · Fixed by #2343
Closed

embedded_hal::i2c::I2c no longer implemented for async I2c in esp-hal 0.21 #2342

tomried opened this issue Oct 12, 2024 · 5 comments · Fixed by #2343
Labels
bug Something isn't working peripheral:i2c I2C peripheral

Comments

@tomried
Copy link

tomried commented Oct 12, 2024

Bug description

In commit 00ad9b5eed876bb34a9a4daee8ee587a60425e6d, the embedded_hal::i2c::I2c trait was removed from async I2c and is now only implemented for blocking I2c.

To Reproduce

Try using something requiring the embedded_hal::i2c::I2c trait with an async I2c bus.

Expected behavior

embedded_hal::i2c::I2c should be implemented for blocking and async I2c, as it was in 0.20.1.

Environment

ESP32-S3 with esp-hal 0.21

@tomried tomried added bug Something isn't working status:needs-attention This should be prioritized labels Oct 12, 2024
@github-project-automation github-project-automation bot moved this from Todo to Done in esp-rs Oct 14, 2024
@jessebraham
Copy link
Member

jessebraham commented Oct 16, 2024

FYI we published a patch release today which restores this trait implementation.

@bugadani
Copy link
Contributor

I'm reopening this, just because we are pretty inconsistent with ehal traits in I2C. We implement ehal1::I2c for any mode, but ehal02 traits only for Blocking. We should probably be a bit more consistent, or at least decide whether we want to be intentionally inconsistent.

@bugadani bugadani reopened this Oct 16, 2024
@github-project-automation github-project-automation bot moved this from Done to In Progress in esp-rs Oct 16, 2024
@SergioGasquez SergioGasquez added the peripheral:i2c I2C peripheral label Oct 21, 2024
@bugadani
Copy link
Contributor

bugadani commented Nov 4, 2024

I think there are three questions here, that we should answer and extend that answer to all our peripherals:

  • Do we want to keep embedded-hal 0.2 support? I think yes, it's not a huge amount of work and some old drivers may need it.
  • Do we want to implement blocking embedded-hal (be it 0.2 or 1.0) traits for Async peripherals? I think we should.
  • Do we want to provide blocking inherent methods on Async APIs? We could as _blocking functions, but depending on trait impls it may not be necessary.

If the answer is "yes" to the third, we'd end up with the following, which has some interesting implications to generic code (user code couldn't be generic over Mode, users would be forced to use embedded-hal traits to use blocking APIs of I2C drivers of unknown mode).

impl I2c<Blocking> {
  fn transfer();
}
impl I2c<Async> {
  async fn transfer();
  fn transfer_blocking();
}

The internal implementations would need to be decoupled from the actual API, but that is a relatively small task. Then we could delegate public API as well as trait impls to these internal implementations.

@jessebraham
Copy link
Member

* Do we want to keep embedded-hal 0.2 support? I think yes, it's not a huge amount of work and some old drivers may need it.

I seem to be in the minority, as I have shared this opinion before, but I think there is little value in continuing to implement these. Many of the traits are not even useful, and the 1.0.0 release has been out for nearly a year now. At some point we need to rip off the band-aid and force people to get with the times. Especially if we include these in our release (whenever this happens), we're committing to carrying them around for the duration of the support period.

@MabezDev MabezDev removed the status:needs-attention This should be prioritized label Nov 22, 2024
@MabezDev
Copy link
Member

Closing in favour of #2590

@github-project-automation github-project-automation bot moved this from In Progress to Done in esp-rs Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working peripheral:i2c I2C peripheral
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

5 participants