Skip to content

Conversation

@bugadani
Copy link
Contributor

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).
  • I have used cargo xtask fmt-packages command to ensure that all changed code is formatted correctly.
  • My changes were added to the CHANGELOG.md in the proper section.
  • I have added necessary changes to user code to the Migration Guide.
  • My changes are in accordance to the esp-rs API guidelines

Extra:

Pull Request Details 📖

Description

Please provide a clear and concise description of your changes, including the motivation behind these changes. The context is crucial for the reviewers.

Testing

Describe how you tested your changes.

let scl_high = half_cycle - scl_wait_high;
let sda_hold = half_cycle / 4;
let sda_sample = half_cycle / 2 + scl_wait_high;
let sda_sample = half_cycle / 2;
Copy link
Contributor Author

@bugadani bugadani Jan 27, 2025

Choose a reason for hiding this comment

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

To be fair, I should probably remove the half_cycle/2 term instead. Technically, we can sample at any point after the rising edge, and scl_wait_high is supposed to be somewhat dependent on the hardware (i.e. it should be tunable, maybe). scl_wait_high represents the rising edge of the clock signal, after which the clock signal is high for scl_high. We should probably aim at the start/middle of the interval covered by scl_high.

Still, this should be good enough to test.

@bugadani bugadani closed this Feb 11, 2025
@bugadani bugadani deleted the i2c-sample branch February 11, 2025 08:37
@armandas
Copy link

armandas commented Oct 3, 2025

@bugadani I just ran into this issue and can confirm that the proposed change does resolve it. Any chance we can revive this PR?

As far as I can see, the esp_hal timing differs from that used in esp-idf, and it appears that the change was introduced in #263 without any comment.

Background

I have a ESP32-C6 board from Waveshare and was trying to read the touch driver. The provided ESP-IDF code works flawlessly, however, when using esp_hal the data is garbled.

I started probing the bus with my oscilloscope and to my surprise, the readout started working. I went to see if anyone has reported such an issue and ended up here.

@bugadani
Copy link
Contributor Author

bugadani commented Oct 3, 2025

I completely forgot about this. This PR was abandoned because it failed to fix an issue where I thought this would be relevant. We can certainly revisit this

@bugadani bugadani restored the i2c-sample branch October 6, 2025 09:24
@bugadani bugadani mentioned this pull request Oct 6, 2025
@armandas
Copy link

May I help with any additional testing or can we just treat esp-idf as a source of truth?

@bugadani
Copy link
Contributor Author

Of course, any testing you do, any issues you can find, are welcome.

@armandas
Copy link

I mean in order to be able merge this PR.

@bugadani
Copy link
Contributor Author

Ah, this has been already done in #4268

@armandas
Copy link

Thanks a lot, I missed that!

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.

2 participants