|
SensorLib 0.5.0
Multi-platform sensor driver library for Arduino, PlatformIO, and ESP-IDF
|
Generic ADC implementation for AXP1xx-based PMICs. More...
#include <AXP1xxAdc.hpp>
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. | |
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.
| CoreType | I2C communication core (must have readReg/writeReg/readRegBuff methods) |
| RegTraits | Chip-specific register and conversion factor configuration |
Definition at line 51 of file AXP1xxAdc.hpp.
|
inlineexplicit |
Construct ADC interface.
| core | Reference to the I2C communication core |
Definition at line 58 of file AXP1xxAdc.hpp.
|
default |
|
inline |
Disable one or more ADC channels by Channel enum.
| mask | Bitwise OR of Channel values to disable. |
Definition at line 94 of file PmicAdcBase.hpp.
|
overridevirtual |
Disable one or more ADC channels.
| mask | Bitwise OR of Channel values or chip-specific mask constants |
Implements PmicAdcBase.
Definition at line 89 of file AXP1xxAdc_impl.hpp.
|
virtual |
Disable one or more ADC channels.
| mask | Bitmask of channels to disable. |
Implements PmicAdcBase.
|
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).
| mask | Bitwise OR of Channel values to enable. |
Definition at line 84 of file PmicAdcBase.hpp.
|
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);
| mask | Bitwise OR of Channel values or chip-specific mask constants |
Implements PmicAdcBase.
Definition at line 38 of file AXP1xxAdc_impl.hpp.
Referenced by setup().
|
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.
| mask | Bitmask of channels to enable. |
Implements PmicAdcBase.
|
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.
| ch | The channel to read (from PmicAdcBase::Channel enum) | |
| [out] | out | Output value in physical units |
Implements PmicAdcBase.
Definition at line 156 of file AXP1xxAdc_impl.hpp.
|
protected |
Reference to I2C communication core.
Definition at line 101 of file AXP1xxAdc.hpp.