|
SensorLib 0.5.0
Multi-platform sensor driver library for Arduino, PlatformIO, and ESP-IDF
|
AXP202 ADC channel control and data readout (template wrapper) More...
#include <AXP202Adc.hpp>
Public Member Functions | |
| AXP202Adc (AXP202Core &core) | |
| Construct AXP202 ADC interface. | |
| ~AXP202Adc ()=default | |
| bool | setADCSampleRate (uint8_t rate) |
| Set ADC sample rate (REG 84H bits 7:6) | |
| uint16_t | getADCSampleRate () |
| Get ADC sample rate in Hz. | |
| bool | setADCInputRange (uint8_t val) |
| Set ADC input range (REG 85H) | |
| uint8_t | getADCInputRange () |
| bool | setADCIrqRisingThreshold (uint8_t val) |
| Set ADC IRQ rising-edge threshold (REG 86H) | |
| uint8_t | getADCIrqRisingThreshold () |
| bool | setADCIrqFallingThreshold (uint8_t val) |
| Set ADC IRQ falling-edge threshold (REG 87H) | |
| uint8_t | getADCIrqFallingThreshold () |
| float | getTsVoltage () |
| Read TS pin voltage in mV (REG 62H/63H, 12-bit H8L4) | |
| float | getGpio0Voltage () |
| Read GPIO0 ADC voltage in mV (REG 64H/65H, 12-bit H8L4) | |
| float | getGpio1Voltage () |
| Read GPIO1 ADC voltage in mV (REG 66H/67H, 12-bit H8L4) | |
| float | getBatteryPower () |
| Read battery instantaneous power (REG 70H-72H, 24-bit) | |
Public Member Functions inherited from axp1xx::AXP1xxAdc< AXP202Core, axp1xx::AdcTraitsBase< AXP202Core > > | |
| AXP1xxAdc (AXP202Core &core) | |
| Construct ADC interface. | |
| ~AXP1xxAdc ()=default | |
| bool | enableChannels (uint32_t mask) override |
| Enable one or more ADC channels. | |
| 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 (uint32_t mask) override |
| Disable 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. | |
| bool | read (Channel ch, float &out) override |
| Read a single ADC channel value. | |
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 uint32_t | ADC_BAT_VOLTAGE_HW = 0x80 |
| static constexpr uint32_t | ADC_BAT_CURRENT_HW = 0x40 |
| static constexpr uint32_t | ADC_ACIN_VOLTAGE_HW = 0x20 |
| static constexpr uint32_t | ADC_ACIN_CURRENT_HW = 0x10 |
| static constexpr uint32_t | ADC_VBUS_VOLTAGE_HW = 0x08 |
| static constexpr uint32_t | ADC_VBUS_CURRENT_HW = 0x04 |
| static constexpr uint32_t | ADC_APS_VOLTAGE_HW = 0x02 |
| static constexpr uint32_t | ADC_TS_PIN_HW = 0x01 |
| static constexpr uint32_t | ADC_TEMPERATURE_HW = 0x8000 |
| static constexpr uint32_t | ADC_GPIO0_HW = 0x0800 |
| static constexpr uint32_t | ADC_GPIO1_HW = 0x0400 |
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. | |
Protected Attributes inherited from axp1xx::AXP1xxAdc< AXP202Core, axp1xx::AdcTraitsBase< AXP202Core > > | |
| AXP202Core & | _core |
| Reference to I2C communication core. | |
AXP202 ADC channel control and data readout (template wrapper)
Instantiates the generic AXP1xxAdc template with AXP202Core and AXP202 traits. Provides the same interface as before while benefiting from reduced code duplication.
Definition at line 52 of file AXP202Adc.hpp.
|
inlineexplicit |
Construct AXP202 ADC interface.
| core | Reference to AXP202 core communication |
Definition at line 72 of file AXP202Adc.hpp.
|
default |
| uint8_t AXP202Adc::getADCInputRange | ( | ) |
Definition at line 64 of file AXP202Adc.cpp.
References axp1xx::AXP1xxAdc< AXP202Core, axp1xx::AdcTraitsBase< AXP202Core > >::_core, axp202_regs::adc::ADC_INPUTRANGE, and SensorCommWrapper::readReg().
| uint8_t AXP202Adc::getADCIrqFallingThreshold | ( | ) |
Definition at line 86 of file AXP202Adc.cpp.
References axp1xx::AXP1xxAdc< AXP202Core, axp1xx::AdcTraitsBase< AXP202Core > >::_core, axp202_regs::adc::ADC_IRQ_FETFSET, and SensorCommWrapper::readReg().
| uint8_t AXP202Adc::getADCIrqRisingThreshold | ( | ) |
Definition at line 75 of file AXP202Adc.cpp.
References axp1xx::AXP1xxAdc< AXP202Core, axp1xx::AdcTraitsBase< AXP202Core > >::_core, axp202_regs::adc::ADC_IRQ_RETFSET, and SensorCommWrapper::readReg().
| uint16_t AXP202Adc::getADCSampleRate | ( | ) |
Get ADC sample rate in Hz.
Definition at line 51 of file AXP202Adc.cpp.
References axp1xx::AXP1xxAdc< AXP202Core, axp1xx::AdcTraitsBase< AXP202Core > >::_core, axp202_regs::adc::ADC_SPEED, and SensorCommWrapper::readReg().
| float AXP202Adc::getBatteryPower | ( | ) |
Read battery instantaneous power (REG 70H-72H, 24-bit)
Definition at line 120 of file AXP202Adc.cpp.
References axp1xx::AXP1xxAdc< AXP202Core, axp1xx::AdcTraitsBase< AXP202Core > >::_core, axp202_regs::adc::BAT_POWER_H, buf, and SensorCommWrapper::readRegBuff().
| float AXP202Adc::getGpio0Voltage | ( | ) |
Read GPIO0 ADC voltage in mV (REG 64H/65H, 12-bit H8L4)
Definition at line 102 of file AXP202Adc.cpp.
References axp202_regs::factory::FACTORY_GPIO_VOLTAGE, axp202_regs::adc::GPIO0_ADC_H, and axp202_regs::adc::GPIO0_ADC_L.
| float AXP202Adc::getGpio1Voltage | ( | ) |
Read GPIO1 ADC voltage in mV (REG 66H/67H, 12-bit H8L4)
Definition at line 111 of file AXP202Adc.cpp.
References axp202_regs::factory::FACTORY_GPIO_VOLTAGE, axp202_regs::adc::GPIO1_ADC_H, and axp202_regs::adc::GPIO1_ADC_L.
| float AXP202Adc::getTsVoltage | ( | ) |
Read TS pin voltage in mV (REG 62H/63H, 12-bit H8L4)
Definition at line 93 of file AXP202Adc.cpp.
References axp202_regs::factory::FACTORY_TS_VOLTAGE, axp202_regs::adc::TS_IN_H, and axp202_regs::adc::TS_IN_L.
| bool AXP202Adc::setADCInputRange | ( | uint8_t | val | ) |
Set ADC input range (REG 85H)
| val | Raw register value |
Definition at line 59 of file AXP202Adc.cpp.
References axp1xx::AXP1xxAdc< AXP202Core, axp1xx::AdcTraitsBase< AXP202Core > >::_core, axp202_regs::adc::ADC_INPUTRANGE, and SensorCommWrapper::writeReg().
| bool AXP202Adc::setADCIrqFallingThreshold | ( | uint8_t | val | ) |
Set ADC IRQ falling-edge threshold (REG 87H)
| val | Raw register value |
Definition at line 81 of file AXP202Adc.cpp.
References axp1xx::AXP1xxAdc< AXP202Core, axp1xx::AdcTraitsBase< AXP202Core > >::_core, axp202_regs::adc::ADC_IRQ_FETFSET, and SensorCommWrapper::writeReg().
| bool AXP202Adc::setADCIrqRisingThreshold | ( | uint8_t | val | ) |
Set ADC IRQ rising-edge threshold (REG 86H)
| val | Raw register value |
Definition at line 70 of file AXP202Adc.cpp.
References axp1xx::AXP1xxAdc< AXP202Core, axp1xx::AdcTraitsBase< AXP202Core > >::_core, axp202_regs::adc::ADC_IRQ_RETFSET, and SensorCommWrapper::writeReg().
| bool AXP202Adc::setADCSampleRate | ( | uint8_t | rate | ) |
Set ADC sample rate (REG 84H bits 7:6)
| rate | 0=25Hz, 1=50Hz, 2=100Hz, 3=200Hz |
Definition at line 45 of file AXP202Adc.cpp.
References axp1xx::AXP1xxAdc< AXP202Core, axp1xx::AdcTraitsBase< AXP202Core > >::_core, axp202_regs::adc::ADC_SPEED, and SensorCommWrapper::updateBits().
|
staticconstexpr |
Definition at line 59 of file AXP202Adc.hpp.
|
staticconstexpr |
Definition at line 58 of file AXP202Adc.hpp.
|
staticconstexpr |
Definition at line 62 of file AXP202Adc.hpp.
|
staticconstexpr |
Definition at line 57 of file AXP202Adc.hpp.
|
staticconstexpr |
Definition at line 56 of file AXP202Adc.hpp.
|
staticconstexpr |
Definition at line 65 of file AXP202Adc.hpp.
|
staticconstexpr |
Definition at line 66 of file AXP202Adc.hpp.
|
staticconstexpr |
Definition at line 64 of file AXP202Adc.hpp.
|
staticconstexpr |
Definition at line 63 of file AXP202Adc.hpp.
|
staticconstexpr |
Definition at line 61 of file AXP202Adc.hpp.
|
staticconstexpr |
Definition at line 60 of file AXP202Adc.hpp.