Add timeout to i2c write error logs (#4697)

This commit is contained in:
Szewcson 2023-04-16 22:12:13 +02:00 committed by Jesse Hills
parent 53c59cf675
commit 2ebacad398
No known key found for this signature in database
GPG key ID: BEAAE804EFD8E83A

View file

@ -154,18 +154,25 @@ 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) {
return ERROR_OK; case 0:
} else if (status == 1) { return ERROR_OK;
// transmit buffer not large enough case 1:
ESP_LOGVV(TAG, "TX failed: buffer not large enough"); // transmit buffer not large enough
return ERROR_UNKNOWN; ESP_LOGVV(TAG, "TX failed: buffer not large enough");
} else if (status == 2 || status == 3) { return ERROR_UNKNOWN;
ESP_LOGVV(TAG, "TX failed: not acknowledged"); case 2:
return ERROR_NOT_ACKNOWLEDGED; case 3:
ESP_LOGVV(TAG, "TX failed: 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);
return ERROR_UNKNOWN;
} }
ESP_LOGVV(TAG, "TX failed: unknown error %u", status);
return ERROR_UNKNOWN;
} }
/// Perform I2C bus recovery, see: /// Perform I2C bus recovery, see: