164 uint16_t calc_chksum = 0xFFFF;
169 calc_chksum = ~calc_chksum;
170 uint16_t coeff_chksum = this->
read_(CSE7761_REG_COEFFCHKSUM, 2);
171 if ((calc_chksum != coeff_chksum) || (!calc_chksum)) {
172 ESP_LOGD(TAG,
"Default calibration");
178 this->
write_(CSE7761_SPECIAL_COMMAND, CSE7761_CMD_ENABLE_WRITE);
180 uint8_t sys_status = this->
read_(CSE7761_REG_SYSSTATUS, 1);
181 if (sys_status & 0x10) {
182 this->
write_(CSE7761_REG_SYSCON | 0x80, 0xFF04);
183 this->
write_(CSE7761_REG_EMUCON | 0x80, 0x1183);
184 this->
write_(CSE7761_REG_EMUCON2 | 0x80, 0x0FC1);
185 this->
write_(CSE7761_REG_PULSE1SEL | 0x80, 0x3290);
187 ESP_LOGD(TAG,
"Write failed at chip_init");
202 value = this->
read_(CSE7761_REG_RMSIA, 3);
203 this->
data_.
current_rms[0] = ((value >= 0x800000) || (value < 1600)) ? 0 : value;
204 value = this->
read_(CSE7761_REG_POWERPA, 4);
208 value = this->
read_(CSE7761_REG_RMSIB, 3);
209 this->
data_.
current_rms[1] = ((value >= 0x800000) || (value < 1600)) ? 0 : value;
210 value = this->
read_(CSE7761_REG_POWERPB, 4);
221 for (uint8_t channel = 0; channel < 2; channel++) {
226 ESP_LOGD(TAG,
"Channel %d power %f W, current %f A", channel + 1, active_power, amps);
234 }
else if (channel == 1) {