57#include "../../../SensorBuildOpt.h"
58#if !SENSORLIB_EXCLUDE_PMIC_AXP192
60#include "../../PmicBase.hpp"
61#include "../../PmicAdcBase.hpp"
62#include "../../PmicIrqBase.hpp"
63#include "../../PmicPowerBase.hpp"
68#include "../axp1xx/AXP1xxIrq.hpp"
69#include "../axp1xx/AXP1xxCharger.hpp"
73#include "../axp1xx/AXP1xxPower.hpp"
74#include "../axp1xx/AXP1xxPwron.hpp"
75#include "../axp1xx/AXP1xxTimer.hpp"
76#include "../axp1xx/AXP1xxLed.hpp"
78static constexpr uint8_t AXP192_SLAVE_ADDRESS = 0x34;
96 , _irq(_core), _charger(_core)
99 , _gpio(_core), _pwron(_core)
113 bool begin(TwoWire &wire, uint8_t addr,
int sda = -1,
int scl = -1)
115 return _core.
begin(wire, addr, sda, scl);
117#elif defined(ESP_PLATFORM)
118#if defined(SENSORLIB_USE_I2C_LEGACY)
127 bool begin(i2c_port_t port_num, uint8_t addr,
int sda = -1,
int scl = -1)
129 return _core.
begin(port_num, addr, sda, scl);
138 bool begin(i2c_master_bus_handle_t handle, uint8_t addr)
140 return _core.
begin(handle, addr);
156 return _core.
begin(callback, hal_cb, addr);
200 .chargeCurrentMin = 100,
201 .chargeCurrentMax = 1320,
202 .chargeCurrentStep = 0,
203 .chargeCurrentSteps = 16,
352 if (s0 < 0 || s1 < 0)
return 0;
353 return (
static_cast<uint16_t
>(s0) << 8) |
static_cast<uint16_t
>(s1);
390 if (
id < 0)
return 0;
391 return static_cast<uint8_t
>(id);
AXP192 ADC Interface (template wrapper)
AXP192 Power Output Channel Control.
bool isCharging() override
Check whether the battery is currently charging.
bool begin(SensorCommCustom::CustomCallback cb, SensorCommCustomHal::CustomHalCallback hal_cb, uint8_t addr)
Initialize the sensor using custom callback interface.
AXP192 PMIC Unified Interface.
AXP1xxCharger< axp192_regs > & charger()
Access the charger subsystem.
const PmicConfig & getConfig() const override
Get PMIC configuration structure.
AXP192Gpio & gpio()
Access the GPIO interface.
bool isVbusGood()
Check if VBUS power is present and good.
PmicLedBase & getLed() override
Access the LED interface.
uint16_t getStatus()
Read combined status registers (STATUS + MODE_CHGSTATUS)
PmicGpioBase * getGpio() override
Get GPIO interface.
void shutdown()
Shut down the AXP192 (soft power-off)
bool begin(SensorCommCustom::CustomCallback callback, SensorCommCustomHal::CustomHalCallback hal_cb, uint8_t addr)
Initialise the AXP192 with custom communication callbacks.
AXP192Core & core()
Access the core communication object.
AXP1xxLed< axp192_regs > & led()
Access the LED module.
PmicCapability::Capability getCapabilities() const override
Get supported capabilities bitmask.
PmicChargerBase * getCharger() override
Access the charger interface.
bool isBatteryConnect()
Check if a battery is connected.
PmicChannelBase * getChannel() override
Access the power channel control interface.
void reset()
Reset the AXP192.
AXP192Adc & adc()
Access the chip-specific ADC interface.
AXP1xxIrq< axp192_regs > & irq()
Access the IRQ subsystem.
bool isCharging()
Check if the battery is currently charging.
AXP1xxPwron< axp192_regs > & pwron()
Access the power-on control subsystem.
PmicAdcBase & getAdc() override
Access the ADC interface.
AXP1xxTimer< axp192_regs > & timer()
Access the countdown timer subsystem.
uint8_t getChipID()
Read the AXP192 chip identification register.
void end()
Deinitialize PMIC and release resources.
const char * getChipName() const override
Get the chip name string.
PmicPowerBase & getPower() override
Access the power management interface.
PmicIrqBase * getIrq() override
Get interrupt 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
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 MODE_CHGSTATUS
static constexpr uint8_t STATUS
static constexpr uint8_t IC_TYPE
static constexpr uint8_t OFF_CTL