48#define CHECK_FOR_ERRORS(condition) if (condition) {Serial.println("BQ25896 error"); while(1)delay(1000);}
53 Serial.println(
"╔══════════════════════════════════════════╗");
54 Serial.println(
"║ BQ25896 Charger Test ║");
55 Serial.println(
"╚══════════════════════════════════════════╝");
72 Serial.println(
"BQ25896 begin() failed. Check wiring.");
78 Serial.println(
"BQ25896 initialized successfully");
96 Serial.print(
"Pre Charge Current: ");
98 Serial.print(
"Fast Charge Current: ");
100 Serial.print(
"Termination Current: ");
102 Serial.print(
"Charge Voltage: ");
112 Serial.print(
"Input Current Limit: ");
114 Serial.print(
"Input Voltage Limit: ");
116 Serial.print(
"Minimum System Voltage: ");
126 Serial.println(
"Setup complete!");
135 Serial.println(
"\n========== BQ25896 Status ==========");
141 Serial.print(
"VBUS Voltage: ");
142 Serial.print(ret ? val : -1);
143 Serial.println(
" mV");
146 Serial.print(
"Battery Voltage: ");
147 Serial.print(ret ? val : -1);
148 Serial.println(
" mV");
151 Serial.print(
"VSYS Voltage: ");
152 Serial.print(ret ? val : -1);
153 Serial.println(
" mV");
156 Serial.print(
"Battery Current: ");
157 Serial.print(ret ? val : -1);
158 Serial.println(
" mA");
161 Serial.print(
"NTC Temperature: ");
162 Serial.print(ret ? val : -1);
163 Serial.println(
" %");
165 Serial.print(
"Charging: ");
169 Serial.print(
"Online: ");
170 Serial.println(status.
online ?
"Yes" :
"No");
171 Serial.print(
"VBUS Present: ");
173 Serial.print(
"Charge Done: ");
174 Serial.println(status.
chargeDone ?
"Yes" :
"No");
175 Serial.print(
"Fault: ");
176 Serial.println(status.
fault ?
"Yes" :
"No");
178 Serial.print(
"Boost Enabled: ");
181 Serial.print(
"Boost Voltage: ");
184 Serial.print(
"ICO Optimized: ");
187 Serial.print(
"VINDPM Active: ");
190 Serial.print(
"IINDPM Active: ");
193 Serial.print(
"VSYS in Regulation: ");
196 Serial.println(
"===================================\n");
#define CHECK_FOR_ERRORS(condition)
bool enableChannels(uint32_t mask) override
Enable one or more ADC channels.
static constexpr uint8_t ADC_CONV_START
ADC control flags.
bool read(Channel ch, float &out) override
Read ADC value for specified channel.
bool setFastChargeCurrent(uint16_t mA) override
Set fast charge (constant-current) current.
uint16_t getPreChargeCurrent() override
Get pre-charge current.
uint16_t getFastChargeCurrent() override
Get fast charge current.
bool setTerminationCurrent(uint16_t mA) override
Set termination current.
bool setChargeVoltage(uint16_t mV) override
Set charge voltage (constant voltage phase)
uint16_t getChargeVoltage() override
Get charge voltage.
bool isCharging() override
Check if charging is in progress.
bool setPreChargeCurrent(uint16_t mA) override
Set pre-charge current.
uint16_t getTerminationCurrent() override
Get termination current.
Status getStatus() override
Get charger status.
bool isInputCurrentOptimizerOptimized()
Check if Input Current Optimizer has optimized.
bool isVsysInRegulation()
Check if VSYS is in regulation.
bool isVindpmActive()
Get fault status.
bool isIindpmActive()
Check if IINDPM is active (input current limiting)
bool setMode(Mode mode) override
Set LED operating mode.
bool isBoostEnabled() const override
Check if boost mode is enabled.
bool setMinimumSystemVoltage(uint32_t mv) override
Set minimum system voltage.
bool setInputVoltageLimit(uint32_t mv) override
Set input voltage limit (VINDPM)
bool setInputCurrentLimit(uint32_t mA) override
Set input current limit.
uint32_t getInputVoltageLimit() const override
Get input voltage limit.
uint16_t getBoostVoltage() const override
Get boost output voltage.
uint32_t getInputCurrentLimit() const override
Get input current limit.
uint32_t getMinimumSystemVoltage() const override
Get minimum system voltage.
@ BAT_VOLTAGE
Battery voltage.
@ BAT_TEMPERATURE
Battery temperature.
@ BAT_CURRENT
Battery current.
@ VBUS_VOLTAGE
VBUS voltage.
@ VSYS_VOLTAGE
VSYS voltage.
BQ25896Core & core()
Get core interface (mutable)
bool begin(SensorCommCustom::CustomCallback callback, SensorCommCustomHal::CustomHalCallback hal_cb, uint8_t addr)
Initialize using custom I2C callback.
BQ25896Charger & charger()
Get charger interface.
@ DISABLE
LED is disabled (if supported).
Charger status structure.
bool vbusPresent
VBUS detected / good (USB power present)
bool chargeDone
Charge termination/done (battery full)
bool fault
Any fault latched/active.
bool online
PMIC reachable / initialized.