1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-18 03:02:20 +01:00

[i2c] Perform register reads as single transactions (#10389)

Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
This commit is contained in:
Clyde Stubbs
2025-08-27 19:30:33 +10:00
committed by GitHub
parent 65d63de9b6
commit c171d13c8c
38 changed files with 329 additions and 643 deletions

View File

@@ -22,7 +22,7 @@ void KMeterISOComponent::setup() {
this->reset_to_construction_state();
}
auto err = this->bus_->writev(this->address_, nullptr, 0);
auto err = this->bus_->write_readv(this->address_, nullptr, 0, nullptr, 0);
if (err == esphome::i2c::ERROR_OK) {
ESP_LOGCONFIG(TAG, "Could write to the address %d.", this->address_);
} else {
@@ -33,7 +33,7 @@ void KMeterISOComponent::setup() {
}
uint8_t read_buf[4] = {1};
if (!this->read_bytes(KMETER_ERROR_STATUS_REG, read_buf, 1)) {
if (!this->read_register(KMETER_ERROR_STATUS_REG, read_buf, 1)) {
ESP_LOGCONFIG(TAG, "Could not read from the device.");
this->error_code_ = COMMUNICATION_FAILED;
this->mark_failed();