Skip to content

fix(i2c): Fix I2c::probe timeout not using configured timeout #414

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

Merged
merged 1 commit into from
Apr 8, 2025

Conversation

finger563
Copy link
Contributor

Description

  • Update I2c::probe to use config_.timeout_ms to determine number of ticks for i2c transaction timeout instead of hardcoded 1000 ticks.

Motivation and Context

Ensures the configured i2c timeout is used properly when probing the bus, instead of a hardcoded timeout

How has this been tested?

  • Build and run i2c/example on ESP32S3 and ensure it probes the bus quickly as it should (~1 second total for all addresses)

Screenshots (if appropriate, e.g. schematic, board, console logs, lab pictures):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update
  • Hardware (schematic, board, system design) change
  • Software change

Checklist:

  • My change requires a change to the documentation.
  • I have added / updated the documentation related to this change via either README or WIKI

Software

  • I have added tests to cover my changes.
  • I have updated the .github/workflows/build.yml file to add my new test to the automated cloud build github action.
  • All new and existing tests passed.
  • My code follows the code style of this project.

* Update `I2c::probe` to use `config_.timeout_ms` to determine number of ticks for i2c transaction timeout instead of hardcoded 1000 ticks.

Ensures the configured i2c timeout is used properly when probing the bus, instead of a hardcoded timeout

* Build and run `i2c/example` on ESP32S3 and ensure it probes the bus quickly as it should (~1 second total for all addresses)
@finger563 finger563 requested a review from Copilot April 8, 2025 14:03
@finger563 finger563 self-assigned this Apr 8, 2025
@finger563 finger563 added bug Something isn't working i2c labels Apr 8, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 1 out of 1 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (1)

components/i2c/include/i2c.hpp:279

  • Consider verifying that config_.timeout_ms is always greater than or equal to portTICK_PERIOD_MS to prevent a zero tick timeout. This check can help avoid unintended behavior when the timeout value is too low.
if (i2c_master_cmd_begin(config_.port, cmd, config_.timeout_ms / portTICK_PERIOD_MS) == ESP_OK) {

Copy link

github-actions bot commented Apr 8, 2025

✅Static analysis result - no issues found! ✅

@finger563 finger563 merged commit a34e74a into main Apr 8, 2025
77 checks passed
@finger563 finger563 deleted the fix/i2c-probe-timeout branch April 8, 2025 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working i2c
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant