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

AXP517 ADC driver. More...

#include <AXP517Adc.hpp>

Inheritance diagram for AXP517Adc:
[legend]

Public Member Functions

 AXP517Adc (AXP517Core &core)
 Construct an AXP517 ADC driver.
 
 ~AXP517Adc ()=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 an ADC channel.
 
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.
 

Static Public Attributes

static constexpr uint8_t ADC_VBUS_CURRENT_HW = 0x80
 Hardware ADC enable bit for VBUS current.
 
static constexpr uint8_t ADC_BAT_DISCHARGE_HW = 0x40
 Hardware ADC enable bit for battery discharge current.
 
static constexpr uint8_t ADC_BAT_CHARGE_HW = 0x20
 Hardware ADC enable bit for battery charge current.
 
static constexpr uint8_t ADC_DIE_TEMP_HW = 0x10
 Hardware ADC enable bit for die temperature.
 
static constexpr uint8_t ADC_SYSTEM_VOLTAGE_HW = 0x08
 Hardware ADC enable bit for system voltage.
 
static constexpr uint8_t ADC_VBUS_VOLTAGE_HW = 0x04
 Hardware ADC enable bit for VBUS voltage.
 
static constexpr uint8_t ADC_TS_PIN_HW = 0x02
 Hardware ADC enable bit for TS pin voltage.
 
static constexpr uint8_t ADC_BAT_VOLTAGE_HW = 0x01
 Hardware ADC enable bit for battery voltage.
 

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

AXP517 ADC driver.

Provides PMIC ADC channel enable/disable control and converts raw AXP517 ADC readings into millivolts, milliamps, or degrees Celsius according to the selected PmicAdcBase::Channel.

Definition at line 43 of file AXP517Adc.hpp.

Constructor & Destructor Documentation

◆ AXP517Adc()

AXP517Adc::AXP517Adc ( AXP517Core core)
explicit

Construct an AXP517 ADC driver.

Parameters
coreShared AXP517 register transport.

Definition at line 37 of file AXP517Adc.cpp.

◆ ~AXP517Adc()

AXP517Adc::~AXP517Adc ( )
default

Member Function Documentation

◆ disableChannels() [1/3]

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]

bool AXP517Adc::disableChannels ( uint32_t  mask)
overridevirtual

Disable one or more ADC channels.

Parameters
maskBitwise OR of Channel values to disable.
Return values
trueon success, false on register access failure.

Implements PmicAdcBase.

Definition at line 69 of file AXP517Adc.cpp.

References axp517_regs::adc::ENABLE, PmicAdcBase::forEachChannel(), SensorCommWrapper::readReg(), and SensorCommWrapper::writeReg().

◆ disableChannels() [3/3]

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]

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]

bool AXP517Adc::enableChannels ( uint32_t  mask)
overridevirtual

Enable one or more ADC channels.

Parameters
maskBitwise OR of Channel values to enable.
Return values
trueon success, false on register access failure.

Implements PmicAdcBase.

Definition at line 55 of file AXP517Adc.cpp.

References axp517_regs::adc::ENABLE, PmicAdcBase::forEachChannel(), SensorCommWrapper::readReg(), and SensorCommWrapper::writeReg().

Referenced by setup().

◆ enableChannels() [3/3]

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()

Member Data Documentation

◆ ADC_BAT_CHARGE_HW

constexpr uint8_t AXP517Adc::ADC_BAT_CHARGE_HW = 0x20
staticconstexpr

Hardware ADC enable bit for battery charge current.

Definition at line 53 of file AXP517Adc.hpp.

◆ ADC_BAT_DISCHARGE_HW

constexpr uint8_t AXP517Adc::ADC_BAT_DISCHARGE_HW = 0x40
staticconstexpr

Hardware ADC enable bit for battery discharge current.

Definition at line 50 of file AXP517Adc.hpp.

◆ ADC_BAT_VOLTAGE_HW

constexpr uint8_t AXP517Adc::ADC_BAT_VOLTAGE_HW = 0x01
staticconstexpr

Hardware ADC enable bit for battery voltage.

Definition at line 68 of file AXP517Adc.hpp.

◆ ADC_DIE_TEMP_HW

constexpr uint8_t AXP517Adc::ADC_DIE_TEMP_HW = 0x10
staticconstexpr

Hardware ADC enable bit for die temperature.

Definition at line 56 of file AXP517Adc.hpp.

◆ ADC_SYSTEM_VOLTAGE_HW

constexpr uint8_t AXP517Adc::ADC_SYSTEM_VOLTAGE_HW = 0x08
staticconstexpr

Hardware ADC enable bit for system voltage.

Definition at line 59 of file AXP517Adc.hpp.

◆ ADC_TS_PIN_HW

constexpr uint8_t AXP517Adc::ADC_TS_PIN_HW = 0x02
staticconstexpr

Hardware ADC enable bit for TS pin voltage.

Definition at line 65 of file AXP517Adc.hpp.

◆ ADC_VBUS_CURRENT_HW

constexpr uint8_t AXP517Adc::ADC_VBUS_CURRENT_HW = 0x80
staticconstexpr

Hardware ADC enable bit for VBUS current.

Definition at line 47 of file AXP517Adc.hpp.

◆ ADC_VBUS_VOLTAGE_HW

constexpr uint8_t AXP517Adc::ADC_VBUS_VOLTAGE_HW = 0x04
staticconstexpr

Hardware ADC enable bit for VBUS voltage.

Definition at line 62 of file AXP517Adc.hpp.


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