30#include "../../../SensorBuildOpt.h"
31#if !SENSORLIB_EXCLUDE_PMIC_AXP517
42bool AXP517Pwron::updateBits(uint8_t mask, uint8_t value)
45 if (v < 0)
return false;
46 uint8_t cur = (uint8_t)v;
47 uint8_t next = (uint8_t)((cur & ~mask) | (value & mask));
48 if (next == cur)
return true;
55 uint8_t idx = (ms >= 2000) ? 3 :
58 return updateBits(0x03, idx);
64 const uint16_t kOnLevelMs[] = {128, 512, 1000, 2000};
66 if (v < 0)
return false;
67 ms = kOnLevelMs[((uint8_t)v) & 0x03];
73 uint8_t idx = (ms >= 10000) ? 3 :
76 return updateBits(0x0C, idx << 2);
82 const uint16_t kOffLevelMs[] = {4000, 6000, 8000, 10000};
84 if (v < 0)
return false;
85 ms = kOffLevelMs[(((uint8_t)v) >> 2) & 0x03];
92 uint8_t idx = (ms >= 2500) ? 3 :
95 return updateBits(0x30, idx << 4);
101 const uint16_t kIrqLevelMs[] = {1000, 1500, 2000, 2500};
103 if (v < 0)
return false;
104 ms = kIrqLevelMs[(((uint8_t)v) >> 4) & 0x03];
AXP517 low-level core driver.
AXP517Pwron(AXP517Core &core)
Construct an AXP517 PWRON button driver.
bool setOffDurationMs(uint16_t ms) override
Set the power-off debounce duration.
bool setOnDurationMs(uint16_t ms) override
Set the power-on debounce duration.
bool getOnDurationMs(uint16_t &ms) const override
Get the current power-on debounce duration.
bool getIrqDurationMs(uint16_t &ms) const override
Get the current button IRQ trigger duration.
bool getOffDurationMs(uint16_t &ms) const override
Get the current power-off debounce duration.
bool setIrqDurationMs(uint16_t ms) override
Set the button IRQ trigger duration.
int readReg(uint8_t reg) const
int writeReg(uint8_t reg, uint8_t val)
static constexpr uint8_t PWRON_CFG
PWRON configure.