53#include "../../../SensorBuildOpt.h"
54#if !SENSORLIB_EXCLUDE_PMIC_AXP202
56#include "../../PmicBase.hpp"
57#include "../../PmicAdcBase.hpp"
58#include "../../PmicIrqBase.hpp"
66#include "../axp1xx/AXP1xxIrq.hpp"
67#include "../axp1xx/AXP1xxCharger.hpp"
71#include "../axp1xx/AXP1xxPower.hpp"
72#include "../axp1xx/AXP1xxPwron.hpp"
73#include "../axp1xx/AXP1xxTimer.hpp"
74#include "../axp1xx/AXP1xxLed.hpp"
76static constexpr uint8_t AXP202_SLAVE_ADDRESS = 0x35;
91 , _irq(_core), _charger(_core)
96 , _gpio(_core), _channel(_core)
97 , _powerEx(_core), _chargerEx(_core), _coulomb(_core)
109 bool begin(TwoWire &wire, uint8_t addr,
int sda = -1,
int scl = -1)
111 return _core.
begin(wire, addr, sda, scl);
113#elif defined(ESP_PLATFORM)
114#if defined(SENSORLIB_USE_I2C_LEGACY)
123 bool begin(i2c_port_t port_num, uint8_t addr,
int sda = -1,
int scl = -1)
125 return _core.
begin(port_num, addr, sda, scl);
134 bool begin(i2c_master_bus_handle_t handle, uint8_t addr)
136 return _core.
begin(handle, addr);
152 return _core.
begin(callback, hal_cb, addr);
200 .chargeCurrentMin = 300,
201 .chargeCurrentMax = 1800,
202 .chargeCurrentStep = 100,
203 .chargeCurrentSteps = 16,
381 if (s0 < 0 || s1 < 0)
return 0;
382 return (
static_cast<uint16_t
>(s0) << 8) |
static_cast<uint16_t
>(s1);
419 if (
id < 0)
return 0;
420 return static_cast<uint8_t
>(id);
AXP202 Coulomb counter for battery charge/discharge measurement.
AXP202-specific power management extensions.
bool isCharging() override
Check whether the battery is currently charging.
AXP202 ADC channel control and data readout (template wrapper)
AXP202 power channel enable and voltage control.
bool begin(SensorCommCustom::CustomCallback cb, SensorCommCustomHal::CustomHalCallback hal_cb, uint8_t addr)
Initialize the sensor using custom callback interface.
Unified AXP202 PMIC driver.
bool isBatteryConnect()
Check if a battery is connected.
AXP1xxPwron< axp202_regs > & pwron()
Access the power-button timing/control interface.
AXP202Gpio & gpio()
Access the GPIO interface.
PmicGpioBase * getGpio() override
Get GPIO interface.
AXP202Adc & adc()
Access the ADC interface (chip-specific)
void end()
De-initialise the PMIC (no-op)
uint8_t getChipID()
Read the AXP202 chip ID register.
bool isVbusGood()
Check if VBUS is present and valid.
AXP1xxIrq< axp202_regs > & irq()
Access the IRQ (interrupt) interface.
AXP1xxCharger< axp202_regs > & charger()
Access the charger interface (chip-specific)
void shutdown()
Power off the PMIC (shutdown)
AXP1xxTimer< axp202_regs > & timer()
Access the countdown timer subsystem.
PmicChannelBase * getChannel() override
Access the power channel control interface.
PmicAXP202()
Construct the AXP202 driver with all sub-modules.
PmicChargerBase * getCharger() override
Access the charger interface.
AXP202Coulomb & coulomb()
Access coulomb counter for charge/discharge energy measurement.
PmicIrqBase * getIrq() override
Get interrupt interface.
const PmicConfig & getConfig() const override
Get the PMIC configuration descriptor.
uint16_t getStatus()
Read combined STATUS and MODE_CHGSTATUS registers.
bool enableSleep(bool en)
Enable or disable sleep mode.
AXP202ChargerEx & chargerEx()
Access AXP202-specific charger extensions (thermal, backup, timeout)
const char * getChipName() const override
Get the chip name string.
bool isCharging()
Check if the battery is currently charging.
PmicAdcBase & getAdc() override
Access the ADC interface.
AXP1xxLed< axp202_regs > & led()
PmicCapability::Capability getCapabilities() const override
Get the PMIC capability flags.
bool begin(SensorCommCustom::CustomCallback callback, SensorCommCustomHal::CustomHalCallback hal_cb, uint8_t addr)
Initialise the PMIC using custom communication callbacks.
AXP202PowerEx & power()
Access AXP202-specific power extensions (DCDC mode, APS warning)
AXP202Core & core()
Access the core communication interface.
PmicLedBase & getLed() override
Access the LED control interface.
PmicPowerBase & getPower() override
Access the power management 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 clrRegBit(uint8_t reg, uint8_t bit)
bool getRegBit(uint8_t reg, uint8_t bit)
int readReg(uint8_t reg) const
bool setRegBit(uint8_t reg, uint8_t bit)
@ PmicSupportCharger
Battery charger support.
@ PmicSupportGpio
General purpose I/O 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 STATUS
static constexpr uint8_t IC_TYPE
static constexpr uint8_t MODE_CHGSTATUS
static constexpr uint8_t VOFF_SET
static constexpr uint8_t OFF_CTL