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

Top-level unified interface for the AXP2101 PMIC. More...

#include <PmicAXP2101.hpp>

Inheritance diagram for PmicAXP2101:
[legend]

Public Types

using Module = AXP2101Core::Module
 

Public Member Functions

 PmicAXP2101 ()
 Construct the AXP2101 PMIC interface, initialising all sub-modules.
 
bool begin (SensorCommCustom::CustomCallback callback, SensorCommCustomHal::CustomHalCallback hal_cb, uint8_t addr)
 Initialise the AXP2101 with custom communication callbacks.
 
void end ()
 De-initialise the PMIC (no-op for AXP2101).
 
PmicCapability::Capability getCapabilities () const override
 Get the supported PMIC capabilities bitmask.
 
const PmicConfiggetConfig () const override
 Get the PMIC configuration descriptor.
 
PmicPowerBasegetPower () override
 Get the power management interface.
 
PmicChargerBasegetCharger () override
 Get the charger interface (pointer for optional support).
 
PmicAdcBasegetAdc () override
 Get the ADC interface.
 
PmicLedBasegetLed () override
 Get the LED interface.
 
PmicChannelBasegetChannel () override
 Get the power output channel interface.
 
PmicIrqBasegetIrq () override
 Get interrupt interface.
 
const char * getChipName () const override
 Get the human-readable chip name.
 
AXP2101Irqirq ()
 Get the chip-specific IRQ controller.
 
AXP2101Chargercharger ()
 Get the chip-specific charger interface.
 
AXP2101Ledled ()
 Get the chip-specific LED module.
 
AXP2101Pwronpwron ()
 Get the chip-specific power button interface.
 
AXP2101Watchdogwatchdog ()
 Get the chip-specific watchdog interface.
 
AXP2101Adcadc ()
 Get the chip-specific ADC interface.
 
AXP2101Corecore ()
 Get the core I2C communication interface.
 
AXP2101Powerpower ()
 Get the chip-specific power management interface.
 
bool enableModule (Module module, bool enable)
 Enable or disable an internal functional module.
 
bool isModuleEnabled (Module module)
 Check whether an internal module is enabled.
 
uint16_t getStatus ()
 Read the combined STATUS1 and STATUS2 registers.
 
bool isVbusGood ()
 Check if a valid VBUS power source is present.
 
bool isBatteryConnect ()
 Check if a battery is connected.
 
bool isCharging ()
 Check if the battery is currently charging.
 
uint8_t getChipID ()
 Read the AXP2101 chip ID / version register.
 
void shutdown ()
 Soft power-off the PMIC.
 
void reset ()
 Reset (restart) the SoC system.
 
- Public Member Functions inherited from PmicBase
virtual ~PmicBase ()=default
 Virtual destructor.
 
virtual PmicGpioBasegetGpio ()
 Get GPIO interface.
 

Detailed Description

Top-level unified interface for the AXP2101 PMIC.

Aggregates all AXP2101 sub-modules (ADC, IRQ, charger, LED, power, power button, watchdog, and power channels) into a single convenient class. Provides I2C initialisation across multiple platforms (Arduino, ESP-IDF, custom HAL) and exposes both the polymorphic base-class accessors and chip-specific module references.

Capabilities:

  • Charger (PmicSupportCharger)
  • Power management (PmicSupportPower)
  • ADC (PmicSupportAdc)
  • Interrupt controller (PmicSupportIrq)
  • Power button (PmicSupportPowerBtn)
  • Power output channels (PmicSupportChannel)

Definition at line 71 of file PmicAXP2101.hpp.

Member Typedef Documentation

◆ Module

Definition at line 74 of file PmicAXP2101.hpp.

Constructor & Destructor Documentation

◆ PmicAXP2101()

PmicAXP2101::PmicAXP2101 ( )
inline

Construct the AXP2101 PMIC interface, initialising all sub-modules.

Definition at line 79 of file PmicAXP2101.hpp.

Member Function Documentation

◆ adc()

AXP2101Adc & PmicAXP2101::adc ( )
inline

Get the chip-specific ADC interface.

Returns
Reference to AXP2101Adc.

Definition at line 301 of file PmicAXP2101.hpp.

Referenced by loop(), and setup().

◆ begin()

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

Initialise the AXP2101 with custom communication callbacks.

Parameters
callbackCustom I2C callback.
hal_cbCustom HAL callback.
addrI2C slave address.
Returns
true on success.

Implements PmicBase.

Definition at line 133 of file PmicAXP2101.hpp.

References I2CDeviceWithHal::begin().

Referenced by setup().

◆ charger()

AXP2101Charger & PmicAXP2101::charger ( )
inline

Get the chip-specific charger interface.

Returns
Reference to AXP2101Charger.

Definition at line 265 of file PmicAXP2101.hpp.

◆ core()

AXP2101Core & PmicAXP2101::core ( )
inline

Get the core I2C communication interface.

Returns
Reference to AXP2101Core.

Definition at line 310 of file PmicAXP2101.hpp.

◆ enableModule()

bool PmicAXP2101::enableModule ( Module  module,
bool  enable 
)
inline

Enable or disable an internal functional module.

Convenience wrapper for AXP2101Core::enableModule().

Parameters
moduleModule identifier.
enabletrue to enable, false to disable.
Returns
true on success.

Definition at line 335 of file PmicAXP2101.hpp.

References AXP2101Core::enableModule().

Referenced by setup().

◆ end()

void PmicAXP2101::end ( )
inlinevirtual

De-initialise the PMIC (no-op for AXP2101).

Implements PmicBase.

Definition at line 143 of file PmicAXP2101.hpp.

◆ getAdc()

PmicAdcBase & PmicAXP2101::getAdc ( )
inlineoverridevirtual

Get the ADC interface.

Returns
Reference to AXP2101Adc.

Implements PmicBase.

Definition at line 213 of file PmicAXP2101.hpp.

◆ getCapabilities()

PmicCapability::Capability PmicAXP2101::getCapabilities ( ) const
inlineoverridevirtual

◆ getChannel()

PmicChannelBase * PmicAXP2101::getChannel ( )
inlineoverridevirtual

Get the power output channel interface.

Returns
Pointer to AXP2101Channel, nullptr if not supported.

Reimplemented from PmicBase.

Definition at line 231 of file PmicAXP2101.hpp.

Referenced by setup().

◆ getCharger()

PmicChargerBase * PmicAXP2101::getCharger ( )
inlineoverridevirtual

Get the charger interface (pointer for optional support).

Returns
Pointer to AXP2101Charger, or nullptr if not available.

Reimplemented from PmicBase.

Definition at line 204 of file PmicAXP2101.hpp.

Referenced by loop(), and setup().

◆ getChipID()

uint8_t PmicAXP2101::getChipID ( )
inline

Read the AXP2101 chip ID / version register.

Returns
Chip ID byte, or 0 on error.

Definition at line 399 of file PmicAXP2101.hpp.

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

Referenced by setup().

◆ getChipName()

const char * PmicAXP2101::getChipName ( ) const
inlineoverridevirtual

Get the human-readable chip name.

Returns
String "AXP2101".

Implements PmicBase.

Definition at line 245 of file PmicAXP2101.hpp.

◆ getConfig()

const PmicConfig & PmicAXP2101::getConfig ( ) const
inlineoverridevirtual

◆ getIrq()

PmicIrqBase * PmicAXP2101::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 236 of file PmicAXP2101.hpp.

◆ getLed()

PmicLedBase & PmicAXP2101::getLed ( )
inlineoverridevirtual

Get the LED interface.

Returns
Reference to AXP2101Led.

Implements PmicBase.

Definition at line 222 of file PmicAXP2101.hpp.

◆ getPower()

PmicPowerBase & PmicAXP2101::getPower ( )
inlineoverridevirtual

Get the power management interface.

Returns
Reference to AXP2101Power.

Implements PmicBase.

Definition at line 195 of file PmicAXP2101.hpp.

◆ getStatus()

uint16_t PmicAXP2101::getStatus ( )
inline

Read the combined STATUS1 and STATUS2 registers.

Returns
16-bit status word (high byte = STATUS1, low byte = STATUS2). Returns 0 on I2C error.

Definition at line 360 of file PmicAXP2101.hpp.

References SensorCommWrapper::readReg(), axp2101_regs::bmu::STATUS1, and axp2101_regs::bmu::STATUS2.

◆ irq()

AXP2101Irq & PmicAXP2101::irq ( )
inline

Get the chip-specific IRQ controller.

Returns
Reference to AXP2101Irq.

Definition at line 256 of file PmicAXP2101.hpp.

Referenced by loop(), and setup().

◆ isBatteryConnect()

bool PmicAXP2101::isBatteryConnect ( )
inline

Check if a battery is connected.

Returns
true if battery is detected.

Definition at line 381 of file PmicAXP2101.hpp.

References SensorCommWrapper::getRegBit(), and axp2101_regs::bmu::STATUS1.

Referenced by loop().

◆ isCharging()

bool PmicAXP2101::isCharging ( )
inline

Check if the battery is currently charging.

Returns
true if charging.

Definition at line 390 of file PmicAXP2101.hpp.

References AXP2101Charger::isCharging().

◆ isModuleEnabled()

bool PmicAXP2101::isModuleEnabled ( Module  module)
inline

Check whether an internal module is enabled.

Convenience wrapper for AXP2101Core::isModuleEnabled().

Parameters
moduleModule identifier.
Returns
true if the module is enabled.

Definition at line 348 of file PmicAXP2101.hpp.

References AXP2101Core::isModuleEnabled().

◆ isVbusGood()

bool PmicAXP2101::isVbusGood ( )
inline

Check if a valid VBUS power source is present.

Returns
true if VBUS is good.

Definition at line 372 of file PmicAXP2101.hpp.

References SensorCommWrapper::getRegBit(), and axp2101_regs::bmu::STATUS1.

Referenced by loop().

◆ led()

AXP2101Led & PmicAXP2101::led ( )
inline

Get the chip-specific LED module.

Returns
Reference to AXP2101Led.

Definition at line 274 of file PmicAXP2101.hpp.

Referenced by loop().

◆ power()

AXP2101Power & PmicAXP2101::power ( )
inline

Get the chip-specific power management interface.

Returns
Reference to AXP2101Power.

Definition at line 319 of file PmicAXP2101.hpp.

◆ pwron()

AXP2101Pwron & PmicAXP2101::pwron ( )
inline

Get the chip-specific power button interface.

Returns
Reference to AXP2101Pwron.

Definition at line 283 of file PmicAXP2101.hpp.

Referenced by setup().

◆ reset()

void PmicAXP2101::reset ( )
inline

Reset (restart) the SoC system.

Definition at line 417 of file PmicAXP2101.hpp.

References AXP2101Power::resetSoC().

◆ shutdown()

void PmicAXP2101::shutdown ( )
inline

Soft power-off the PMIC.

Definition at line 409 of file PmicAXP2101.hpp.

References AXP2101Power::softShutdown().

◆ watchdog()

AXP2101Watchdog & PmicAXP2101::watchdog ( )
inline

Get the chip-specific watchdog interface.

Returns
Reference to AXP2101Watchdog.

Definition at line 292 of file PmicAXP2101.hpp.


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