1
0
mirror of https://github.com/esphome/esphome.git synced 2025-02-26 14:58:16 +00:00

[i2c] Fix i2c issue on idf 5.3 (#8283)

This commit is contained in:
Jonathan Swoboda 2025-02-25 16:49:09 -05:00 committed by GitHub
parent b7b2f3e61c
commit d5da341138
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -8,6 +8,10 @@
#include "esphome/core/helpers.h" #include "esphome/core/helpers.h"
#include "esphome/core/log.h" #include "esphome/core/log.h"
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 3, 0)
#define SOC_HP_I2C_NUM SOC_I2C_NUM
#endif
namespace esphome { namespace esphome {
namespace i2c { namespace i2c {
@ -17,14 +21,14 @@ void IDFI2CBus::setup() {
ESP_LOGCONFIG(TAG, "Setting up I2C bus..."); ESP_LOGCONFIG(TAG, "Setting up I2C bus...");
static i2c_port_t next_port = I2C_NUM_0; static i2c_port_t next_port = I2C_NUM_0;
port_ = next_port; port_ = next_port;
#if SOC_I2C_NUM > 1 #if SOC_HP_I2C_NUM > 1
next_port = (next_port == I2C_NUM_0) ? I2C_NUM_1 : I2C_NUM_MAX; next_port = (next_port == I2C_NUM_0) ? I2C_NUM_1 : I2C_NUM_MAX;
#else #else
next_port = I2C_NUM_MAX; next_port = I2C_NUM_MAX;
#endif #endif
if (port_ == I2C_NUM_MAX) { if (port_ == I2C_NUM_MAX) {
ESP_LOGE(TAG, "Too many I2C buses configured. Max %u supported.", SOC_I2C_NUM); ESP_LOGE(TAG, "Too many I2C buses configured. Max %u supported.", SOC_HP_I2C_NUM);
this->mark_failed(); this->mark_failed();
return; return;
} }