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

i2c: implement I2C:transaction for embedded-hal and embedded-hal-async #1505

Merged
merged 13 commits into from
Apr 30, 2024

Conversation

liebman
Copy link
Contributor

@liebman liebman commented Apr 23, 2024

Thank you for your contribution!

We appreciate the time and effort you've put into this pull request.
To help us review it efficiently, please ensure you've gone through the following checklist:

Submission Checklist 📝

  • I have updated existing examples or added new ones (if applicable).
  • My changes were added to the CHANGELOG.md in the proper section.

Extra:

Pull Request Details 📖

Description

This is an implementation of the I2C::transaction method for embedded-hal and embedded-hal-async. Also added native async read/write/write_read methods not requiring embedded-hal/embedded-hal-async

This fixes #1490

Testing

I've tested:

  • esp32 - sync and async
  • esp32s2 - sync and async
  • esp32s3 - sync and async
  • esp32c2 - sync and async
  • esp32c3 - sync and async
  • esp32c6 - sync and async
  • esp32h2 - not tested (I don't have one)

sync testing was i2c_display and i2c_bmp180_calibration_data examples
async testing was embassy_i2c_bmp180_calibration_data example (new)

@bjoernQ
Copy link
Contributor

bjoernQ commented Apr 24, 2024

Awesome - this works now as expected in regards to #1490

Push the "transaction" down into the lower level implementations so that the read/write/write_read (non-embedded-hal trait version) can use the same code rather than a similar but different implementation.

I think that would be the best way to go. We also want to make every driver useable without depending on embedded-hal following the Focus on Drivers idea in https://blog.rust-embedded.org/embedded-hal-v1/

I remember we had some issues with the C2 before because the FIFO is only 16x8 bits there (while IIRC all others are 32x8) - we especially had problems with SSD1306 displays - one PR for that was #213 (I think there were follow up PRs)

In general, this will be a great improvement - Thanks for taking care of this!

@liebman
Copy link
Contributor Author

liebman commented Apr 27, 2024

Learned something new for the esp32: The End command never gets its cmd_done bit set! The end_detect interrupt bit gets set and even after a 1ms delay, the cmd_done bit for that is not set. (This is not mentioned in the TRM or the errata).

@liebman liebman marked this pull request as ready for review April 28, 2024 15:59
@bjoernQ
Copy link
Contributor

bjoernQ commented Apr 29, 2024

Amazing! Works great for me

I think I remember we usually don't limit the blocking impls to the blocking mode. Did that cause problems here?

@liebman
Copy link
Contributor Author

liebman commented Apr 29, 2024

Yes - It prevented me to from adding read/write/write_read for Async (not using embedded-hal-async)

Copy link
Contributor

@bjoernQ bjoernQ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - Thanks!

Copy link
Contributor

@JurajSadel JurajSadel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@JurajSadel JurajSadel added this pull request to the merge queue Apr 30, 2024
Merged via the queue into esp-rs:main with commit f70ef1a Apr 30, 2024
21 checks passed
@liebman liebman deleted the i2c-implement-transaction branch April 30, 2024 14:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

i2c peripheral is not using a repeated start condition for write_read()
3 participants