From 5ca8ed9649f154e474fd258831e42c71d2e10c4a Mon Sep 17 00:00:00 2001 From: William Emfinger Date: Tue, 8 Apr 2025 09:02:05 -0500 Subject: [PATCH] fix(i2c): Fix `I2c::probe` timeout not using configured timeout * 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) --- components/i2c/include/i2c.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/i2c/include/i2c.hpp b/components/i2c/include/i2c.hpp index 72387e1b2..720780f18 100644 --- a/components/i2c/include/i2c.hpp +++ b/components/i2c/include/i2c.hpp @@ -276,7 +276,8 @@ class I2c : public espp::BaseComponent { i2c_master_start(cmd); i2c_master_write_byte(cmd, (dev_addr << 1) | I2C_MASTER_WRITE, true); i2c_master_stop(cmd); - if (i2c_master_cmd_begin(config_.port, cmd, 1000) == ESP_OK) { + if (i2c_master_cmd_begin(config_.port, cmd, config_.timeout_ms / portTICK_PERIOD_MS) == + ESP_OK) { success = true; } i2c_cmd_link_delete(cmd);