SensorLib 0.5.0
Multi-platform sensor driver library for Arduino, PlatformIO, and ESP-IDF
Loading...
Searching...
No Matches
axp1xx::AXP1xxAdc< CoreType, RegTraits > Class Template Reference

Generic ADC implementation for AXP1xx-based PMICs. More...

#include <AXP1xxAdc.hpp>

Inheritance diagram for axp1xx::AXP1xxAdc< CoreType, RegTraits >:
[legend]

Public Member Functions

 AXP1xxAdc (CoreType &core)
 Construct ADC interface.
 
 ~AXP1xxAdc ()=default
 
bool enableChannels (uint32_t mask) override
 Enable one or more ADC channels.
 
bool disableChannels (uint32_t mask) override
 Disable one or more ADC channels.
 
bool read (Channel ch, float &out) override
 Read a single ADC channel value.
 
bool enableChannels (Channel mask)
 Enable one or more ADC channels by Channel enum.
 
virtual bool enableChannels (uint32_t mask)=0
 Enable one or more ADC channels.
 
bool disableChannels (Channel mask)
 Disable one or more ADC channels by Channel enum.
 
virtual bool disableChannels (uint32_t mask)=0
 Disable one or more ADC channels.
 
- Public Member Functions inherited from PmicAdcBase
virtual ~PmicAdcBase ()=default
 
bool enableChannels (Channel mask)
 Enable one or more ADC channels by Channel enum.
 
bool disableChannels (Channel mask)
 Disable one or more ADC channels by Channel enum.
 

Protected Attributes

CoreType & _core
 Reference to I2C communication core.
 

Additional Inherited Members

- Public Types inherited from PmicAdcBase
enum class  Channel : uint16_t {
  VBUS_VOLTAGE = (1 << 0) , VBUS_CURRENT = (1 << 1) , BAT_VOLTAGE = (1 << 2) , BAT_CURRENT = (1 << 3) ,
  VSYS_VOLTAGE = (1 << 4) , DIE_TEMPERATURE = (1 << 5) , BAT_TEMPERATURE = (1 << 6) , BAT_PERCENTAGE = (1 << 7) ,
  ACIN_VOLTAGE = (1 << 8) , ACIN_CURRENT = (1 << 9)
}
 ADC channel bitmask. More...
 
- Static Protected Member Functions inherited from PmicAdcBase
template<typename Func >
static void forEachChannel (uint32_t mask, Func fn)
 Helper to iterate over set bits in a bitmask.
 

Detailed Description

template<typename CoreType, typename RegTraits>
class axp1xx::AXP1xxAdc< CoreType, RegTraits >

Generic ADC implementation for AXP1xx-based PMICs.

Provides common ADC functionality with chip-specific behavior delegated to a RegTraits template parameter. This eliminates code duplication while maintaining full API compatibility with PmicAdcBase.

Template Parameters
CoreTypeI2C communication core (must have readReg/writeReg/readRegBuff methods)
RegTraitsChip-specific register and conversion factor configuration

Definition at line 51 of file AXP1xxAdc.hpp.

Constructor & Destructor Documentation

◆ AXP1xxAdc()

template<typename CoreType , typename RegTraits >
axp1xx::AXP1xxAdc< CoreType, RegTraits >::AXP1xxAdc ( CoreType &  core)
inlineexplicit

Construct ADC interface.

Parameters
coreReference to the I2C communication core

Definition at line 58 of file AXP1xxAdc.hpp.

◆ ~AXP1xxAdc()

template<typename CoreType , typename RegTraits >
axp1xx::AXP1xxAdc< CoreType, RegTraits >::~AXP1xxAdc ( )
default

Member Function Documentation

◆ disableChannels() [1/3]

template<typename CoreType , typename RegTraits >
bool PmicAdcBase::disableChannels ( Channel  mask)
inline

Disable one or more ADC channels by Channel enum.

Parameters
maskBitwise OR of Channel values to disable.
Returns
True on success, false on failure.

Definition at line 94 of file PmicAdcBase.hpp.

◆ disableChannels() [2/3]

template<typename CoreType , typename RegTraits >
bool axp1xx::AXP1xxAdc< CoreType, RegTraits >::disableChannels ( uint32_t  mask)
overridevirtual

Disable one or more ADC channels.

Parameters
maskBitwise OR of Channel values or chip-specific mask constants
Returns
true on success, false if channel not supported or I2C error

Implements PmicAdcBase.

Definition at line 89 of file AXP1xxAdc_impl.hpp.

◆ disableChannels() [3/3]

template<typename CoreType , typename RegTraits >
virtual bool PmicAdcBase::disableChannels ( uint32_t  mask)
virtual

Disable one or more ADC channels.

Parameters
maskBitmask of channels to disable.
Returns
True on success, false on failure.

Implements PmicAdcBase.

◆ enableChannels() [1/3]

template<typename CoreType , typename RegTraits >
bool PmicAdcBase::enableChannels ( Channel  mask)
inline

Enable one or more ADC channels by Channel enum.

Convenience overload that accepts Channel values directly without explicit cast. Delegates to enableChannels(uint32_t).

Parameters
maskBitwise OR of Channel values to enable.
Returns
True on success, false on failure.

Definition at line 84 of file PmicAdcBase.hpp.

◆ enableChannels() [2/3]

template<typename CoreType , typename RegTraits >
bool axp1xx::AXP1xxAdc< CoreType, RegTraits >::enableChannels ( uint32_t  mask)
overridevirtual

Enable one or more ADC channels.

Maps each Channel bit to chip-specific enable mask via RegTraits, then sets the appropriate bits in ADC enable registers. Supports single or combined channels: adc.enableChannels(Channel::BAT_VOLTAGE | Channel::VBUS_VOLTAGE);

Parameters
maskBitwise OR of Channel values or chip-specific mask constants
Returns
true on success, false if channel not supported or I2C error

Implements PmicAdcBase.

Definition at line 38 of file AXP1xxAdc_impl.hpp.

Referenced by setup().

◆ enableChannels() [3/3]

template<typename CoreType , typename RegTraits >
virtual bool PmicAdcBase::enableChannels ( uint32_t  mask)
virtual

Enable one or more ADC channels.

Accepts Channel bitmask values. Common channels (Channel::XXX) can be combined with bitwise OR. Subclasses may also accept chip-specific mask values for channels not in the Channel enum.

Parameters
maskBitmask of channels to enable.
Returns
True on success, false on failure.

Implements PmicAdcBase.

◆ read()

template<typename CoreType , typename RegTraits >
bool axp1xx::AXP1xxAdc< CoreType, RegTraits >::read ( PmicAdcBase::Channel  ch,
float &  out 
)
overridevirtual

Read a single ADC channel value.

Reads the raw ADC data from registers and converts to physical units (mV for voltage, mA for current, degC for temperature). Implements device-state checks (e.g., VBUS present) to return 0 when appropriate.

Parameters
chThe channel to read (from PmicAdcBase::Channel enum)
[out]outOutput value in physical units
Returns
true on success, false on read error

Implements PmicAdcBase.

Definition at line 156 of file AXP1xxAdc_impl.hpp.

Member Data Documentation

◆ _core

template<typename CoreType , typename RegTraits >
CoreType& axp1xx::AXP1xxAdc< CoreType, RegTraits >::_core
protected

Reference to I2C communication core.

Definition at line 101 of file AXP1xxAdc.hpp.


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