|
SensorLib 0.5.0
Multi-platform sensor driver library for Arduino, PlatformIO, and ESP-IDF
|
AXP517 ADC driver. More...
#include <AXP517Adc.hpp>
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. | |
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.
|
explicit |
Construct an AXP517 ADC driver.
| core | Shared AXP517 register transport. |
Definition at line 37 of file AXP517Adc.cpp.
|
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 to disable. |
| true | on 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().
|
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.
| mask | Bitwise OR of Channel values to enable. |
| true | on 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().
|
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 an ADC channel.
| ch | The ADC channel to read. |
| out | Receives the converted ADC value. |
| true | on success, false on invalid channel or register access failure. |
Implements PmicAdcBase.
Definition at line 83 of file AXP517Adc.cpp.
References axp517_regs::adc::BAT_CURR_H, PmicAdcBase::BAT_CURRENT, axp517_regs::gauge::BAT_PERCENT, PmicAdcBase::BAT_PERCENTAGE, axp517_regs::gauge::BAT_TEMP, PmicAdcBase::BAT_TEMPERATURE, axp517_regs::adc::BAT_VOLT_H, PmicAdcBase::BAT_VOLTAGE, axp517_regs::adc::DATA_H, axp517_regs::adc::DATA_SEL, PmicAdcBase::DIE_TEMPERATURE, axp517_regs::factory::FACTORY_BAT_CURRENT, axp517_regs::factory::FACTORY_VBAT_VOLTAGE, axp517_regs::factory::FACTORY_VBUS_CURRENT, axp517_regs::factory::FACTORY_VBUS_VOLTAGE, axp517_regs::factory::FACTORY_VSYS_VOLTAGE, SensorCommWrapper::readRegBuff(), axp517_regs::bmu::STATUS0, axp517_regs::adc::VBUS_CURR_H, PmicAdcBase::VBUS_CURRENT, axp517_regs::adc::VBUS_VOLT_H, PmicAdcBase::VBUS_VOLTAGE, PmicAdcBase::VSYS_VOLTAGE, and SensorCommWrapper::writeReg().
|
staticconstexpr |
Hardware ADC enable bit for battery charge current.
Definition at line 53 of file AXP517Adc.hpp.
|
staticconstexpr |
Hardware ADC enable bit for battery discharge current.
Definition at line 50 of file AXP517Adc.hpp.
|
staticconstexpr |
Hardware ADC enable bit for battery voltage.
Definition at line 68 of file AXP517Adc.hpp.
|
staticconstexpr |
Hardware ADC enable bit for die temperature.
Definition at line 56 of file AXP517Adc.hpp.
|
staticconstexpr |
Hardware ADC enable bit for system voltage.
Definition at line 59 of file AXP517Adc.hpp.
|
staticconstexpr |
Hardware ADC enable bit for TS pin voltage.
Definition at line 65 of file AXP517Adc.hpp.
|
staticconstexpr |
Hardware ADC enable bit for VBUS current.
Definition at line 47 of file AXP517Adc.hpp.
|
staticconstexpr |
Hardware ADC enable bit for VBUS voltage.
Definition at line 62 of file AXP517Adc.hpp.