7#ifdef USE_BQ25186_PG_GPO
19static constexpr uint8_t BQ25186_REG_STAT0 = 0x00;
20static constexpr uint8_t BQ25186_REG_STAT1 = 0x01;
21static constexpr uint8_t BQ25186_REG_FLAG0 = 0x02;
22static constexpr uint8_t BQ25186_REG_VBAT_CTRL = 0x03;
23static constexpr uint8_t BQ25186_REG_ICHG_CTRL = 0x04;
24static constexpr uint8_t BQ25186_REG_CHARGECTRL0 = 0x05;
25static constexpr uint8_t BQ25186_REG_CHARGECTRL1 = 0x06;
26static constexpr uint8_t BQ25186_REG_IC_CTRL = 0x07;
27static constexpr uint8_t BQ25186_REG_TMR_ILIM = 0x08;
28static constexpr uint8_t BQ25186_REG_SHIP_RST = 0x09;
29static constexpr uint8_t BQ25186_REG_SYS_REG = 0x0A;
30static constexpr uint8_t BQ25186_REG_TS_CONTROL = 0x0B;
31static constexpr uint8_t BQ25186_REG_MASK_ID = 0x0C;
32static constexpr size_t BQ25186_CONFIG_REGISTER_COUNT = BQ25186_REG_MASK_ID - BQ25186_REG_VBAT_CTRL + 1;
35static constexpr size_t BQ25186_STATUS_REGISTER_COUNT = BQ25186_REG_MASK_ID - BQ25186_REG_STAT0 + 1;
38static constexpr uint8_t BQ25186_VBAT_CTRL_PG_MODE = 0x80;
39static constexpr uint8_t BQ25186_SYS_REG_PG_GPO_LEVEL = 0x10;
48 "Charge Done/Disabled",
"Normal",
"Hot/Cold (Charging Suspended)",
"Cool (Current Reduced)",
49 "Warm (Voltage Reduced)");
54 void setup()
override;
63#ifdef USE_BQ25186_STATUS_PUBLISHER
66#ifdef USE_BQ25186_PG_GPO
69 bool write_pg_gpo_level(
bool level) {
70 return this->
update_register_(BQ25186_REG_SYS_REG, BQ25186_SYS_REG_PG_GPO_LEVEL,
71 level ? BQ25186_SYS_REG_PG_GPO_LEVEL : 0);
82#ifdef USE_BQ25186_PG_GPO
This class simplifies creating components that periodically check a state.
BQ25186ConfigRegisters regs_
void check_pg_gpo_(const BQ25186StatusRegisters &status, bool &pending)
HUB_PUBLISHER(status, const BQ25186StatusRegisters &) SUB_SWITCH(pg_gpo) bool write_pg_gpo_level(bool level)
The /PG/GPO pin is put in general purpose output mode when a switch drives it.
bool write_register_(uint8_t reg, uint8_t value)
bool config_matches_(const BQ25186StatusRegisters ®s) const
bool apply_config(const BQ25186ConfigRegisters ®s)
uint8_t expected_register_(size_t index) const
bool update_register_(uint8_t reg, uint8_t mask, uint8_t value)
void dump_config() override
bool write_ship_rst(uint8_t mask, uint8_t value)
Write the masked bits of SHIP_RST.
void set_setup_registers(const BQ25186ConfigRegisters ®s)
This Class provides the methods to read/write bytes from/to an i2c device.
I2CRegister reg(uint8_t a_register)
calls the I2CRegister constructor
std::array< uint8_t, BQ25186_CONFIG_REGISTER_COUNT > BQ25186ConfigRegisters
PROGMEM_STRING_TABLE(BQ25186StatusStrings, "Not Charging", "Constant Current", "Constant Voltage", "Charge Done/Disabled", "Normal", "Hot/Cold (Charging Suspended)", "Cool (Current Reduced)", "Warm (Voltage Reduced)")
std::array< uint8_t, BQ25186_STATUS_REGISTER_COUNT > BQ25186StatusRegisters