38#include "../../../SensorBuildOpt.h"
39#if !SENSORLIB_EXCLUDE_PMIC_AXP202
47 if (rate > 3)
return false;
54 if (val < 0)
return 0;
55 static const uint16_t rates[] = {25, 50, 100, 200};
56 return rates[(val >> 6) & 0x03];
67 return (val < 0) ? 0 :
static_cast<uint8_t
>(val);
78 return (val < 0) ? 0 :
static_cast<uint8_t
>(val);
89 return (val < 0) ? 0 :
static_cast<uint8_t
>(val);
96 if (raw == 0xFFFF)
return 0.0f;
105 if (raw == 0xFFFF)
return 0.0f;
114 if (raw == 0xFFFF)
return 0.0f;
124 uint32_t raw = (
static_cast<uint32_t
>(
buf[0]) << 16) |
125 (
static_cast<uint32_t
>(
buf[1]) << 8) |
126 static_cast<uint32_t
>(
buf[2]);
127 return static_cast<float>(raw) * 2.0f * 1.1f * 0.5f / 1000.0f;
132uint16_t AXP202Adc::readRegisterH8L4(uint8_t regH, uint8_t regL)
136 if (h < 0 || l < 0) {
139 return (
static_cast<uint16_t
>(h) << 4) | (
static_cast<uint16_t
>(l) & 0x0F);
bool setADCInputRange(uint8_t val)
Set ADC input range (REG 85H)
bool setADCSampleRate(uint8_t rate)
Set ADC sample rate (REG 84H bits 7:6)
float getBatteryPower()
Read battery instantaneous power (REG 70H-72H, 24-bit)
float getGpio0Voltage()
Read GPIO0 ADC voltage in mV (REG 64H/65H, 12-bit H8L4)
uint8_t getADCIrqRisingThreshold()
uint8_t getADCIrqFallingThreshold()
bool setADCIrqRisingThreshold(uint8_t val)
Set ADC IRQ rising-edge threshold (REG 86H)
bool setADCIrqFallingThreshold(uint8_t val)
Set ADC IRQ falling-edge threshold (REG 87H)
uint16_t getADCSampleRate()
Get ADC sample rate in Hz.
uint8_t getADCInputRange()
float getTsVoltage()
Read TS pin voltage in mV (REG 62H/63H, 12-bit H8L4)
float getGpio1Voltage()
Read GPIO1 ADC voltage in mV (REG 66H/67H, 12-bit H8L4)
int readReg(uint8_t reg) const
int writeReg(uint8_t reg, uint8_t val)
int readRegBuff(uint8_t reg, uint8_t *buf, size_t len) const
int updateBits(uint8_t reg, uint8_t mask, uint8_t value_shifted)
AXP202Core & _core
Reference to I2C communication core.
static constexpr uint8_t ADC_IRQ_RETFSET
static constexpr uint8_t GPIO0_ADC_H
static constexpr uint8_t GPIO1_ADC_H
static constexpr uint8_t BAT_POWER_H
static constexpr uint8_t GPIO0_ADC_L
static constexpr uint8_t ADC_INPUTRANGE
static constexpr uint8_t TS_IN_H
static constexpr uint8_t ADC_SPEED
static constexpr uint8_t ADC_IRQ_FETFSET
static constexpr uint8_t GPIO1_ADC_L
static constexpr uint8_t TS_IN_L
static constexpr float FACTORY_GPIO_VOLTAGE
static constexpr float FACTORY_TS_VOLTAGE