| 34 | } |
| 35 | |
| 36 | bool readI2CReg16LE(uint8_t addr, uint8_t reg, uint16_t* outValue) { |
| 37 | Wire.beginTransmission(addr); |
| 38 | Wire.write(reg); |
| 39 | if (Wire.endTransmission(false) != 0) { |
| 40 | return false; |
| 41 | } |
| 42 | if (Wire.requestFrom(addr, static_cast<uint8_t>(2), static_cast<uint8_t>(true)) < 2) { |
| 43 | while (Wire.available()) { |
| 44 | Wire.read(); |
| 45 | } |
| 46 | return false; |
| 47 | } |
| 48 | const uint8_t lo = Wire.read(); |
| 49 | const uint8_t hi = Wire.read(); |
| 50 | *outValue = (static_cast<uint16_t>(hi) << 8) | lo; |
| 51 | return true; |
| 52 | } |
| 53 | |
| 54 | bool readBQ27220CurrentMA(int16_t* outCurrent) { |
| 55 | uint16_t raw = 0; |
no test coverage detected