|
SensorLib 0.5.0
Multi-platform sensor driver library for Arduino, PlatformIO, and ESP-IDF
|
Base traits class for AXP1xxAdc template specialization. More...
#include <AXP1xxAdcTraits.hpp>
Static Public Member Functions | |
| static uint32_t | getChannelMask (PmicAdcBase::Channel ch) |
| Map a Channel enum to its hardware enable mask. | |
| static bool | hasSpecialEnablement (PmicAdcBase::Channel ch) |
| Check if a channel requires special enablement logic. | |
| static bool | enableSpecialChannel (CoreType &core, PmicAdcBase::Channel ch) |
| Perform special channel enablement. | |
| static bool | disableSpecialChannel (CoreType &core, PmicAdcBase::Channel ch) |
| Perform special channel disablement. | |
| static bool | readChannel (CoreType &core, PmicAdcBase::Channel ch, float &out) |
| Main ADC channel reading implementation. | |
Static Public Attributes | |
| static constexpr uint8_t | ADC_EN1_ADDR = 0x82 |
| ADC_EN1 register address. | |
| static constexpr uint8_t | ADC_EN2_ADDR = 0x83 |
| ADC_EN2 register address. | |
Base traits class for AXP1xxAdc template specialization.
Specializations of this class must provide:
The design uses static polymorphism (templates) rather than virtual functions to avoid vtable overhead and enable compiler optimizations.
| CoreType | The I2C communication core type (unused in base, required for specializations) |
Definition at line 53 of file AXP1xxAdcTraits.hpp.
|
inlinestatic |
Perform special channel disablement.
Called by AXP1xxAdc::disableChannels() for channels where hasSpecialEnablement() returns true.
| core | Reference to I2C communication core |
| ch | The channel to disable |
Definition at line 136 of file AXP1xxAdcTraits.hpp.
|
inlinestatic |
Perform special channel enablement.
Called by AXP1xxAdc::enableChannels() for channels where hasSpecialEnablement() returns true. Implementations should perform chip-specific register writes outside the standard ADC enable procedure.
Default implementation is a no-op.
| core | Reference to I2C communication core |
| ch | The channel to enable |
Definition at line 119 of file AXP1xxAdcTraits.hpp.
|
inlinestatic |
Map a Channel enum to its hardware enable mask.
Returns the bitmask(s) that must be set in the ADC enable registers to activate the given channel. The mask is split into:
| ch | Channel from PmicAdcBase::Channel enum |
Definition at line 83 of file AXP1xxAdcTraits.hpp.
|
inlinestatic |
Check if a channel requires special enablement logic.
Some channels need custom handling outside the standard ADC enable register writes. For example, AXP2101's TS pin requires configuration in a separate TS_PIN_CTRL register.
| ch | The channel to check |
Definition at line 99 of file AXP1xxAdcTraits.hpp.
|
inlinestatic |
Main ADC channel reading implementation.
This is the workhorse method that handles all channel-specific register reads, conversions, and state checks. Must be specialized for each PMIC variant.
Implementations should:
| core | Reference to I2C communication core |
| ch | Channel to read |
| out | Reference to output float |
Definition at line 161 of file AXP1xxAdcTraits.hpp.
|
staticconstexpr |
ADC_EN1 register address.
This is the primary ADC enable register, typically containing channel enable bits for 0-7 (VBUS, VBUS_CUR, APS, TS, BAT, ACIN, etc.)
Definition at line 62 of file AXP1xxAdcTraits.hpp.
|
staticconstexpr |
ADC_EN2 register address.
Optional secondary ADC enable register for additional channels. Set to same value as ADC_EN1_ADDR if not used.
Definition at line 70 of file AXP1xxAdcTraits.hpp.