mirror of
https://github.com/esphome/esphome.git
synced 2024-12-25 17:07:50 +01:00
Add timeout to i2c write error logs (#4697)
This commit is contained in:
parent
382dcddf12
commit
8a60919e1f
@ -154,19 +154,26 @@ ErrorCode ArduinoI2CBus::writev(uint8_t address, WriteBuffer *buffers, size_t cn
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
uint8_t status = wire_->endTransmission(stop);
|
uint8_t status = wire_->endTransmission(stop);
|
||||||
if (status == 0) {
|
switch (status) {
|
||||||
|
case 0:
|
||||||
return ERROR_OK;
|
return ERROR_OK;
|
||||||
} else if (status == 1) {
|
case 1:
|
||||||
// transmit buffer not large enough
|
// transmit buffer not large enough
|
||||||
ESP_LOGVV(TAG, "TX failed: buffer not large enough");
|
ESP_LOGVV(TAG, "TX failed: buffer not large enough");
|
||||||
return ERROR_UNKNOWN;
|
return ERROR_UNKNOWN;
|
||||||
} else if (status == 2 || status == 3) {
|
case 2:
|
||||||
|
case 3:
|
||||||
ESP_LOGVV(TAG, "TX failed: not acknowledged");
|
ESP_LOGVV(TAG, "TX failed: not acknowledged");
|
||||||
return ERROR_NOT_ACKNOWLEDGED;
|
return ERROR_NOT_ACKNOWLEDGED;
|
||||||
}
|
case 5:
|
||||||
|
ESP_LOGVV(TAG, "TX failed: timeout");
|
||||||
|
return ERROR_UNKNOWN;
|
||||||
|
case 4:
|
||||||
|
default:
|
||||||
ESP_LOGVV(TAG, "TX failed: unknown error %u", status);
|
ESP_LOGVV(TAG, "TX failed: unknown error %u", status);
|
||||||
return ERROR_UNKNOWN;
|
return ERROR_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Perform I2C bus recovery, see:
|
/// Perform I2C bus recovery, see:
|
||||||
/// https://www.nxp.com/docs/en/user-guide/UM10204.pdf
|
/// https://www.nxp.com/docs/en/user-guide/UM10204.pdf
|
||||||
|
Loading…
Reference in New Issue
Block a user