|
SensorLib 0.5.0
Multi-platform sensor driver library for Arduino, PlatformIO, and ESP-IDF
|
#include <PmicAdcBase.hpp>
Public Types | |
| 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... | |
Public Member Functions | |
| 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. | |
| virtual bool | enableChannels (uint32_t mask)=0 |
| Enable one or more ADC channels. | |
| virtual bool | disableChannels (uint32_t mask)=0 |
| Disable one or more ADC channels. | |
| virtual bool | read (Channel ch, float &out)=0 |
| Read a single ADC channel value. | |
Static Protected Member Functions | |
| template<typename Func > | |
| static void | forEachChannel (uint32_t mask, Func fn) |
| Helper to iterate over set bits in a bitmask. | |
Definition at line 44 of file PmicAdcBase.hpp.
|
strong |
ADC channel bitmask.
Each common channel occupies a unique bit position so they can be combined with bitwise OR for batch enable/disable operations.
These values are passed directly to enableChannels(uint32_t). Subclasses may define additional chip-specific mask values beyond what is defined here (e.g. GPIO ADC channels).
Definition at line 60 of file PmicAdcBase.hpp.
|
virtualdefault |
|
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.
References disableChannels().
Referenced by disableChannels().
|
pure virtual |
Disable one or more ADC channels.
| mask | Bitmask of channels to disable. |
Implemented in SY6970Adc, BQ25896Adc, axp1xx::AXP1xxAdc< CoreType, RegTraits >, axp1xx::AXP1xxAdc< AXP192Core, axp1xx::AdcTraitsBase< AXP192Core > >, axp1xx::AXP1xxAdc< AXP202Core, axp1xx::AdcTraitsBase< AXP202Core > >, AXP2101Adc, AXP517Adc, SY6970Adc, BQ25896Adc, axp1xx::AXP1xxAdc< CoreType, RegTraits >, axp1xx::AXP1xxAdc< AXP192Core, axp1xx::AdcTraitsBase< AXP192Core > >, axp1xx::AXP1xxAdc< AXP202Core, axp1xx::AdcTraitsBase< AXP202Core > >, AXP2101Adc, and AXP517Adc.
|
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.
References enableChannels().
Referenced by enableChannels().
|
pure 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. |
Implemented in SY6970Adc, BQ25896Adc, axp1xx::AXP1xxAdc< CoreType, RegTraits >, axp1xx::AXP1xxAdc< AXP192Core, axp1xx::AdcTraitsBase< AXP192Core > >, axp1xx::AXP1xxAdc< AXP202Core, axp1xx::AdcTraitsBase< AXP202Core > >, AXP2101Adc, AXP517Adc, SY6970Adc, BQ25896Adc, axp1xx::AXP1xxAdc< CoreType, RegTraits >, axp1xx::AXP1xxAdc< AXP192Core, axp1xx::AdcTraitsBase< AXP192Core > >, axp1xx::AXP1xxAdc< AXP202Core, axp1xx::AdcTraitsBase< AXP202Core > >, AXP2101Adc, and AXP517Adc.
|
inlinestaticprotected |
Helper to iterate over set bits in a bitmask.
Usage in subclass implementations:
| mask | Bitmask to iterate |
| fn | Callback invoked for each set bit |
Definition at line 141 of file PmicAdcBase.hpp.
Referenced by AXP2101Adc::disableChannels(), AXP517Adc::disableChannels(), AXP2101Adc::enableChannels(), and AXP517Adc::enableChannels().
|
pure virtual |
Read a single ADC channel value.
| ch | Single channel to read (must be a single bit, not a combination). |
| out | Output variable for the channel value in physical units. |
Implemented in SY6970Adc, BQ25896Adc, axp1xx::AXP1xxAdc< CoreType, RegTraits >, axp1xx::AXP1xxAdc< AXP192Core, axp1xx::AdcTraitsBase< AXP192Core > >, axp1xx::AXP1xxAdc< AXP202Core, axp1xx::AdcTraitsBase< AXP202Core > >, AXP2101Adc, and AXP517Adc.
Referenced by loop().