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

Core I2C communication layer for the AXP2101 PMIC. More...

#include <AXP2101Core.hpp>

Inheritance diagram for AXP2101Core:
[legend]

Public Types

enum class  Module : uint8_t {
  CELL_CHARGE , BTN_CHARGE , WATCHDOG , GAUGE ,
  BAT_DETECT , GENERAL_ADC , TEMP_MEASURE , VSYS_MEASURE ,
  VBUS_MEASURE , TS_MEASURE , BAT_VOLT_MEASURE
}
 Identifiers for AXP2101 internal functional modules. More...
 
enum class  WatchdogConfig : uint8_t { TIMEOUT_IRQ_ONLY = 0 , TIMEOUT_IRQ_AND_SYS_RESET , TIMEOUT_IRQ_AND_SYS_RESET_PULLDOWN_PWROK_1S , TIMEOUT_IRQ_AND_SYS_RESET_AFTER_POWEROFF_THEN_POWERON }
 Watchdog timer configuration options. More...
 

Public Member Functions

 AXP2101Core ()=default
 
 ~AXP2101Core ()=default
 
bool enableModule (Module module, bool enable)
 Enable or disable an internal functional module.
 
bool isModuleEnabled (Module module)
 Check whether an internal module is enabled.
 
bool setWatchdogConfig (WatchdogConfig config)
 Set watchdog timer configuration.
 
- Public Member Functions inherited from I2CDeviceWithHal
bool begin (SensorCommCustom::CustomCallback cb, SensorCommCustomHal::CustomHalCallback hal_cb, uint8_t addr)
 Initialize the sensor using custom callback interface.
 
- Public Member Functions inherited from DeviceBeginCommon
virtual ~DeviceBeginCommon ()
 
uint8_t getAddress () const
 
uint8_t getInterface () const
 
- Public Member Functions inherited from SensorCommWrapper
 SensorCommWrapper ()=default
 
int readReg (uint8_t reg) const
 
int readRegBuff (uint8_t reg, uint8_t *buf, size_t len) const
 
int readBuff (uint8_t *buf, size_t len) const
 
int writeReg (uint8_t reg, uint8_t val)
 
int writeRegBuff (uint8_t reg, uint8_t *buf, size_t len)
 
int writeBuff (uint8_t *buf, size_t len)
 
int writeThenRead (const uint8_t *write_buffer, size_t write_len, uint8_t *read_buffer, size_t read_len)
 
bool setRegBit (uint8_t reg, uint8_t bit)
 
bool clrRegBit (uint8_t reg, uint8_t bit)
 
bool getRegBit (uint8_t reg, uint8_t bit)
 
int updateBits (uint8_t reg, uint8_t mask, uint8_t value_shifted)
 
void setAddress (uint8_t address)
 
void setAck (bool enable)
 
- Public Member Functions inherited from SensorCommInterface
virtual ~SensorCommInterface ()=default
 

Additional Inherited Members

- Protected Member Functions inherited from I2CDeviceWithHal
bool ensureValid () const override
 Ensure the communication interface is valid.
 
- Protected Member Functions inherited from DeviceBeginCommon
 DeviceBeginCommon ()=default
 
virtual SensorCommBasegetComm () const override
 
virtual void beforeBegin ()
 
virtual void afterCommReady ()
 
virtual void afterInitSuccess (uint8_t param)
 
virtual void onBeginFail ()
 
bool fail ()
 
void clearCommState ()
 
template<typename CreateComm >
bool beginLifecycle (uint8_t addr, uint8_t iface, uint8_t initParam, CreateComm createComm)
 
- Protected Attributes inherited from DeviceBeginCommon
std::unique_ptr< SensorCommBasecomm
 
std::unique_ptr< SensorHalhal
 
std::unique_ptr< SensorCommStaticstaticComm
 
uint8_t _addr = 0
 
uint8_t _iface = COMM_CUSTOM
 

Detailed Description

Core I2C communication layer for the AXP2101 PMIC.

Provides low-level I2C register access (inherited from I2CDeviceWithHal), chip ID verification, and module enable/disable control for the AXP2101's internal functional blocks.

Definition at line 41 of file AXP2101Core.hpp.

Member Enumeration Documentation

◆ Module

enum class AXP2101Core::Module : uint8_t
strong

Identifiers for AXP2101 internal functional modules.

Each module maps to a specific enable bit in REG 0x18 (MODULE_EN) or REG 0x30 (ADC_CHANNEL_CTRL) or REG 0x68 (BAT_DETECT_CTRL).

Enumerator
CELL_CHARGE 

Cell battery charger (REG 0x18 bit 1)

BTN_CHARGE 

Button/backup battery charger (REG 0x18 bit 2)

WATCHDOG 

Watchdog timer (REG 0x18 bit 0)

GAUGE 

Fuel gauge (REG 0x18 bit 3)

BAT_DETECT 

Battery detection (REG 0x68 bit 0)

GENERAL_ADC 

General-purpose ADC (REG 0x30 bit 5)

TEMP_MEASURE 

Die temperature ADC (REG 0x30 bit 4)

VSYS_MEASURE 

VSYS voltage ADC (REG 0x30 bit 3)

VBUS_MEASURE 

VBUS voltage ADC (REG 0x30 bit 2)

TS_MEASURE 

TS pin ADC (REG 0x30 bit 1)

BAT_VOLT_MEASURE 

Battery voltage ADC (REG 0x30 bit 0)

Definition at line 53 of file AXP2101Core.hpp.

◆ WatchdogConfig

enum class AXP2101Core::WatchdogConfig : uint8_t
strong

Watchdog timer configuration options.

Enumerator
TIMEOUT_IRQ_ONLY 

Trigger IRQ only.

TIMEOUT_IRQ_AND_SYS_RESET 

Trigger IRQ and system reset.

TIMEOUT_IRQ_AND_SYS_RESET_PULLDOWN_PWROK_1S 

Trigger IRQ, system reset, and pull down PWROK after 1s.

TIMEOUT_IRQ_AND_SYS_RESET_AFTER_POWEROFF_THEN_POWERON 

Trigger IRQ, system reset after power off, then power on.

Definition at line 68 of file AXP2101Core.hpp.

Constructor & Destructor Documentation

◆ AXP2101Core()

AXP2101Core::AXP2101Core ( )
default

◆ ~AXP2101Core()

AXP2101Core::~AXP2101Core ( )
default

Member Function Documentation

◆ enableModule()

bool AXP2101Core::enableModule ( Module  module,
bool  enable 
)

◆ isModuleEnabled()

bool AXP2101Core::isModuleEnabled ( Module  module)

Check whether an internal module is enabled.

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

Definition at line 67 of file AXP2101Core.cpp.

References BAT_DETECT, axp2101_regs::chg::BAT_DETECT_CTRL, BAT_VOLT_MEASURE, BTN_CHARGE, CELL_CHARGE, axp2101_regs::adc::CHANNEL_CTRL, GAUGE, GENERAL_ADC, SensorCommWrapper::getRegBit(), axp2101_regs::ctrl::MODULE_EN, TEMP_MEASURE, TS_MEASURE, VBUS_MEASURE, VSYS_MEASURE, and WATCHDOG.

Referenced by PmicAXP2101::isModuleEnabled(), and AXP2101Watchdog::isWatchdogEnabled().

◆ setWatchdogConfig()

bool AXP2101Core::setWatchdogConfig ( WatchdogConfig  config)

Set watchdog timer configuration.

Parameters
configWatchdog configuration.
Returns
true on success or false on failure.

Definition at line 97 of file AXP2101Core.cpp.

References SensorCommWrapper::updateBits(), and axp2101_regs::ctrl::WDT_CTRL.


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