SensorLib 0.5.0
Multi-platform sensor driver library for Arduino, PlatformIO, and ESP-IDF
Loading...
Searching...
No Matches
AXP1xxCharger< Regs > Class Template Reference

#include <AXP1xxCharger.hpp>

Inheritance diagram for AXP1xxCharger< Regs >:
[legend]

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...
 

Detailed Description

template<typename Regs>
class AXP1xxCharger< Regs >

Definition at line 36 of file AXP1xxCharger.hpp.

Constructor & Destructor Documentation

◆ AXP1xxCharger()

template<typename Regs >
AXP1xxCharger< Regs >::AXP1xxCharger ( SensorCommWrapper core)
inlineexplicit

Construct charger control interface.

Parameters
coreReference to the I2C communication wrapper.

Definition at line 43 of file AXP1xxCharger.hpp.

Member Function Documentation

◆ enableCharging()

template<typename Regs >
bool AXP1xxCharger< Regs >::enableCharging ( bool  enable)
inlineoverridevirtual

Enable or disable battery charging.

Controls CHARGE1 register bit 7.

Parameters
enabletrue to enable charging, false to disable.
Return values
trueCharging was configured successfully.
falseI2C communication failed.

Implements PmicChargerBase.

Definition at line 54 of file AXP1xxCharger.hpp.

References AXP1xxCharger< Regs >::_core, SensorCommWrapper::clrRegBit(), and SensorCommWrapper::setRegBit().

◆ getChargeVoltage()

template<typename Regs >
uint16_t AXP1xxCharger< Regs >::getChargeVoltage ( )
inlineoverridevirtual

Get the charge target voltage (CV).

Returns
Charge voltage in millivolts (4100, 4150, 4200, or 4360), or 0 on error.

Implements PmicChargerBase.

Definition at line 182 of file AXP1xxCharger.hpp.

References AXP1xxCharger< Regs >::_core, and SensorCommWrapper::readReg().

◆ getFastChargeCurrent()

template<typename Regs >
uint16_t AXP1xxCharger< Regs >::getFastChargeCurrent ( )
inlineoverridevirtual

Get the fast charge (constant-current) current.

Returns
Fast charge current in milliamps, or 0 on error.

Implements PmicChargerBase.

Definition at line 115 of file AXP1xxCharger.hpp.

References AXP1xxCharger< Regs >::_core, and SensorCommWrapper::readReg().

◆ getPreChargeCurrent()

template<typename Regs >
uint16_t AXP1xxCharger< Regs >::getPreChargeCurrent ( )
inlineoverridevirtual

Get pre-charge current (not supported by AXP1xx).

Returns
Always 0.

Implements PmicChargerBase.

Definition at line 84 of file AXP1xxCharger.hpp.

◆ getStatus()

template<typename Regs >
Status AXP1xxCharger< Regs >::getStatus ( )
inlineoverridevirtual

Get the charger status.

Reads the STATUS and MODE_CHGSTATUS registers to determine VBUS presence, battery presence, charging state, and fault conditions.

Returns
Status structure with current charger state.

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().

◆ getTerminationCurrent()

template<typename Regs >
uint16_t AXP1xxCharger< Regs >::getTerminationCurrent ( )
inlineoverridevirtual

Get the termination current threshold.

Returns
Termination current in milliamps (0 if unknown).

Implements PmicChargerBase.

Definition at line 143 of file AXP1xxCharger.hpp.

References AXP1xxCharger< Regs >::_core, and SensorCommWrapper::readReg().

◆ isCharging()

template<typename Regs >
bool AXP1xxCharger< Regs >::isCharging ( )
inlineoverridevirtual

Check whether the battery is currently charging.

Returns
true if charging, false otherwise.

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().

◆ setChargeVoltage()

template<typename Regs >
bool AXP1xxCharger< Regs >::setChargeVoltage ( uint16_t  mV)
inlineoverridevirtual

Set the charge target voltage (CV).

Programs CHARGE1 register bits 5-6 using a lookup table.

Parameters
mVDesired charge voltage in millivolts. Values <= 4100 set 4100mV. Values <= 4150 set 4150mV. Values <= 4200 set 4200mV. Values > 4200 set 4360mV.
Return values
trueVoltage was set successfully.
falseI2C communication failed.

Implements PmicChargerBase.

Definition at line 163 of file AXP1xxCharger.hpp.

References AXP1xxCharger< Regs >::_core, and SensorCommWrapper::updateBits().

◆ setFastChargeCurrent()

template<typename Regs >
bool AXP1xxCharger< Regs >::setFastChargeCurrent ( uint16_t  mA)
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.

Parameters
mADesired fast charge current in milliamps
Return values
trueCurrent was set successfully.
falseI2C communication failed.

Implements PmicChargerBase.

Definition at line 100 of file AXP1xxCharger.hpp.

References AXP1xxCharger< Regs >::_core, SensorCommWrapper::readReg(), and SensorCommWrapper::writeReg().

◆ setPreChargeCurrent()

template<typename Regs >
bool AXP1xxCharger< Regs >::setPreChargeCurrent ( uint16_t  mA)
inlineoverridevirtual

Set pre-charge current (not supported by AXP1xx).

Parameters
mAPre-charge current in milliamps (ignored).
Returns
Always false.

Implements PmicChargerBase.

Definition at line 74 of file AXP1xxCharger.hpp.

◆ setTerminationCurrent()

template<typename Regs >
bool AXP1xxCharger< Regs >::setTerminationCurrent ( uint16_t  mA)
inlineoverridevirtual

Set the termination current threshold.

Controls CHARGE1 register bit 4. When set, termination current is approximately 150mA.

Parameters
mADesired termination current in milliamps (>=150 sets threshold).
Return values
trueThreshold was set successfully.
falseI2C communication failed.

Implements PmicChargerBase.

Definition at line 133 of file AXP1xxCharger.hpp.

References AXP1xxCharger< Regs >::_core, and SensorCommWrapper::updateBits().

Member Data Documentation

◆ _core


The documentation for this class was generated from the following file: