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

AXP517 low-level core driver. More...

#include <AXP517Core.hpp>

Inheritance diagram for AXP517Core:
[legend]

Public Types

enum class  Module : uint8_t {
  BC12 , TYPEC , GAUGE , WATCHDOG ,
  GAUGE_LOW_POWER , BOOST , BUCK , CHGLED ,
  CHARGE , MPPT
}
 Functional module switches exposed by AXP517. More...
 

Public Member Functions

 AXP517Core ()=default
 Construct an uninitialized AXP517 core object.
 
 ~AXP517Core ()=default
 
bool enableModule (Module module, bool enable)
 Enable or disable a module.
 
bool isModuleEnabled (Module module)
 Check if a module is enabled.
 
uint32_t millis ()
 Return the current platform millisecond counter.
 
void delayMs (uint32_t ms)
 Delay using the active platform HAL.
 
void pinMode (uint8_t pin, uint8_t mode)
 Configure a platform GPIO pin through the active HAL.
 
uint8_t digitalRead (uint8_t pin)
 Read a platform GPIO pin through the active HAL.
 
- 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

AXP517 low-level core driver.

This class owns the shared I2C/HAL transport, performs chip and TCPC vendor identification during initialization, and exposes common module enable controls used by the feature-specific AXP517 drivers.

Definition at line 42 of file AXP517Core.hpp.

Member Enumeration Documentation

◆ Module

enum class AXP517Core::Module : uint8_t
strong

Functional module switches exposed by AXP517.

Enumerator
BC12 

Module enable control 0 (REG 0BH).

REG 0BH bit 4 BC1.2

TYPEC 

REG 0BH bit 3 Type-C.

GAUGE 

REG 0BH bit 2 Fuel gauge.

WATCHDOG 

REG 0BH bit 0 Watchdog CLK and REG 19H bit 0 Watchdog Module enable.

GAUGE_LOW_POWER 

Module enable control 1 (REG 19H).

REG 19H bit 6 Low power mode

BOOST 

REG 19H bit 4 Boost converter.

BUCK 

REG 19H bit 3 Buck converter.

CHGLED 

REG 19H bit 2 Charge LED.

CHARGE 

REG 19H bit 1 Charger.

MPPT 

REG 22H bit 0 MPPT configure.

Definition at line 55 of file AXP517Core.hpp.

Constructor & Destructor Documentation

◆ AXP517Core()

AXP517Core::AXP517Core ( )
default

Construct an uninitialized AXP517 core object.

◆ ~AXP517Core()

AXP517Core::~AXP517Core ( )
default

Member Function Documentation

◆ delayMs()

void AXP517Core::delayMs ( uint32_t  ms)
inline

Delay using the active platform HAL.

Parameters
msDelay duration in milliseconds.

Definition at line 104 of file AXP517Core.hpp.

References DeviceBeginCommon::hal.

Referenced by AXP517Tcpc::delayMs(), and AXP517Tcpc::init().

◆ digitalRead()

uint8_t AXP517Core::digitalRead ( uint8_t  pin)
inline

Read a platform GPIO pin through the active HAL.

Parameters
pinPlatform GPIO number.
Returns
Pin logic level, or 1 if no HAL is attached.

Definition at line 128 of file AXP517Core.hpp.

References DeviceBeginCommon::hal.

Referenced by AXP517Tcpc::digitalRead().

◆ enableModule()

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

Enable or disable a module.

Note
The master switch for each functional module (e.g. boost, buck, charger, LED, BC1.2, TCPC, gauge, watchdog, etc.).
Parameters
moduleThe module to enable/disable.
enabletrue to enable, false to disable.
Return values
trueon success, false on register access failure.

Definition at line 44 of file AXP517Core.cpp.

References BC12, BOOST, BUCK, CHARGE, CHGLED, SensorCommWrapper::clrRegBit(), GAUGE, GAUGE_LOW_POWER, axp517_regs::bmu::MODULE_EN0, axp517_regs::ctrl::MODULE_EN1, MPPT, axp517_regs::ctrl::MPPT_CFG, SensorCommWrapper::setRegBit(), TYPEC, and WATCHDOG.

Referenced by PmicAXP517::enableModule(), and AXP517Tcpc::init().

◆ isModuleEnabled()

bool AXP517Core::isModuleEnabled ( Module  module)

Check if a module is enabled.

Note
This function checks the status of a specific functional module.
Parameters
moduleThe module to check.
Return values
trueif the module is enabled, false otherwise.

Definition at line 71 of file AXP517Core.cpp.

References BC12, BOOST, BUCK, CHARGE, CHGLED, GAUGE, GAUGE_LOW_POWER, SensorCommWrapper::getRegBit(), axp517_regs::bmu::MODULE_EN0, axp517_regs::ctrl::MODULE_EN1, MPPT, axp517_regs::ctrl::MPPT_CFG, SensorCommWrapper::readReg(), TYPEC, and WATCHDOG.

Referenced by PmicAXP517::isModuleEnabled().

◆ millis()

uint32_t AXP517Core::millis ( )
inline

Return the current platform millisecond counter.

Returns
Milliseconds from the active HAL, or 0 when no HAL is attached.

Definition at line 95 of file AXP517Core.hpp.

References DeviceBeginCommon::hal.

Referenced by AXP517Tcpc::millis().

◆ pinMode()

void AXP517Core::pinMode ( uint8_t  pin,
uint8_t  mode 
)
inline

Configure a platform GPIO pin through the active HAL.

Parameters
pinPlatform GPIO number.
modePlatform-specific pin mode value.

Definition at line 116 of file AXP517Core.hpp.

References DeviceBeginCommon::hal.

Referenced by AXP517Tcpc::pinMode().


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