6 #if __has_include(<esp_log.h>)
14 static constexpr std::uint8_t REG_SYS_CTL0 = 0x00;
15 static constexpr std::uint8_t REG_SYS_CTL1 = 0x01;
16 static constexpr std::uint8_t REG_SYS_CTL2 = 0x02;
17 static constexpr std::uint8_t REG_READ0 = 0x70;
18 static constexpr std::uint8_t REG_READ1 = 0x71;
19 static constexpr std::uint8_t REG_READ2 = 0x72;
20 static constexpr std::uint8_t REG_READ3 = 0x77;
21 static constexpr std::uint8_t REG_READ4 = 0x78;
22 static constexpr std::uint8_t REG_CHG_CTL0 = 0x20;
23 static constexpr std::uint8_t REG_CHG_CTL1 = 0x21;
24 static constexpr std::uint8_t REG_CHG_CTL2 = 0x22;
25 static constexpr std::uint8_t REG_CHG_CTL3 = 0x23;
26 static constexpr std::uint8_t REG_CHG_DIG_CTL0 = 0x24;
28 static constexpr std::uint8_t BOOST_OUT_BIT = 0x02;
38 #if defined (ESP_LOGV)
39 ESP_LOGV(
"IP5306",
"found");
50 case 0x00:
return 100;
62 static constexpr std::uint8_t CHARGE_OUT_BIT = 0x10;
67 writeRegister8(REG_SYS_CTL0, enable ? (val | CHARGE_OUT_BIT) : (val & (~CHARGE_OUT_BIT)));
73 max_mA = (max_mA > 50) ? (max_mA - 50) / 100 : 0;
74 if (max_mA > 31) { max_mA = 31; }
85 max_mV = (max_mV / 10);
86 max_mV = (max_mV > 410) ? max_mV - 410 : 0;
87 if (max_mV > 436 - 410) { max_mV = 436 - 410; }
88 static constexpr std::uint8_t table[] =
95 while (table[i] <= max_mV) { ++i; }
97 static constexpr std::uint8_t regdata[4] =
108 std::uint8_t val = 0;
116 data = en ? (data | BOOST_OUT_BIT) : (data & (~BOOST_OUT_BIT));
bool readRegister(std::uint8_t reg, std::uint8_t *result, std::size_t length) const
bool writeRegister8(std::uint8_t reg, std::uint8_t data) const
bool writeRegister(std::uint8_t reg, const std::uint8_t *data, std::size_t length) const
std::int8_t getBatteryLevel(void)
void setChargeVoltage(std::uint16_t max_mV)
void setBatteryCharge(bool enable)
void setChargeCurrent(std::uint16_t max_mA)
bool isCharging(void)
Get whether the battery is currently charging or not.
bool setPowerBoostKeepOn(bool en)
Set whether or not to continue supplying power even at low loads.