From f6caf6e1acef0d52cbbc23acda94fce003b3d31a Mon Sep 17 00:00:00 2001 From: Daniel Whitlow Date: Thu, 11 Jul 2024 18:51:42 -0700 Subject: [PATCH] Update esp-idf i2c timeout unit conversion --- esphome/components/i2c/i2c_bus_esp_idf.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/esphome/components/i2c/i2c_bus_esp_idf.cpp b/esphome/components/i2c/i2c_bus_esp_idf.cpp index 3a9c229778..ba2a012156 100644 --- a/esphome/components/i2c/i2c_bus_esp_idf.cpp +++ b/esphome/components/i2c/i2c_bus_esp_idf.cpp @@ -50,13 +50,13 @@ void IDFI2CBus::setup() { ESP_LOGW(TAG, "i2c timeout of %" PRIu32 "us greater than max of 13ms on esp-idf, setting to max", timeout_); timeout_ = 13000; } - err = i2c_set_timeout(port_, timeout_ * 80); // unit: APB 80MHz clock cycle + err = i2c_set_timeout(port_, timeout_ / (APB_CLK_FREQ / 1000000)); if (err != ESP_OK) { ESP_LOGW(TAG, "i2c_set_timeout failed: %s", esp_err_to_name(err)); this->mark_failed(); return; } else { - ESP_LOGV(TAG, "i2c_timeout set to %" PRIu32 " ticks (%" PRIu32 " us)", timeout_ * 80, timeout_); + ESP_LOGV(TAG, "i2c_timeout set to %" PRIu32 " ticks (%" PRIu32 " us)", timeout_ / (APB_CLK_FREQ / 1000000), timeout_); } } err = i2c_driver_install(port_, I2C_MODE_MASTER, 0, 0, ESP_INTR_FLAG_IRAM);