mirror of
https://github.com/esphome/esphome.git
synced 2024-11-26 00:48:19 +01:00
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:
parent
0b1b25191d
commit
9876d5276c
1 changed files with 13 additions and 2 deletions
|
@ -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_();
|
||||
|
||||
|
|
Loading…
Reference in a new issue