ESPHome 2026.11.0b6
Loading...
Searching...
No Matches
ina2xx_base.cpp
Go to the documentation of this file.
1#include "ina2xx_base.h"
2#include "esphome/core/hal.h"
4#include "esphome/core/log.h"
5#include <cinttypes>
6#include <cmath>
7
9
10ESPHOME_LOG_TAG(TAG, "ina2xx");
11
12#define OKFAILED(b) ((b) ? "OK" : "FAILED")
13
14static const uint16_t ADC_TIMES[8] = {50, 84, 150, 280, 540, 1052, 2074, 4120};
15static const uint16_t ADC_SAMPLES[8] = {1, 4, 16, 64, 128, 256, 512, 1024};
16
17static const char *get_device_name(INAModel model) {
18 switch (model) {
20 return "INA228";
22 return "INA229";
24 return "INA238";
26 return "INA239";
28 return "INA237";
29 default:
30 return "UNKNOWN";
31 }
32};
33
34static bool check_model_and_device_match(INAModel model, uint16_t dev_id) {
35 switch (model) {
37 return dev_id == 0x228;
39 return dev_id == 0x229;
41 return dev_id == 0x238;
43 return dev_id == 0x239;
45 return dev_id == 0x237;
46 default:
47 return false;
48 }
49}
50
52 if (!this->reset_config_()) {
53 this->mark_failed(LOG_STR("Reset failed, check connection"));
54 return;
55 }
56 delay(2);
57
58 if (!this->check_device_model_()) {
59 this->mark_failed(LOG_STR("Device not supported or model selected improperly in yaml file"));
60 return;
61 }
62 delay(1);
63
65 delay(1);
66
67 this->configure_adc_();
68 delay(1);
69
70 this->configure_shunt_();
71 delay(1);
72
74 delay(1);
75
76 this->state_ = State::IDLE;
77}
78
80 ESP_LOGD(TAG, "Updating");
81 if (this->is_ready() && this->state_ == State::IDLE) {
82 ESP_LOGD(TAG, "Initiating new data collection");
83 this->state_ = State::DATA_COLLECTION_1;
84 return;
85 }
86}
87
89 if (this->is_ready()) {
90 switch (this->state_) {
92 case State::IDLE:
93 break;
94
96 this->full_loop_is_okay_ = true;
97
98 if (this->shunt_voltage_sensor_ != nullptr) {
99 float shunt_voltage{0};
100 this->full_loop_is_okay_ &= this->read_shunt_voltage_mv_(shunt_voltage);
101 this->shunt_voltage_sensor_->publish_state(shunt_voltage);
102 }
103 this->state_ = State::DATA_COLLECTION_2;
104 break;
105
107 if (this->bus_voltage_sensor_ != nullptr) {
108 float bus_voltage{0};
109 this->full_loop_is_okay_ &= this->read_bus_voltage_(bus_voltage);
110 this->bus_voltage_sensor_->publish_state(bus_voltage);
111 }
112 this->state_ = State::DATA_COLLECTION_3;
113 break;
114
116 if (this->die_temperature_sensor_ != nullptr) {
117 float die_temperature{0};
118 this->full_loop_is_okay_ &= this->read_die_temp_c_(die_temperature);
119 this->die_temperature_sensor_->publish_state(die_temperature);
120 }
121 this->state_ = State::DATA_COLLECTION_4;
122 break;
123
125 if (this->current_sensor_ != nullptr) {
126 float current{0};
127 this->full_loop_is_okay_ &= this->read_current_a_(current);
128 this->current_sensor_->publish_state(current);
129 }
130 this->state_ = State::DATA_COLLECTION_5;
131 break;
132
134 if (this->power_sensor_ != nullptr) {
135 float power{0};
136 this->full_loop_is_okay_ &= this->read_power_w_(power);
137 this->power_sensor_->publish_state(power);
138 }
139 this->state_ = State::DATA_COLLECTION_6;
140 break;
141
143 if (this->ina_model_ == INAModel::INA_228 || this->ina_model_ == INAModel::INA_229) {
144 if (this->energy_j_sensor_ != nullptr || this->energy_wh_sensor_ != nullptr ||
145 this->charge_c_sensor_ != nullptr || this->charge_ah_sensor_ != nullptr) {
147 }
148 if (this->energy_j_sensor_ != nullptr || this->energy_wh_sensor_ != nullptr) {
149 double energy_j{0}, energy_wh{0};
150 this->full_loop_is_okay_ &= this->read_energy_(energy_j, energy_wh);
151 PUBLISH_STATE(this->energy_j_sensor_, energy_j);
152 PUBLISH_STATE(this->energy_wh_sensor_, energy_wh);
153 }
154 }
155 this->state_ = State::DATA_COLLECTION_7;
156 break;
157
159 if (this->ina_model_ == INAModel::INA_228 || this->ina_model_ == INAModel::INA_229) {
160 if (this->charge_c_sensor_ != nullptr || this->charge_ah_sensor_ != nullptr) {
161 double charge_c{0}, charge_ah{0};
162 this->full_loop_is_okay_ &= this->read_charge_(charge_c, charge_ah);
163 PUBLISH_STATE(this->charge_c_sensor_, charge_c);
164 PUBLISH_STATE(this->charge_ah_sensor_, charge_ah);
165 }
166 }
167 this->state_ = State::DATA_COLLECTION_8;
168 break;
169
172 this->state_ = State::IDLE;
173 break;
174
175 default:
176 ESP_LOGW(TAG, "Unknown state of the component, might be due to memory corruption");
177 break;
178 }
179 }
180}
181
183 ESP_LOGCONFIG(TAG, "INA2xx:");
184 ESP_LOGCONFIG(TAG, " Device model = %s", get_device_name(this->ina_model_));
185
186 if (this->device_mismatch_) {
187 ESP_LOGE(TAG, " Device model mismatch. Found device with ID = %x. Please check your configuration.",
188 this->dev_id_);
189 }
190 LOG_UPDATE_INTERVAL(this);
191 ESP_LOGCONFIG(TAG,
192 " Shunt resistance = %f Ohm\n"
193 " Max current = %f A\n"
194 " Shunt temp coeff = %d ppm/°C\n"
195 " ADCRANGE = %d (%s)\n"
196 " CURRENT_LSB = %f\n"
197 " SHUNT_CAL = %d",
199 (uint8_t) this->adc_range_,
200 this->adc_range_ ? LOG_STR_LITERAL("±40.96 mV") : LOG_STR_LITERAL("±163.84 mV"), this->current_lsb_,
201 this->shunt_cal_);
202
203 ESP_LOGCONFIG(TAG, " ADC Samples = %d; ADC times: Bus = %d μs, Shunt = %d μs, Temp = %d μs",
204 ADC_SAMPLES[0b111 & (uint8_t) this->adc_avg_samples_],
205 ADC_TIMES[0b111 & (uint8_t) this->adc_time_bus_voltage_],
206 ADC_TIMES[0b111 & (uint8_t) this->adc_time_shunt_voltage_],
207 ADC_TIMES[0b111 & (uint8_t) this->adc_time_die_temperature_]);
208
209 ESP_LOGCONFIG(TAG, " Device is %s", get_device_name(this->ina_model_));
210
211 LOG_SENSOR(" ", "Shunt Voltage", this->shunt_voltage_sensor_);
212 LOG_SENSOR(" ", "Bus Voltage", this->bus_voltage_sensor_);
213 LOG_SENSOR(" ", "Die Temperature", this->die_temperature_sensor_);
214 LOG_SENSOR(" ", "Current", this->current_sensor_);
215 LOG_SENSOR(" ", "Power", this->power_sensor_);
216
217 if (this->ina_model_ == INAModel::INA_228 || this->ina_model_ == INAModel::INA_229) {
218 LOG_SENSOR(" ", "Energy J", this->energy_j_sensor_);
219 LOG_SENSOR(" ", "Energy Wh", this->energy_wh_sensor_);
220 LOG_SENSOR(" ", "Charge C", this->charge_c_sensor_);
221 LOG_SENSOR(" ", "Charge Ah", this->charge_ah_sensor_);
222 }
223}
224
226 if (this->ina_model_ != INAModel::INA_228 && this->ina_model_ != INAModel::INA_229) {
227 return false;
228 }
229 ESP_LOGV(TAG, "reset_energy_counters");
230
232 auto ret = this->read_unsigned_16_(RegisterMap::REG_CONFIG, cfg.raw_u16);
233 cfg.RSTACC = true;
234 cfg.ADCRANGE = this->adc_range_;
235 ret = ret && this->write_unsigned_16_(RegisterMap::REG_CONFIG, cfg.raw_u16);
236
237 this->energy_overflows_count_ = 0;
238 this->charge_overflows_count_ = 0;
239 return ret;
240}
241
243 ESP_LOGV(TAG, "Reset");
245 if (!this->reset_on_boot_) {
246 ESP_LOGI(TAG, "Skipping on-boot device reset");
247 cfg.RST = false;
248 } else {
249 cfg.RST = true;
250 }
251 return this->write_unsigned_16_(RegisterMap::REG_CONFIG, cfg.raw_u16);
252}
253
255 constexpr uint16_t manufacturer_ti = 0x5449; // "TI"
256
257 uint16_t manufacturer_id{0}, rev_id{0};
260 this->dev_id_ = 0;
261 ESP_LOGV(TAG, "Can't read device ID");
262 };
263 rev_id = this->dev_id_ & 0x0F;
264 this->dev_id_ >>= 4;
265 ESP_LOGI(TAG, "Manufacturer: 0x%04X, Device ID: 0x%04X, Revision: %d", manufacturer_id, this->dev_id_, rev_id);
266
267 if (manufacturer_id != manufacturer_ti) {
268 ESP_LOGE(TAG, "Manufacturer ID doesn't match original 0x5449");
269 this->device_mismatch_ = true;
270 return false;
271 }
272
273 if (this->dev_id_ == 0x228 || this->dev_id_ == 0x229) {
274 ESP_LOGI(TAG, "Supported device found: INA%x, 85-V, 20-Bit, Ultra-Precise Power/Energy/Charge Monitor",
275 this->dev_id_);
276 } else if (this->dev_id_ == 0x238 || this->dev_id_ == 0x239) {
277 ESP_LOGI(TAG, "Supported device found: INA%x, 85-V, 16-Bit, High-Precision Power Monitor", this->dev_id_);
278 } else if (this->dev_id_ == 0x0 || this->dev_id_ == 0xFF) {
279 ESP_LOGI(TAG, "We assume device is: INA237 85-V, 16-Bit, Precision Power Monitor");
280 this->dev_id_ = 0x237;
281 } else {
282 ESP_LOGE(TAG, "Unknown device ID %x.", this->dev_id_);
283 this->device_mismatch_ = true;
284 return false;
285 }
286
287 // Check user-selected model agains what we have found. Mark as failed if selected model != found model
288 if (!check_model_and_device_match(this->ina_model_, this->dev_id_)) {
289 ESP_LOGE(TAG, "Selected model %s doesn't match found device INA%x", get_device_name(this->ina_model_),
290 this->dev_id_);
291 this->device_mismatch_ = true;
292 return false;
293 }
294
295 // setup device coefficients
296 if (this->ina_model_ == INAModel::INA_228 || this->ina_model_ == INAModel::INA_229) {
297 this->cfg_.vbus_lsb = 0.0001953125f;
298 this->cfg_.v_shunt_lsb_range0 = 0.0003125f;
299 this->cfg_.v_shunt_lsb_range1 = 0.000078125f;
300 this->cfg_.shunt_cal_scale = 13107.2f * 1000000.0f;
301 this->cfg_.current_lsb_scale_factor = -19;
302 this->cfg_.die_temp_lsb = 0.0078125f;
303 this->cfg_.power_coeff = 3.2f;
304 this->cfg_.energy_coeff = 16.0f * 3.2f;
305 } else {
306 this->cfg_.vbus_lsb = 0.0031250000f;
307 this->cfg_.v_shunt_lsb_range0 = 0.0050000f;
308 this->cfg_.v_shunt_lsb_range1 = 0.001250000f;
309 this->cfg_.shunt_cal_scale = 819.2f * 1000000.0f;
310 this->cfg_.current_lsb_scale_factor = -15;
311 this->cfg_.die_temp_lsb = 0.1250000f;
312 this->cfg_.power_coeff = 0.2f;
313 this->cfg_.energy_coeff = 0.0f; // N/A
314 }
315
316 return true;
317}
318
320 ESP_LOGV(TAG, "Setting ADCRANGE = %d", (uint8_t) this->adc_range_);
322 auto ret = this->read_unsigned_16_(RegisterMap::REG_CONFIG, cfg.raw_u16);
323 cfg.ADCRANGE = this->adc_range_;
324 ret = ret && this->write_unsigned_16_(RegisterMap::REG_CONFIG, cfg.raw_u16);
325
326 return ret;
327}
328
330 bool ret{false};
331 AdcConfigurationRegister adc_cfg{0};
332 adc_cfg.MODE = 0x0F; // Fh = Continuous bus voltage, shunt voltage and temperature
333 adc_cfg.VBUSCT = this->adc_time_bus_voltage_;
334 adc_cfg.VSHCT = this->adc_time_shunt_voltage_;
335 adc_cfg.VTCT = this->adc_time_die_temperature_;
336 adc_cfg.AVG = this->adc_avg_samples_;
337 ret = this->write_unsigned_16_(RegisterMap::REG_ADC_CONFIG, adc_cfg.raw_u16);
338 return ret;
339}
340
342 this->current_lsb_ = ldexp(this->max_current_a_, this->cfg_.current_lsb_scale_factor);
343 this->shunt_cal_ = (uint16_t) (this->cfg_.shunt_cal_scale * this->current_lsb_ * this->shunt_resistance_ohm_);
344 if (this->adc_range_)
345 this->shunt_cal_ *= 4;
346
347 if (this->shunt_cal_ & 0x8000) {
348 // cant be more than 15 bits
349 ESP_LOGW(TAG, "Shunt value too high");
350 }
351 this->shunt_cal_ &= 0x7FFF;
352 ESP_LOGV(TAG, "Rshunt=%f Ohm, max current=%.3f A, current LSB=%f, shunt cal=%u", this->shunt_resistance_ohm_,
353 this->max_current_a_, this->current_lsb_, this->shunt_cal_);
355}
356
358 // Only for 228/229
359 // unsigned 14-bit value
360 // 0x0000 = 0 ppm/°C
361 // 0x3FFF = 16383 ppm/°C
362 if ((this->ina_model_ == INAModel::INA_228 || this->ina_model_ == INAModel::INA_229) &&
363 this->shunt_tempco_ppm_c_ > 0) {
365 }
366 return true;
367}
368
369bool INA2XX::read_shunt_voltage_mv_(float &volt_out) {
370 // Two's complement value
371 // 228, 229 - 24bit: 20(23-4) + 4(3-0) res
372 // 237, 238, 239 - 16bit
373
374 bool ret{false};
375 float volt_reading{0};
376 uint64_t raw{0};
377 if (this->ina_model_ == INAModel::INA_228 || this->ina_model_ == INAModel::INA_229) {
379 raw >>= 4;
380 volt_reading = sign_extend<20>(raw);
381 } else {
383 volt_reading = sign_extend<16>(raw);
384 }
385
386 if (ret) {
387 volt_out = (this->adc_range_ ? this->cfg_.v_shunt_lsb_range1 : this->cfg_.v_shunt_lsb_range0) * volt_reading;
388 }
389
390 ESP_LOGV(TAG, "read_shunt_voltage_mv_ ret=%s, shunt_cal=%d, reading_lsb=%f", OKFAILED(ret), this->shunt_cal_,
391 volt_reading);
392
393 return ret;
394}
395
396bool INA2XX::read_bus_voltage_(float &volt_out) {
397 // Two's complement value
398 // 228, 229 - 24bit: 20(23-4) + 4(3-0) res
399 // 237, 238, 239 - 16bit
400
401 bool ret{false};
402 float volt_reading{0};
403 uint64_t raw{0};
404 if (this->ina_model_ == INAModel::INA_228 || this->ina_model_ == INAModel::INA_229) {
406 raw >>= 4;
407 volt_reading = sign_extend<20>(raw);
408 } else {
410 volt_reading = sign_extend<16>(raw);
411 }
412 if (ret) {
413 volt_out = this->cfg_.vbus_lsb * (float) volt_reading;
414 }
415
416 ESP_LOGV(TAG, "read_bus_voltage_ ret=%s, reading_lsb=%f", OKFAILED(ret), volt_reading);
417 return ret;
418}
419
420bool INA2XX::read_die_temp_c_(float &temp_out) {
421 // Two's complement value
422 // 228, 229 - 16bit
423 // 237, 238, 239 - 16bit: 12(15-4) + 4(3-0) res
424
425 bool ret{false};
426 float temp_reading{0};
427 uint64_t raw{0};
428
429 if (this->ina_model_ == INAModel::INA_228 || this->ina_model_ == INAModel::INA_229) {
431 temp_reading = sign_extend<16>(raw);
432 } else {
434 raw >>= 4;
435 temp_reading = sign_extend<12>(raw);
436 }
437 if (ret) {
438 temp_out = this->cfg_.die_temp_lsb * (float) temp_reading;
439 }
440
441 ESP_LOGV(TAG, "read_die_temp_c_ ret=%s, reading_lsb=%f", OKFAILED(ret), temp_reading);
442 return ret;
443}
444
445bool INA2XX::read_current_a_(float &amps_out) {
446 // Two's complement value
447 // 228, 229 - 24bit: 20(23-4) + 4(3-0) res
448 // 237, 238, 239 - 16bit
449 bool ret{false};
450 float amps_reading{0};
451 uint64_t raw{0};
452
453 if (this->ina_model_ == INAModel::INA_228 || this->ina_model_ == INAModel::INA_229) {
455 raw >>= 4;
456 amps_reading = sign_extend<20>(raw);
457 } else {
459 amps_reading = sign_extend<16>(raw);
460 }
461
462 ESP_LOGV(TAG, "read_current_a_ ret=%s. current_lsb=%f. reading_lsb=%f", OKFAILED(ret), this->current_lsb_,
463 amps_reading);
464 if (ret) {
465 amps_out = this->current_lsb_ * (float) amps_reading;
466 }
467
468 return ret;
469}
470
471bool INA2XX::read_power_w_(float &power_out) {
472 // Unsigned value
473 // 228, 229 - 24bit
474 // 237, 238, 239 - 24bit
475 uint64_t power_reading{0};
476 auto ret = this->read_unsigned_((uint8_t) RegisterMap::REG_POWER, 3, power_reading);
477
478 ESP_LOGV(TAG, "read_power_w_ ret=%s, reading_lsb=%" PRIu32, OKFAILED(ret), (uint32_t) power_reading);
479 if (ret) {
480 power_out = this->cfg_.power_coeff * this->current_lsb_ * (float) power_reading;
481 }
482
483 return ret;
484}
485
486bool INA2XX::read_energy_(double &joules_out, double &watt_hours_out) {
487 // Unsigned value
488 // 228, 229 - 40bit
489 // 237, 238, 239 - not available
490 if (this->ina_model_ != INAModel::INA_228 && this->ina_model_ != INAModel::INA_229) {
491 joules_out = 0;
492 return false;
493 }
494 uint64_t joules_reading = 0;
495 uint64_t previous_energy = this->energy_overflows_count_ * (((uint64_t) 1) << 40);
496 auto ret = this->read_unsigned_((uint8_t) RegisterMap::REG_ENERGY, 5, joules_reading);
497
498 ESP_LOGV(TAG, "read_energy_j_ ret=%s, reading_lsb=0x%" PRIX64 ", current_lsb=%f, overflow_cnt=%" PRIu32,
499 OKFAILED(ret), joules_reading, this->current_lsb_, this->energy_overflows_count_);
500 if (ret) {
501 joules_out = this->cfg_.energy_coeff * this->current_lsb_ * (double) joules_reading + (double) previous_energy;
502 watt_hours_out = joules_out / 3600.0;
503 }
504 return ret;
505}
506
507bool INA2XX::read_charge_(double &coulombs_out, double &amp_hours_out) {
508 // Two's complement value
509 // 228, 229 - 40bit
510 // 237, 238, 239 - not available
511 if (this->ina_model_ != INAModel::INA_228 && this->ina_model_ != INAModel::INA_229) {
512 coulombs_out = 0;
513 return false;
514 }
515
516 // and what to do with this? datasheet doesnt tell us what if charge is negative
517 uint64_t previous_charge = this->charge_overflows_count_ * (((uint64_t) 1) << 39);
518 double coulombs_reading = 0;
519 uint64_t raw{0};
520 auto ret = this->read_unsigned_((uint8_t) RegisterMap::REG_CHARGE, 5, raw);
521 coulombs_reading = this->two_complement_(raw, 40);
522
523 ESP_LOGV(TAG, "read_charge_c_ ret=%d, curr_charge=%f + 39-bit overflow_cnt=%" PRIu32, ret, coulombs_reading,
525 if (ret) {
526 coulombs_out = this->current_lsb_ * (double) coulombs_reading + (double) previous_charge;
527 amp_hours_out = coulombs_out / 3600.0;
528 }
529 return ret;
530}
531
533 if (this->ina_model_ != INAModel::INA_228 && this->ina_model_ != INAModel::INA_229) {
534 return false;
535 }
536
537 DiagnosticRegister diag{0};
538 auto ret = this->read_unsigned_16_(RegisterMap::REG_DIAG_ALRT, diag.raw_u16);
539 ESP_LOGV(TAG, "read_diagnostics_and_act_ ret=%s, 0x%04X", OKFAILED(ret), diag.raw_u16);
540
541 if (diag.ENERGYOF) {
542 this->energy_overflows_count_++; // 40-bit overflow
543 }
544
545 if (diag.CHARGEOF) {
546 this->charge_overflows_count_++; // 39-bit overflow
547 }
548
549 return ret;
550}
551
552bool INA2XX::write_unsigned_16_(uint8_t reg, uint16_t val) {
553 uint16_t data_out = byteswap(val);
554 auto ret = this->write_ina_register(reg, (uint8_t *) &data_out, 2);
555 if (!ret) {
556 ESP_LOGV(TAG, "write_unsigned_16_ FAILED reg=0x%02X, val=0x%04X", reg, val);
557 }
558 return ret;
559}
560
561bool INA2XX::read_unsigned_(uint8_t reg, uint8_t reg_size, uint64_t &data_out) {
562 uint8_t rx_buf[5]{};
563 if (reg_size > sizeof(rx_buf)) {
564 return false;
565 }
566
567 auto ret = this->read_ina_register(reg, rx_buf, reg_size);
568
569 // Combine bytes
570 data_out = rx_buf[0];
571 for (uint8_t i = 1; i < reg_size; i++) {
572 data_out = (data_out << 8) | rx_buf[i];
573 }
574 ESP_LOGV(TAG, "read_unsigned_ reg=0x%02X, ret=%s, len=%d, val=0x%" PRIX64, reg, OKFAILED(ret), reg_size, data_out);
575
576 return ret;
577}
578
579bool INA2XX::read_unsigned_16_(uint8_t reg, uint16_t &out) {
580 uint16_t data_in{0};
581 auto ret = this->read_ina_register(reg, (uint8_t *) &data_in, 2);
582 out = byteswap(data_in);
583 ESP_LOGV(TAG, "read_unsigned_16_ 0x%02X, ret= %s, val=0x%04X", reg, OKFAILED(ret), out);
584 return ret;
585}
586
587int64_t INA2XX::two_complement_(uint64_t value, uint8_t bits) {
588 return (int64_t) (value << (64 - bits)) >> (64 - bits);
589}
590} // namespace esphome::ina2xx_base
uint8_t raw[35]
Definition bl0939.h:0
void mark_failed()
Mark this component as failed.
bool status_comm_result(bool ok)
Clears the warning when ok, else sets it with message (default "Communication failed"); returns ok.
bool is_ready() const
bool read_die_temp_c_(float &temp)
bool write_unsigned_16_(uint8_t reg, uint16_t val)
bool read_unsigned_(uint8_t reg, uint8_t reg_size, uint64_t &data_out)
bool read_bus_voltage_(float &volt_out)
bool read_unsigned_16_(uint8_t reg, uint16_t &out)
struct esphome::ina2xx_base::INA2XX::@97 cfg_
bool read_shunt_voltage_mv_(float &volt_out)
virtual bool read_ina_register(uint8_t a_register, uint8_t *data, size_t len)=0
bool read_power_w_(float &power_out)
int64_t two_complement_(uint64_t value, uint8_t bits)
bool read_charge_(double &coulombs_out, double &amp_hours_out)
bool read_energy_(double &joules_out, double &watt_hours_out)
bool read_current_a_(float &amps_out)
virtual bool write_ina_register(uint8_t a_register, const uint8_t *data, size_t len)=0
std::vector< uint8_t > & out
Definition gif.cpp:49
int ret
mopeka_std_values val[3]
ESPHOME_LOG_TAG(TAG, "ina2xx")
uint32_t value
Definition hal.cpp:41
constexpr int32_t sign_extend(uint32_t value)
Sign-extend the low BITS bits of value, e.g. sign_extend<24>(0xFFFFFE) == -2. Higher bits are ignored...
Definition helpers.h:1057
void HOT delay(uint32_t ms)
Definition hal.cpp:85
static void uint32_t
void byteswap()