33#include "../../../SensorBuildOpt.h"
34#if !SENSORLIB_EXCLUDE_PMIC_AXP2101
36#include "../../PmicBase.hpp"
37#include "../../PmicAdcBase.hpp"
38#include "../../PmicIrqBase.hpp"
39#include "../../PmicPowerBase.hpp"
52static constexpr uint8_t AXP2101_SLAVE_ADDRESS = 0x34;
80 , _irq(_core), _charger(_core)
81 , _led(_core), _power(_core)
82 , _pwron(_core), _watchdog(_core), _channel(_core)
94 bool begin(TwoWire &wire, uint8_t addr,
int sda = -1,
int scl = -1)
96 return _core.
begin(wire, addr, sda, scl);
98#elif defined(ESP_PLATFORM)
99#if defined(SENSORLIB_USE_I2C_LEGACY)
108 bool begin(i2c_port_t port_num, uint8_t addr,
int sda = -1,
int scl = -1)
110 return _core.
begin(port_num, addr, sda, scl);
119 bool begin(i2c_master_bus_handle_t handle, uint8_t addr)
121 return _core.
begin(handle, addr);
137 return _core.
begin(callback, hal_cb, addr);
182 .chargeCurrentMin = 0,
183 .chargeCurrentMax = 1000,
184 .chargeCurrentStep = 0,
185 .chargeCurrentSteps = 14,
364 if (s1 < 0 || s2 < 0)
return 0;
365 return (
static_cast<uint16_t
>(s1) << 8) |
static_cast<uint16_t
>(s2);
402 if (
id < 0)
return 0;
403 return static_cast<uint8_t
>(id);
ADC control for the AXP2101 PMIC.
Power output channel (DCDC / LDO) control for the AXP2101 PMIC.
bool isCharging() override
Check if the charger is actively charging.
Core I2C communication layer for the AXP2101 PMIC.
bool isModuleEnabled(Module module)
Check whether an internal module is enabled.
bool enableModule(Module module, bool enable)
Enable or disable an internal functional module.
Module
Identifiers for AXP2101 internal functional modules.
Interrupt controller interface for the AXP2101 PMIC.
Charging indicator LED control for the AXP2101 PMIC.
void softShutdown()
Initiate a soft shutdown (REG 0x10 bit 0).
void resetSoC()
Trigger a system-on-chip reset (REG 0x10 bit 1).
Power-on / power-button timing control for the AXP2101 PMIC.
I2C watchdog timer control for the AXP2101 PMIC.
bool begin(SensorCommCustom::CustomCallback cb, SensorCommCustomHal::CustomHalCallback hal_cb, uint8_t addr)
Initialize the sensor using custom callback interface.
Top-level unified interface for the AXP2101 PMIC.
PmicChannelBase * getChannel() override
Get the power output channel interface.
AXP2101Pwron & pwron()
Get the chip-specific power button interface.
bool isBatteryConnect()
Check if a battery is connected.
const PmicConfig & getConfig() const override
Get the PMIC configuration descriptor.
bool isCharging()
Check if the battery is currently charging.
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).
AXP2101Charger & charger()
Get the chip-specific charger interface.
PmicPowerBase & getPower() override
Get the power management interface.
AXP2101Adc & adc()
Get the chip-specific ADC interface.
void reset()
Reset (restart) the SoC system.
AXP2101Power & power()
Get the chip-specific power management interface.
const char * getChipName() const override
Get the human-readable chip name.
PmicChargerBase * getCharger() override
Get the charger interface (pointer for optional support).
PmicAXP2101()
Construct the AXP2101 PMIC interface, initialising all sub-modules.
bool enableModule(Module module, bool enable)
Enable or disable an internal functional module.
PmicIrqBase * getIrq() override
Get interrupt interface.
PmicAdcBase & getAdc() override
Get the ADC interface.
bool isVbusGood()
Check if a valid VBUS power source is present.
AXP2101Led & led()
Get the chip-specific LED module.
PmicCapability::Capability getCapabilities() const override
Get the supported PMIC capabilities bitmask.
AXP2101Watchdog & watchdog()
Get the chip-specific watchdog interface.
PmicLedBase & getLed() override
Get the LED interface.
void shutdown()
Soft power-off the PMIC.
bool isModuleEnabled(Module module)
Check whether an internal module is enabled.
AXP2101Irq & irq()
Get the chip-specific IRQ controller.
uint16_t getStatus()
Read the combined STATUS1 and STATUS2 registers.
uint8_t getChipID()
Read the AXP2101 chip ID / version register.
AXP2101Core & core()
Get the core I2C communication interface.
PMIC Base Abstract Class.
PMIC power output channel base interface.
PMIC charger capability interface.
uint32_t(*)(Operation op, void *param1, void *param2) CustomHalCallback
bool(*)(uint8_t addr, uint8_t reg, uint8_t *buf, size_t len, bool writeReg, bool isWrite) CustomCallback
bool getRegBit(uint8_t reg, uint8_t bit)
int readReg(uint8_t reg) const
@ PmicSupportCharger
Battery charger support.
@ PmicSupportIrq
Interrupt handling support.
@ PmicSupportPower
Power management (input limits, boost, etc.)
@ PmicSupportAdc
Analog-to-Digital converter for monitoring.
@ PmicSupportChannel
Power output channel control (DCDC/LDO)
@ PmicSupportLed
LED driver support.
@ PmicSupportPowerBtn
Power-on/Power-off control support.
PMIC static configuration data.
const char * chipName
e.g. "AXP2101"
static constexpr uint8_t STATUS2
static constexpr uint8_t IC_TYPE
static constexpr uint8_t STATUS1