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

Configurable I2C Timeout #1011

Merged
merged 1 commit into from
Dec 11, 2023
Merged

Configurable I2C Timeout #1011

merged 1 commit into from
Dec 11, 2023

Conversation

raphaelhetzel
Copy link
Contributor

@raphaelhetzel raphaelhetzel commented Dec 10, 2023

Hi, similar to what has been described in #352, I have a sensor requiring a higher i2c delay.
I tried to follow the hints from the discussion and added a second constructor taking a delay value.
I did not try to use any semantic time values (second part of the discussion in the issue above) but instead just pass the raw timeout (similar to what esp-idf does).

Let me know if there are any required changes required or whether this change requires me to actually run all of the examples.

Must

  • The code compiles without errors or warnings.
  • All examples work.
  • cargo fmt was run.
  • Your changes were added to the CHANGELOG.md in the proper section.
  • You updated existing examples or added examples (if applicable).
  • Added examples are checked in CI

Nice to have

  • You add a description of your work to this PR.
  • You added proper docs for your newly added features and code.

@raphaelhetzel raphaelhetzel marked this pull request as draft December 10, 2023 14:28
@raphaelhetzel raphaelhetzel force-pushed the i2c_timeout branch 3 times, most recently from 37bdee3 to def8d69 Compare December 10, 2023 14:40
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 - Thank you!

@bjoernQ bjoernQ added this pull request to the merge queue Dec 11, 2023
Merged via the queue into esp-rs:main with commit 5b177ec Dec 11, 2023
17 checks passed
scl: impl Peripheral<P = SCL> + 'd,
frequency: HertzU32,
clocks: &Clocks,
timeout: Option<u32>,
Copy link
Member

Choose a reason for hiding this comment

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

Feels a bit strange to be mixing fugit types with primitive types within the same API, is there a particular reason u32 was chosen here instead of say DurationU32?

Copy link
Contributor

Choose a reason for hiding this comment

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

The timeout is not expressed in time but in 2 ^ timeout clock cycles ... while it would be possible trying to do a lot of math to have a duration here it's probably not really worth it

Copy link
Contributor

Choose a reason for hiding this comment

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

But maybe we should do it anyways - or document it at least

Copy link
Contributor Author

@raphaelhetzel raphaelhetzel Dec 11, 2023

Choose a reason for hiding this comment

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

The esp-idf also uses some non-time value here https://docs.espressif.com/projects/esp-idf/en/v4.3/esp32/api-reference/peripherals/i2c.html#_CPPv415i2c_set_timeout10i2c_port_ti . Not sure if anyone needs precise control over this or just "I need a higher timeout".

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.

3 participants