i2c: fix build on ESP-IDF >= 5.1 (#5200)

Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
This commit is contained in:
Stijn Tintel
2023-08-08 09:51:22 +12:00
committed by GitHub
co-authored by Jesse Hills
parent 0b1b25191d
commit 9876d5276c
+13 -2
View File
@@ -15,8 +15,19 @@ static const char *const TAG = "i2c.idf";
void IDFI2CBus::setup() {
ESP_LOGCONFIG(TAG, "Setting up I2C bus...");
static i2c_port_t next_port = 0;
port_ = next_port++;
static i2c_port_t next_port = I2C_NUM_0;
port_ = next_port;
#if I2C_NUM_MAX > 1
next_port = (next_port == I2C_NUM_0) ? I2C_NUM_1 : I2C_NUM_MAX;
#else
next_port = I2C_NUM_MAX;
#endif
if (port_ == I2C_NUM_MAX) {
ESP_LOGE(TAG, "Too many I2C buses configured");
this->mark_failed();
return;
}
recover_();