|
SensorLib 0.5.0
Multi-platform sensor driver library for Arduino, PlatformIO, and ESP-IDF
|
#include <AXP1xxCharger.hpp>
Public Member Functions | |
| AXP1xxCharger (SensorCommWrapper &core) | |
| Construct charger control interface. | |
| bool | enableCharging (bool enable) override |
| Enable or disable battery charging. | |
| bool | isCharging () override |
| Check whether the battery is currently charging. | |
| bool | setPreChargeCurrent (uint16_t mA) override |
| Set pre-charge current (not supported by AXP1xx). | |
| uint16_t | getPreChargeCurrent () override |
| Get pre-charge current (not supported by AXP1xx). | |
| bool | setFastChargeCurrent (uint16_t mA) override |
| Set fast charge (constant-current) current. | |
| uint16_t | getFastChargeCurrent () override |
| Get the fast charge (constant-current) current. | |
| bool | setTerminationCurrent (uint16_t mA) override |
| Set the termination current threshold. | |
| uint16_t | getTerminationCurrent () override |
| Get the termination current threshold. | |
| bool | setChargeVoltage (uint16_t mV) override |
| Set the charge target voltage (CV). | |
| uint16_t | getChargeVoltage () override |
| Get the charge target voltage (CV). | |
| Status | getStatus () override |
| Get the charger status. | |
Public Member Functions inherited from PmicChargerBase | |
| virtual | ~PmicChargerBase ()=default |
| Virtual destructor. | |
Protected Attributes | |
| SensorCommWrapper & | _core |
Additional Inherited Members | |
Public Types inherited from PmicChargerBase | |
| enum class | ChargingStatus : uint8_t { NO_CHARGING = 0 , PRE_CHARGE = 1 , FAST_CHARGE = 2 , TERMINATION = 3 , UNKNOWN = 0xFF } |
| Charging status enumeration. More... | |
Definition at line 36 of file AXP1xxCharger.hpp.
|
inlineexplicit |
Construct charger control interface.
| core | Reference to the I2C communication wrapper. |
Definition at line 43 of file AXP1xxCharger.hpp.
|
inlineoverridevirtual |
Enable or disable battery charging.
Controls CHARGE1 register bit 7.
| enable | true to enable charging, false to disable. |
| true | Charging was configured successfully. |
| false | I2C communication failed. |
Implements PmicChargerBase.
Definition at line 54 of file AXP1xxCharger.hpp.
References AXP1xxCharger< Regs >::_core, SensorCommWrapper::clrRegBit(), and SensorCommWrapper::setRegBit().
|
inlineoverridevirtual |
Get the charge target voltage (CV).
Implements PmicChargerBase.
Definition at line 182 of file AXP1xxCharger.hpp.
References AXP1xxCharger< Regs >::_core, and SensorCommWrapper::readReg().
|
inlineoverridevirtual |
Get the fast charge (constant-current) current.
Implements PmicChargerBase.
Definition at line 115 of file AXP1xxCharger.hpp.
References AXP1xxCharger< Regs >::_core, and SensorCommWrapper::readReg().
|
inlineoverridevirtual |
Get pre-charge current (not supported by AXP1xx).
Implements PmicChargerBase.
Definition at line 84 of file AXP1xxCharger.hpp.
|
inlineoverridevirtual |
Get the charger status.
Reads the STATUS and MODE_CHGSTATUS registers to determine VBUS presence, battery presence, charging state, and fault conditions.
Implements PmicChargerBase.
Definition at line 204 of file AXP1xxCharger.hpp.
References AXP1xxCharger< Regs >::_core, PmicChargerBase::FAST_CHARGE, PmicChargerBase::NO_CHARGING, and SensorCommWrapper::readReg().
Referenced by AXP1xxCharger< Regs >::isCharging().
|
inlineoverridevirtual |
Get the termination current threshold.
Implements PmicChargerBase.
Definition at line 143 of file AXP1xxCharger.hpp.
References AXP1xxCharger< Regs >::_core, and SensorCommWrapper::readReg().
|
inlineoverridevirtual |
Check whether the battery is currently charging.
Implements PmicChargerBase.
Definition at line 64 of file AXP1xxCharger.hpp.
References PmicChargerBase::Status::charging, and AXP1xxCharger< Regs >::getStatus().
Referenced by PmicAXP192::isCharging(), and PmicAXP202::isCharging().
|
inlineoverridevirtual |
Set the charge target voltage (CV).
Programs CHARGE1 register bits 5-6 using a lookup table.
| mV | Desired charge voltage in millivolts. Values <= 4100 set 4100mV. Values <= 4150 set 4150mV. Values <= 4200 set 4200mV. Values > 4200 set 4360mV. |
| true | Voltage was set successfully. |
| false | I2C communication failed. |
Implements PmicChargerBase.
Definition at line 163 of file AXP1xxCharger.hpp.
References AXP1xxCharger< Regs >::_core, and SensorCommWrapper::updateBits().
|
inlineoverridevirtual |
Set fast charge (constant-current) current.
Programs CHARGE1 register bits 0-3. The value is clamped to the valid range. axp192: Set in 90mA steps, close to the set value. axp202: Set in 100mA steps.
| mA | Desired fast charge current in milliamps |
| true | Current was set successfully. |
| false | I2C communication failed. |
Implements PmicChargerBase.
Definition at line 100 of file AXP1xxCharger.hpp.
References AXP1xxCharger< Regs >::_core, SensorCommWrapper::readReg(), and SensorCommWrapper::writeReg().
|
inlineoverridevirtual |
Set pre-charge current (not supported by AXP1xx).
| mA | Pre-charge current in milliamps (ignored). |
Implements PmicChargerBase.
Definition at line 74 of file AXP1xxCharger.hpp.
|
inlineoverridevirtual |
Set the termination current threshold.
Controls CHARGE1 register bit 4. When set, termination current is approximately 150mA.
| mA | Desired termination current in milliamps (>=150 sets threshold). |
| true | Threshold was set successfully. |
| false | I2C communication failed. |
Implements PmicChargerBase.
Definition at line 133 of file AXP1xxCharger.hpp.
References AXP1xxCharger< Regs >::_core, and SensorCommWrapper::updateBits().
|
protected |
Definition at line 227 of file AXP1xxCharger.hpp.
Referenced by AXP1xxCharger< Regs >::enableCharging(), AXP1xxCharger< Regs >::getChargeVoltage(), AXP1xxCharger< Regs >::getFastChargeCurrent(), AXP1xxCharger< Regs >::getStatus(), AXP1xxCharger< Regs >::getTerminationCurrent(), AXP1xxCharger< Regs >::setChargeVoltage(), AXP1xxCharger< Regs >::setFastChargeCurrent(), and AXP1xxCharger< Regs >::setTerminationCurrent().