SensorLib 0.5.0
Multi-platform sensor driver library for Arduino, PlatformIO, and ESP-IDF
Loading...
Searching...
No Matches
PmicAXP202 Class Reference

Unified AXP202 PMIC driver. More...

#include <PmicAXP202.hpp>

Inheritance diagram for PmicAXP202:
[legend]

Public Member Functions

 PmicAXP202 ()
 Construct the AXP202 driver with all sub-modules.
 
bool begin (SensorCommCustom::CustomCallback callback, SensorCommCustomHal::CustomHalCallback hal_cb, uint8_t addr)
 Initialise the PMIC using custom communication callbacks.
 
void end ()
 De-initialise the PMIC (no-op)
 
PmicCapability::Capability getCapabilities () const override
 Get the PMIC capability flags.
 
const PmicConfiggetConfig () const override
 Get the PMIC configuration descriptor.
 
PmicPowerBasegetPower () override
 Access the power management interface.
 
PmicChargerBasegetCharger () override
 Access the charger interface.
 
PmicAdcBasegetAdc () override
 Access the ADC interface.
 
PmicGpioBasegetGpio () override
 Get GPIO interface.
 
PmicLedBasegetLed () override
 Access the LED control interface.
 
PmicChannelBasegetChannel () override
 Access the power channel control interface.
 
PmicIrqBasegetIrq () override
 Get interrupt interface.
 
const char * getChipName () const override
 Get the chip name string.
 
AXP1xxIrq< axp202_regs > & irq ()
 Access the IRQ (interrupt) interface.
 
AXP1xxTimer< axp202_regs > & timer ()
 Access the countdown timer subsystem.
 
AXP1xxCharger< axp202_regs > & charger ()
 Access the charger interface (chip-specific)
 
AXP202Gpiogpio ()
 Access the GPIO interface.
 
AXP202Adcadc ()
 Access the ADC interface (chip-specific)
 
AXP202Corecore ()
 Access the core communication interface.
 
AXP202PowerExpower ()
 Access AXP202-specific power extensions (DCDC mode, APS warning)
 
AXP202ChargerExchargerEx ()
 Access AXP202-specific charger extensions (thermal, backup, timeout)
 
AXP202Coulombcoulomb ()
 Access coulomb counter for charge/discharge energy measurement.
 
AXP1xxLed< axp202_regs > & led ()
 
AXP1xxPwron< axp202_regs > & pwron ()
 Access the power-button timing/control interface.
 
uint16_t getStatus ()
 Read combined STATUS and MODE_CHGSTATUS registers.
 
bool isVbusGood ()
 Check if VBUS is present and valid.
 
bool isBatteryConnect ()
 Check if a battery is connected.
 
bool isCharging ()
 Check if the battery is currently charging.
 
uint8_t getChipID ()
 Read the AXP202 chip ID register.
 
void shutdown ()
 Power off the PMIC (shutdown)
 
bool enableSleep (bool en)
 Enable or disable sleep mode.
 
- Public Member Functions inherited from PmicBase
virtual ~PmicBase ()=default
 Virtual destructor.
 

Detailed Description

Unified AXP202 PMIC driver.

Wraps all AXP202 sub-modules and provides a single entry point for initialisation, status query, and system control (shutdown, sleep).

Definition at line 84 of file PmicAXP202.hpp.

Constructor & Destructor Documentation

◆ PmicAXP202()

PmicAXP202::PmicAXP202 ( )
inline

Construct the AXP202 driver with all sub-modules.

Definition at line 90 of file PmicAXP202.hpp.

Member Function Documentation

◆ adc()

AXP202Adc & PmicAXP202::adc ( )
inline

Access the ADC interface (chip-specific)

Returns
Reference to AXP202Adc

Definition at line 316 of file PmicAXP202.hpp.

Referenced by loop(), and setup().

◆ begin()

bool PmicAXP202::begin ( SensorCommCustom::CustomCallback  callback,
SensorCommCustomHal::CustomHalCallback  hal_cb,
uint8_t  addr 
)
inlinevirtual

Initialise the PMIC using custom communication callbacks.

Parameters
callbackCustom I2C callback function
hal_cbCustom HAL-level callback
addrI2C slave address
Returns
true on success

Implements PmicBase.

Definition at line 148 of file PmicAXP202.hpp.

References I2CDeviceWithHal::begin().

Referenced by setup().

◆ charger()

AXP1xxCharger< axp202_regs > & PmicAXP202::charger ( )
inline

Access the charger interface (chip-specific)

Returns
Reference to AXP1xxCharger<axp202_regs>

Definition at line 298 of file PmicAXP202.hpp.

◆ chargerEx()

AXP202ChargerEx & PmicAXP202::chargerEx ( )
inline

Access AXP202-specific charger extensions (thermal, backup, timeout)

Returns
Reference to AXP202ChargerEx

Definition at line 343 of file PmicAXP202.hpp.

◆ core()

AXP202Core & PmicAXP202::core ( )
inline

Access the core communication interface.

Returns
Reference to AXP202Core

Definition at line 325 of file PmicAXP202.hpp.

◆ coulomb()

AXP202Coulomb & PmicAXP202::coulomb ( )
inline

Access coulomb counter for charge/discharge energy measurement.

Returns
Reference to AXP202Coulomb

Definition at line 352 of file PmicAXP202.hpp.

◆ enableSleep()

bool PmicAXP202::enableSleep ( bool  en)
inline

Enable or disable sleep mode.

Parameters
entrue to enter sleep, false to wake
Returns
true on success
Note
Sleep mode is controlled via VOFF_SET register bit 3.

Definition at line 444 of file PmicAXP202.hpp.

References SensorCommWrapper::clrRegBit(), SensorCommWrapper::setRegBit(), and axp202_regs::pmu::VOFF_SET.

◆ end()

void PmicAXP202::end ( )
inlinevirtual

De-initialise the PMIC (no-op)

Implements PmicBase.

Definition at line 158 of file PmicAXP202.hpp.

◆ getAdc()

PmicAdcBase & PmicAXP202::getAdc ( )
inlineoverridevirtual

Access the ADC interface.

Returns
Reference to AXP202Adc

Implements PmicBase.

Definition at line 232 of file PmicAXP202.hpp.

◆ getCapabilities()

◆ getChannel()

PmicChannelBase * PmicAXP202::getChannel ( )
inlineoverridevirtual

Access the power channel control interface.

Returns
Pointer to AXP202Channel instance

Reimplemented from PmicBase.

Definition at line 255 of file PmicAXP202.hpp.

Referenced by setup().

◆ getCharger()

PmicChargerBase * PmicAXP202::getCharger ( )
inlineoverridevirtual

Access the charger interface.

Returns
Pointer to AXP1xxCharger, or nullptr if unsupported

Reimplemented from PmicBase.

Definition at line 223 of file PmicAXP202.hpp.

Referenced by loop(), and setup().

◆ getChipID()

uint8_t PmicAXP202::getChipID ( )
inline

Read the AXP202 chip ID register.

Returns
Chip ID byte (expected 0x41), or 0 on error

Definition at line 416 of file PmicAXP202.hpp.

References axp202_regs::bmu::IC_TYPE, and SensorCommWrapper::readReg().

◆ getChipName()

const char * PmicAXP202::getChipName ( ) const
inlineoverridevirtual

Get the chip name string.

Returns
"AXP202"

Implements PmicBase.

Definition at line 269 of file PmicAXP202.hpp.

◆ getConfig()

const PmicConfig & PmicAXP202::getConfig ( ) const
inlineoverridevirtual

Get the PMIC configuration descriptor.

Returns
Reference to a static PmicConfig with chip name, address, chip ID register/value, channel count, and capabilities

Implements PmicBase.

Definition at line 183 of file PmicAXP202.hpp.

References PmicConfig::chipName, PmicCapability::PmicSupportAdc, PmicCapability::PmicSupportChannel, PmicCapability::PmicSupportCharger, PmicCapability::PmicSupportGpio, PmicCapability::PmicSupportIrq, PmicCapability::PmicSupportLed, PmicCapability::PmicSupportPower, and PmicCapability::PmicSupportPowerBtn.

◆ getGpio()

PmicGpioBase * PmicAXP202::getGpio ( )
inlineoverridevirtual

Get GPIO interface.

Returns
Pointer to GPIO interface, nullptr if not supported
Note
GPIO support is optional across PMICs. Callers should check for nullptr before use and/or verify capability flags.

Reimplemented from PmicBase.

Definition at line 237 of file PmicAXP202.hpp.

◆ getIrq()

PmicIrqBase * PmicAXP202::getIrq ( )
inlineoverridevirtual

Get interrupt interface.

Returns
Pointer to interrupt interface, nullptr if not supported
Note
This accessor uses the "getXxx" style intentionally because IRQ support is optional across PMICs. Callers should check for nullptr before use (similar to getCharger()).
Chip-specific drivers may additionally expose irq() returning a concrete IRQ type (for chip-specific helper APIs). Use getIrq() when working through a PmicBase pointer/reference.

Reimplemented from PmicBase.

Definition at line 260 of file PmicAXP202.hpp.

◆ getLed()

PmicLedBase & PmicAXP202::getLed ( )
inlineoverridevirtual

Access the LED control interface.

Returns
Reference to AXP1xxLed

Implements PmicBase.

Definition at line 246 of file PmicAXP202.hpp.

◆ getPower()

PmicPowerBase & PmicAXP202::getPower ( )
inlineoverridevirtual

Access the power management interface.

Returns
Reference to AXP1xxPower

Implements PmicBase.

Definition at line 214 of file PmicAXP202.hpp.

◆ getStatus()

uint16_t PmicAXP202::getStatus ( )
inline

Read combined STATUS and MODE_CHGSTATUS registers.

Returns
16-bit value: high byte = STATUS (0x00), low byte = MODE_CHGSTATUS (0x01)

Definition at line 377 of file PmicAXP202.hpp.

References axp202_regs::bmu::MODE_CHGSTATUS, SensorCommWrapper::readReg(), and axp202_regs::bmu::STATUS.

◆ gpio()

AXP202Gpio & PmicAXP202::gpio ( )
inline

Access the GPIO interface.

Returns
Reference to AXP202Gpio

Definition at line 307 of file PmicAXP202.hpp.

◆ irq()

AXP1xxIrq< axp202_regs > & PmicAXP202::irq ( )
inline

Access the IRQ (interrupt) interface.

Returns
Reference to AXP1xxIrq<axp202_regs>

Definition at line 280 of file PmicAXP202.hpp.

Referenced by loop(), and setup().

◆ isBatteryConnect()

bool PmicAXP202::isBatteryConnect ( )
inline

Check if a battery is connected.

Returns
true if battery is detected (MODE_CHGSTATUS register bit 5)

Definition at line 398 of file PmicAXP202.hpp.

References SensorCommWrapper::getRegBit(), and axp202_regs::bmu::MODE_CHGSTATUS.

◆ isCharging()

bool PmicAXP202::isCharging ( )
inline

Check if the battery is currently charging.

Returns
true if charging

Definition at line 407 of file PmicAXP202.hpp.

References AXP1xxCharger< Regs >::isCharging().

◆ isVbusGood()

bool PmicAXP202::isVbusGood ( )
inline

Check if VBUS is present and valid.

Returns
true if VBUS is good (STATUS register bit 5)

Definition at line 389 of file PmicAXP202.hpp.

References SensorCommWrapper::getRegBit(), and axp202_regs::bmu::STATUS.

◆ led()

AXP1xxLed< axp202_regs > & PmicAXP202::led ( )
inline

Definition at line 357 of file PmicAXP202.hpp.

Referenced by setup().

◆ power()

AXP202PowerEx & PmicAXP202::power ( )
inline

Access AXP202-specific power extensions (DCDC mode, APS warning)

Returns
Reference to AXP202PowerEx

Definition at line 334 of file PmicAXP202.hpp.

◆ pwron()

AXP1xxPwron< axp202_regs > & PmicAXP202::pwron ( )
inline

Access the power-button timing/control interface.

Returns
Reference to AXP1xxPwron<axp202_regs>

Definition at line 366 of file PmicAXP202.hpp.

◆ shutdown()

void PmicAXP202::shutdown ( )
inline

Power off the PMIC (shutdown)

Sets the OFF_CTL register bit 7 to initiate a system power-down. The PMIC will remain off until the power key is pressed or VBUS is applied.

Definition at line 432 of file PmicAXP202.hpp.

References axp202_regs::pmu::OFF_CTL, and SensorCommWrapper::setRegBit().

◆ timer()

AXP1xxTimer< axp202_regs > & PmicAXP202::timer ( )
inline

Access the countdown timer subsystem.

Returns
Reference to AXP1xxTimer<axp202_regs>

Definition at line 289 of file PmicAXP202.hpp.

Referenced by loop(), and setup().


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