|
SensorLib 0.5.0
Multi-platform sensor driver library for Arduino, PlatformIO, and ESP-IDF
|
Core I2C communication layer for the AXP2101 PMIC. More...
#include <AXP2101Core.hpp>
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 SensorCommBase * | getComm () 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< SensorCommBase > | comm |
| std::unique_ptr< SensorHal > | hal |
| std::unique_ptr< SensorCommStatic > | staticComm |
| uint8_t | _addr = 0 |
| uint8_t | _iface = COMM_CUSTOM |
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.
|
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).
Definition at line 53 of file AXP2101Core.hpp.
|
strong |
Watchdog timer configuration options.
Definition at line 68 of file AXP2101Core.hpp.
|
default |
|
default |
| bool AXP2101Core::enableModule | ( | Module | module, |
| bool | enable | ||
| ) |
Enable or disable an internal functional module.
| module | Module identifier. |
| enable | true to enable, false to disable. |
Definition at line 37 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, SensorCommWrapper::clrRegBit(), GAUGE, GENERAL_ADC, axp2101_regs::ctrl::MODULE_EN, SensorCommWrapper::setRegBit(), TEMP_MEASURE, TS_MEASURE, VBUS_MEASURE, VSYS_MEASURE, and WATCHDOG.
Referenced by AXP2101Charger::enableCharging(), PmicAXP2101::enableModule(), and AXP2101Watchdog::enableWatchdog().
| bool AXP2101Core::isModuleEnabled | ( | Module | module | ) |
Check whether an internal module is enabled.
| module | Module identifier. |
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().
| bool AXP2101Core::setWatchdogConfig | ( | WatchdogConfig | config | ) |
Set watchdog timer configuration.
| config | Watchdog configuration. |
Definition at line 97 of file AXP2101Core.cpp.
References SensorCommWrapper::updateBits(), and axp2101_regs::ctrl::WDT_CTRL.