|
SensorLib 0.5.0
Multi-platform sensor driver library for Arduino, PlatformIO, and ESP-IDF
|
#include <BQ25896Adc.hpp>
Public Member Functions | |
| BQ25896Adc (BQ25896Core &core) | |
| Construct ADC interface. | |
| ~BQ25896Adc ()=default | |
| bool | enableChannels (uint32_t mask) override |
| Enable one or more ADC channels. | |
| bool | disableChannels (uint32_t mask) override |
| Disable ADC channels (no-op for BQ25896) | |
| bool | read (Channel ch, float &out) override |
| Read ADC value for specified channel. | |
| bool | startConversion () |
| Start a single ADC conversion. | |
| bool | setContinuousMode (bool enable) |
| Enable or disable continuous ADC mode. | |
| bool | enableChannels (Channel mask) |
| Enable ADC channels (no-op for BQ25896) | |
| virtual bool | enableChannels (uint32_t mask)=0 |
| Enable ADC channels (no-op for BQ25896) | |
| 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_CONV_START = 0x80 |
| ADC control flags. | |
| static constexpr uint8_t | ADC_CONV_RATE = 0x40 |
| Enable continuous conversion mode (1Hz) | |
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. | |
Definition at line 82 of file BQ25896Adc.hpp.
|
explicit |
Construct ADC interface.
| core | Reference to BQ25896 core communication |
Definition at line 38 of file BQ25896Adc.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 ADC channels (no-op for BQ25896)
| mask | Channel mask (ignored) |
Implements PmicAdcBase.
Definition at line 46 of file BQ25896Adc.cpp.
|
virtual |
Disable one or more ADC channels.
| mask | Bitmask of channels to disable. |
Implements PmicAdcBase.
|
inline |
Enable ADC channels (no-op for BQ25896)
The BQ25896 has no per-channel enable control. All ADC channels are always available. Use startConversion() or setContinuousMode() to control ADC operation.
| mask | Channel mask (ignored) |
Definition at line 84 of file PmicAdcBase.hpp.
|
overridevirtual |
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.
Definition at line 40 of file BQ25896Adc.cpp.
Referenced by setup().
|
virtual |
Enable ADC channels (no-op for BQ25896)
The BQ25896 has no per-channel enable control. All ADC channels are always available. Use startConversion() or setContinuousMode() to control ADC operation.
| mask | Channel mask (ignored) |
Implements PmicAdcBase.
|
overridevirtual |
Read ADC value for specified channel.
Reads the raw ADC value from the appropriate register and converts it to the physical value using the step values defined in BQ25896Regs.hpp.
| ch | ADC channel to read |
| out | Reference to store the converted value
|
Implements PmicAdcBase.
Definition at line 52 of file BQ25896Adc.cpp.
References PmicAdcBase::BAT_CURRENT, PmicAdcBase::BAT_PERCENTAGE, PmicAdcBase::BAT_TEMPERATURE, PmicAdcBase::BAT_VOLTAGE, PmicAdcBase::DIE_TEMPERATURE, BQ25896Core::isCharging(), BQ25896Core::isVbusPresent(), SensorCommWrapper::readReg(), startConversion(), PmicAdcBase::VBUS_CURRENT, PmicAdcBase::VBUS_VOLTAGE, and PmicAdcBase::VSYS_VOLTAGE.
Referenced by loop().
| bool BQ25896Adc::setContinuousMode | ( | bool | enable | ) |
Enable or disable continuous ADC mode.
In continuous mode, the ADC performs conversions automatically at 1Hz. This is useful for real-time monitoring applications where you need the latest values available immediately when calling read().
| enable | true to enable continuous mode, false for one-shot mode |
Definition at line 130 of file BQ25896Adc.cpp.
References SensorCommWrapper::updateBits().
| bool BQ25896Adc::startConversion | ( | ) |
Start a single ADC conversion.
Sets the CONV_START bit to trigger a one-shot ADC conversion. This is automatically called by read() if needed, but can be called explicitly to pre-trigger conversion before reading multiple values.
Definition at line 125 of file BQ25896Adc.cpp.
References SensorCommWrapper::updateBits().
Referenced by read().
|
staticconstexpr |
Enable continuous conversion mode (1Hz)
Definition at line 90 of file BQ25896Adc.hpp.
|
staticconstexpr |
ADC control flags.
Start ADC conversion
Definition at line 89 of file BQ25896Adc.hpp.
Referenced by setup().