mirror of
https://github.com/esphome/esphome.git
synced 2024-12-22 21:44:55 +01:00
Fix wrong initialization of vectors in ade7953_i2c (#6393)
This commit is contained in:
parent
9442f7a271
commit
db1b187e80
1 changed files with 19 additions and 19 deletions
|
@ -13,29 +13,29 @@ void AdE7953I2c::dump_config() {
|
||||||
ade7953_base::ADE7953::dump_config();
|
ade7953_base::ADE7953::dump_config();
|
||||||
}
|
}
|
||||||
bool AdE7953I2c::ade_write_8(uint16_t reg, uint8_t value) {
|
bool AdE7953I2c::ade_write_8(uint16_t reg, uint8_t value) {
|
||||||
std::vector<uint8_t> data(3);
|
uint8_t data[3];
|
||||||
data.push_back(reg >> 8);
|
data[0] = reg >> 8;
|
||||||
data.push_back(reg >> 0);
|
data[1] = reg >> 0;
|
||||||
data.push_back(value);
|
data[2] = value;
|
||||||
return this->write(data.data(), data.size()) != i2c::ERROR_OK;
|
return this->write(data, 3) != i2c::ERROR_OK;
|
||||||
}
|
}
|
||||||
bool AdE7953I2c::ade_write_16(uint16_t reg, uint16_t value) {
|
bool AdE7953I2c::ade_write_16(uint16_t reg, uint16_t value) {
|
||||||
std::vector<uint8_t> data(4);
|
uint8_t data[4];
|
||||||
data.push_back(reg >> 8);
|
data[0] = reg >> 8;
|
||||||
data.push_back(reg >> 0);
|
data[1] = reg >> 0;
|
||||||
data.push_back(value >> 8);
|
data[2] = value >> 8;
|
||||||
data.push_back(value >> 0);
|
data[3] = value >> 0;
|
||||||
return this->write(data.data(), data.size()) != i2c::ERROR_OK;
|
return this->write(data, 4) != i2c::ERROR_OK;
|
||||||
}
|
}
|
||||||
bool AdE7953I2c::ade_write_32(uint16_t reg, uint32_t value) {
|
bool AdE7953I2c::ade_write_32(uint16_t reg, uint32_t value) {
|
||||||
std::vector<uint8_t> data(6);
|
uint8_t data[6];
|
||||||
data.push_back(reg >> 8);
|
data[0] = reg >> 8;
|
||||||
data.push_back(reg >> 0);
|
data[1] = reg >> 0;
|
||||||
data.push_back(value >> 24);
|
data[2] = value >> 24;
|
||||||
data.push_back(value >> 16);
|
data[3] = value >> 16;
|
||||||
data.push_back(value >> 8);
|
data[4] = value >> 8;
|
||||||
data.push_back(value >> 0);
|
data[5] = value >> 0;
|
||||||
return this->write(data.data(), data.size()) != i2c::ERROR_OK;
|
return this->write(data, 6) != i2c::ERROR_OK;
|
||||||
}
|
}
|
||||||
bool AdE7953I2c::ade_read_8(uint16_t reg, uint8_t *value) {
|
bool AdE7953I2c::ade_read_8(uint16_t reg, uint8_t *value) {
|
||||||
uint8_t reg_data[2];
|
uint8_t reg_data[2];
|
||||||
|
|
Loading…
Reference in a new issue