Skip to content

Commit a34e74a

Browse files
authored
fix(i2c): Fix I2c::probe timeout not using configured timeout (#414)
* 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)
1 parent 6d102d8 commit a34e74a

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

components/i2c/include/i2c.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,8 @@ class I2c : public espp::BaseComponent {
276276
i2c_master_start(cmd);
277277
i2c_master_write_byte(cmd, (dev_addr << 1) | I2C_MASTER_WRITE, true);
278278
i2c_master_stop(cmd);
279-
if (i2c_master_cmd_begin(config_.port, cmd, 1000) == ESP_OK) {
279+
if (i2c_master_cmd_begin(config_.port, cmd, config_.timeout_ms / portTICK_PERIOD_MS) ==
280+
ESP_OK) {
280281
success = true;
281282
}
282283
i2c_cmd_link_delete(cmd);

0 commit comments

Comments
 (0)