SensorLib 0.5.0
Multi-platform sensor driver library for Arduino, PlatformIO, and ESP-IDF
Loading...
Searching...
No Matches
AXP2101Charger.hpp
Go to the documentation of this file.
1
31#pragma once
32#include "../../PmicChargerBase.hpp"
33#include "AXP2101Core.hpp"
34
36{
37public:
42 explicit AXP2101Charger(AXP2101Core &core);
43 ~AXP2101Charger() = default;
44
45 // ---- PmicChargerBase overrides ----
46
53 bool enableCharging(bool enable) override;
54
60 bool isCharging() override;
61
68 bool setPreChargeCurrent(uint16_t mA) override;
69
75 uint16_t getPreChargeCurrent() override;
76
84 bool setFastChargeCurrent(uint16_t mA) override;
85
91 uint16_t getFastChargeCurrent() override;
92
99 bool setTerminationCurrent(uint16_t mA) override;
100
106 uint16_t getTerminationCurrent() override;
107
114 bool setChargeVoltage(uint16_t mV) override;
115
120 uint16_t getChargeVoltage() override;
121
129 Status getStatus() override;
130
131 // ---- Termination Control (REG 63 bit 4) ----
132
138
144
150
151 // ---- Button Battery Charge (REG 18 bit 2, REG 6A) ----
152
157
162
168
175 bool setButtonBatteryChargeVoltage(uint16_t millivolt);
176
182
183 // ---- Battery Detection (REG 68 bit 0) ----
184
190
195
201
202 // ---- Charger Safety Timer (REG 67) ----
203
209 void setPreChargeSafetyTimer(uint8_t opt);
210
216 void setChargeDoneSafetyTimer(uint8_t opt);
217
218 // ---- Thermal Regulation (REG 65) ----
219
225 void setThermalRegulationThreshold(uint8_t opt);
226
232
233 // ---- JEITA Temperature Protection (REG 54-5B) ----
234
240 bool enableJeita(bool enable);
241
246 bool isJeitaEnabled();
247
248 // -- Temperature Fault Thresholds --
249
255 bool setChargeLowTempFaultThreshold(uint8_t val);
256
262
268 bool setChargeHighTempFaultThreshold(uint8_t val);
269
275
281 bool setWorkLowTempFaultThreshold(uint8_t val);
282
288
294 bool setWorkHighTempFaultThreshold(uint8_t val);
295
301
302 // -- Temperature Hysteresis --
303
309 bool setLowTempHysteresis(uint8_t val);
310
315 uint8_t getLowTempHysteresis();
316
322 bool setHighTempHysteresis(uint8_t val);
323
328 uint8_t getHighTempHysteresis();
329
330 // -- JEITA CV Configuration (REG 59) --
331
337 bool setJeitaWarmCurrentReduction(bool reduce);
338
344
350 bool setJeitaCoolCurrentReduction(bool reduce);
351
357
363 bool setJeitaWarmVoltageDrop(uint8_t levels);
364
369 uint8_t getJeitaWarmVoltageDrop();
370
376 bool setJeitaCoolVoltageDrop(uint8_t levels);
377
382 uint8_t getJeitaCoolVoltageDrop();
383
384 // -- JEITA Temperature Thresholds (REG 5B) --
385
391 bool setJeitaCoolThreshold(uint8_t val);
392
397 uint8_t getJeitaCoolThreshold();
398
404 bool setJeitaWarmThreshold(uint8_t val);
405
410 uint8_t getJeitaWarmThreshold();
411
412private:
413 AXP2101Core &_core;
414};
@license MIT License
Status getStatus() override
Get the current charger status.
void disableButtonBatteryCharge()
Disable button/coin-cell battery charging (REG 0x18, bit 2).
bool isCharging() override
Check if the charger is actively charging.
uint8_t getChargeHighTempFaultThreshold()
Get charge high-temperature fault threshold (REG 55, VHTF_CHG).
bool isBatteryDetectionEnabled()
Check if battery detection is enabled (REG 0x68, bit 0).
void disableBatteryDetection()
Disable battery detection (REG 0x68, bit 0).
bool setLowTempHysteresis(uint8_t val)
Set low-temperature hysteresis (REG 52, HYSL2H).
void enableBatteryDetection()
Enable battery detection (REG 0x68, bit 0).
bool setChargeLowTempFaultThreshold(uint8_t val)
Set charge low-temperature fault threshold (REG 54, VLTF_CHG).
bool setJeitaCoolVoltageDrop(uint8_t levels)
Set cool-zone voltage drop levels in JEITA.
uint16_t getPreChargeCurrent() override
Get the configured precharge current (REG 0x61, bits 3:0).
bool setJeitaCoolThreshold(uint8_t val)
Set JEITA cool temperature threshold T2 (REG 5B low nibble).
bool setWorkLowTempFaultThreshold(uint8_t val)
Set work low-temperature fault threshold (REG 56, VLTF_WORK).
uint8_t getJeitaWarmVoltageDrop()
Get warm-zone voltage drop levels in JEITA (REG 0x59).
uint8_t getJeitaWarmThreshold()
Get JEITA warm temperature threshold T3 (REG 5B high nibble).
void enableButtonBatteryCharge()
Enable button/coin-cell battery charging (REG 0x18, bit 2).
uint8_t getThermalRegulationThreshold()
Get the thermal regulation threshold (REG 0x65, bits 1:0).
bool setJeitaWarmVoltageDrop(uint8_t levels)
Set warm-zone voltage drop levels in JEITA.
uint8_t getLowTempHysteresis()
Get low-temperature hysteresis (REG 52, HYSL2H).
bool setFastChargeCurrent(uint16_t mA) override
Set the fast-charge current limit (REG 0x62, bits 4:0).
bool setJeitaCoolCurrentReduction(bool reduce)
Set cool-zone current reduction in JEITA.
bool setPreChargeCurrent(uint16_t mA) override
Set the precharge current limit (REG 0x61, bits 3:0).
void setChargeDoneSafetyTimer(uint8_t opt)
Set the charge-done safety timer (REG 0x67, bits 6:4).
uint8_t getWorkLowTempFaultThreshold()
Get work low-temperature fault threshold (REG 56, VLTF_WORK).
bool enableJeita(bool enable)
Enable or disable JEITA temperature standard.
~AXP2101Charger()=default
bool setChargeVoltage(uint16_t mV) override
Set the charge voltage target (REG 0x64, bits 2:0).
bool setHighTempHysteresis(uint8_t val)
Set high-temperature hysteresis (REG 53, HYSH2L).
uint8_t getHighTempHysteresis()
Get high-temperature hysteresis (REG 53, HYSH2L).
bool isJeitaEnabled()
Check if JEITA temperature standard is enabled.
void enableChargeTermination()
Enable charge termination detection (REG 0x63, bit 4).
bool getJeitaCoolCurrentReduction()
Get cool-zone current reduction setting in JEITA (REG 0x59).
uint16_t getButtonBatteryChargeVoltage()
Get the configured button battery charge voltage (REG 0x6A, bits 2:0).
uint8_t getJeitaCoolThreshold()
Get JEITA cool temperature threshold T2 (REG 5B low nibble).
uint8_t getJeitaCoolVoltageDrop()
Get cool-zone voltage drop levels in JEITA (REG 0x59).
bool enableCharging(bool enable) override
Enable or disable battery charging.
uint16_t getChargeVoltage() override
Get the configured charge voltage target (REG 0x64, bits 2:0).
void disableChargeTermination()
Disable charge termination detection (REG 0x63, bit 4).
uint16_t getFastChargeCurrent() override
Get the configured fast-charge current (REG 0x62, bits 4:0).
bool setChargeHighTempFaultThreshold(uint8_t val)
Set charge high-temperature fault threshold (REG 55, VHTF_CHG).
bool isButtonBatteryChargeEnabled()
Check if button battery charging is enabled (REG 0x18, bit 2).
bool setWorkHighTempFaultThreshold(uint8_t val)
Set work high-temperature fault threshold (REG 57, VHTF_WORK).
uint8_t getChargeLowTempFaultThreshold()
Get charge low-temperature fault threshold (REG 54, VLTF_CHG).
bool setJeitaWarmThreshold(uint8_t val)
Set JEITA warm temperature threshold T3 (REG 5B high nibble).
bool setButtonBatteryChargeVoltage(uint16_t millivolt)
Set the button battery charge voltage (REG 0x6A, bits 2:0).
bool getJeitaWarmCurrentReduction()
Get warm-zone current reduction setting in JEITA (REG 0x59).
void setPreChargeSafetyTimer(uint8_t opt)
Set the precharge safety timer (REG 0x67, bits 2:0).
uint8_t getWorkHighTempFaultThreshold()
Get work high-temperature fault threshold (REG 57, VHTF_WORK).
bool setJeitaWarmCurrentReduction(bool reduce)
Set warm-zone current reduction in JEITA.
uint16_t getTerminationCurrent() override
Get the configured termination current (REG 0x63, bits 3:0).
bool setTerminationCurrent(uint16_t mA) override
Set the charge termination current (REG 0x63, bits 3:0).
void setThermalRegulationThreshold(uint8_t opt)
Set the thermal regulation threshold (REG 0x65, bits 1:0).
bool isChargeTerminationEnabled()
Check if charge termination detection is enabled (REG 0x63, bit 4).
Core I2C communication layer for the AXP2101 PMIC.
PMIC charger capability interface.
Charger status structure.