33#include "../../../SensorBuildOpt.h"
34#if !SENSORLIB_EXCLUDE_PMIC_AXP517
36#include "../../PmicBase.hpp"
37#include "../../PmicAdcBase.hpp"
38#include "../../PmicIrqBase.hpp"
39#include "../../PmicPowerBase.hpp"
53static constexpr uint8_t AXP517_SLAVE_ADDRESS = 0x34;
71 , _irq(_core), _charger(_core)
72 , _bc12(_core), _led(_core)
73 , _power(_core), _gpio(_core),
74 _bc12_2(_core), _tcpc(_core), _pd(_tcpc),
75 _pdNegotiator(_tcpc, _pd)
88 bool begin(TwoWire &wire, uint8_t addr,
int sda = -1,
int scl = -1)
90 return _core.
begin(wire, addr, sda, scl);
102 bool begin(TwoWire &wire, uint8_t addr,
int sda,
int scl,
int irqPin)
104 if (!_core.
begin(wire, addr, sda, scl))
return false;
105 return configurePdIrqPin(irqPin);
107#elif defined(ESP_PLATFORM)
108#if defined(SENSORLIB_USE_I2C_LEGACY)
118 bool begin(i2c_port_t port_num, uint8_t addr,
int sda = -1,
int scl = -1)
120 return _core.
begin(port_num, addr, sda, scl);
132 bool begin(i2c_port_t port_num, uint8_t addr,
int sda,
int scl,
int irqPin)
134 if (!_core.
begin(port_num, addr, sda, scl))
return false;
135 return configurePdIrqPin(irqPin);
145 bool begin(i2c_master_bus_handle_t handle, uint8_t addr)
147 return _core.
begin(handle, addr);
157 bool begin(i2c_master_bus_handle_t handle, uint8_t addr,
int irqPin)
159 if (!_core.
begin(handle, addr))
return false;
160 return configurePdIrqPin(irqPin);
175 return _core.
begin(callback, hal_cb, addr);
191 if (!_core.
begin(callback, hal_cb, addr))
return false;
192 return configurePdIrqPin(irqPin);
233 .chargeCurrentMin = 0,
234 .chargeCurrentMax = 5120,
235 .chargeCurrentStep = 64,
236 .chargeCurrentSteps = 81,
340 return _pdNegotiator;
346 return _pdNegotiator;
366 return _pdNegotiator.
initSink(irqPin);
377 bool requestPd(uint16_t targetMv, uint32_t timeoutMs = 6000,
382 return _pdNegotiator.
negotiate(req, outCaps, timeoutMs);
438 bool configurePdIrqPin(
int irqPin)
440 if (irqPin < 0)
return true;
AXP517 BC1.2 detection module.
AXP517 battery charger driver.
AXP517 low-level core driver.
bool isModuleEnabled(Module module)
Check if a module is enabled.
bool enableModule(Module module, bool enable)
Enable or disable a module.
Module
Functional module switches exposed by AXP517.
AXP517 GPIO module (REG 0x11).
AXP517 interrupt controller helper.
AXP517 charge LED driver.
Minimal interrupt-driven USB-PD sink negotiation state machine.
bool negotiate(const RequestParams &req, SourceCaps *outCaps=nullptr, uint32_t timeoutMs=6000)
Run a blocking fixed PDO negotiation.
bool setIrqPin(int irqPin)
Configure the PMIC/TCPC IRQ pin used for PD negotiation.
bool initSink(int irqPin)
Initialize the TCPC sink and configure the PD receive path.
USB-PD message builder and FIFO helper for AXP517.
AXP517 power-path driver.
AXP517 Type-C Port Controller helper.
bool begin(SensorCommCustom::CustomCallback cb, SensorCommCustomHal::CustomHalCallback hal_cb, uint8_t addr)
Initialize the sensor using custom callback interface.
High-level driver facade for the X-Powers AXP517 PMIC.
AXP517Power & power()
Access the AXP517 power-path driver.
PmicChargerBase * getCharger() override
Access the generic PMIC charger interface.
bool isModuleEnabled(Module module)
Check if a module is enabled.
AXP517Tcpc & tcpc()
Access the low-level AXP517 TCPC helper.
AXP517Adc & adc()
Access the AXP517 ADC driver.
PmicIrqBase * getIrq() override
Access the generic PMIC IRQ interface.
PmicLedBase & getLed() override
Access the generic PMIC LED interface.
const PmicConfig & getConfig() const override
Return static PMIC configuration metadata.
bool setPdIrqPin(int irqPin)
Configure the IRQ pin required for USB-PD negotiation.
bool begin(SensorCommCustom::CustomCallback callback, SensorCommCustomHal::CustomHalCallback hal_cb, uint8_t addr, int irqPin)
Initialize using custom callbacks and configure the PD IRQ pin.
AXP517Gpio & gpio()
Access the AXP517 GPIO driver.
void end()
Deinitialize the driver.
PmicAdcBase & getAdc() override
Access the generic PMIC ADC interface.
AXP517PdNegotiator & pdNegotiator()
Access the USB-PD sink negotiator.
bool requestPd(uint16_t targetMv, uint32_t timeoutMs=6000, AXP517PdNegotiator::SourceCaps *outCaps=nullptr)
Request a fixed USB-PD voltage from the attached source.
bool enableModule(Module module, bool enable)
Enable or disable a functional module.
AXP517Core & core()
Access the shared low-level AXP517 core.
AXP517Pd & pdProtocol()
Access the low-level USB-PD protocol helper.
AXP517PdNegotiator & pd()
Access the USB-PD sink negotiator.
PmicAXP517()
Construct an uninitialized AXP517 facade.
PmicCapability::Capability getCapabilities() const override
Return the capabilities supported by this driver.
AXP517Bc12 & bc12()
Access the AXP517 BC1.2 driver.
AXP517Charger & charger()
Access the AXP517 charger driver.
AXP517Led & led()
Access the AXP517 LED driver.
const char * getChipName() const override
Return the chip name string.
PmicPowerBase & getPower() override
Access the generic PMIC power-path interface.
PmicGpioBase * getGpio() override
Access the generic PMIC GPIO interface.
bool initPdSink(int irqPin)
Initialize the TCPC and PD sink receive path.
AXP517Bc12 & bc12_2()
Access the secondary BC1.2 driver alias.
bool begin(SensorCommCustom::CustomCallback callback, SensorCommCustomHal::CustomHalCallback hal_cb, uint8_t addr)
Initialization using a custom communication interface.
AXP517Irq & irq()
Access the AXP517 IRQ driver.
PMIC Base Abstract Class.
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
@ 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.
@ PmicSupportLed
LED driver support.
@ PmicSupportTypeC
USB Type-C support.
@ PmicSupportBc12
BC1.2 (USB Battery Charging) support.
Requested sink operating point.
uint16_t targetMv
Optional fixed PDO voltage to select.
Parsed Source_Capabilities message.
PMIC static configuration data.
const char * chipName
e.g. "AXP2101"