30#include "../../../SensorBuildOpt.h"
31#if !SENSORLIB_EXCLUDE_PMIC_AXP517
43 mask &= ~IRQ_RESERVED_MASK;
51 uint64_t current = (
static_cast<uint64_t
>(buffer[0]) << 24) |
52 (
static_cast<uint64_t
>(buffer[1]) << 16) |
53 (
static_cast<uint64_t
>(buffer[2]) << 8) |
54 (
static_cast<uint64_t
>(buffer[3]));
55 current &= (~IRQ_RESERVED_MASK);
57 buffer[0] =
static_cast<uint8_t
>((current >> 24) & 0xFF);
58 buffer[1] =
static_cast<uint8_t
>((current >> 16) & 0xFF);
59 buffer[2] =
static_cast<uint8_t
>((current >> 8) & 0xFF);
60 buffer[3] =
static_cast<uint8_t
>(current & 0xFF);
69 mask &= ~IRQ_RESERVED_MASK;
76 uint64_t current = (
static_cast<uint64_t
>(buffer[0]) << 24) |
77 (
static_cast<uint64_t
>(buffer[1]) << 16) |
78 (
static_cast<uint64_t
>(buffer[2]) << 8) |
79 (
static_cast<uint64_t
>(buffer[3]));
81 current &= (~IRQ_RESERVED_MASK);
83 buffer[0] =
static_cast<uint8_t
>((current >> 24) & 0xFF);
84 buffer[1] =
static_cast<uint8_t
>((current >> 16) & 0xFF);
85 buffer[2] =
static_cast<uint8_t
>((current >> 8) & 0xFF);
86 buffer[3] =
static_cast<uint8_t
>(current & 0xFF);
96 int pdAlertL = _core.
readReg(axp517::tcpc::PD_ALERTL);
97 int pdAlertH = _core.
readReg(axp517::tcpc::PD_ALERTH);
98 if (pdAlertL < 0 || pdAlertH < 0) {
108 uint16_t pdAlert =
static_cast<uint16_t
>(pdAlertL) |
109 (
static_cast<uint16_t
>(pdAlertH) << 8);
110 uint64_t mask = (
static_cast<uint64_t
>(pdAlert) << 32) |
111 (
static_cast<uint64_t
>(buffer[0]) << 24) |
112 (
static_cast<uint64_t
>(buffer[1]) << 16) |
113 (
static_cast<uint64_t
>(buffer[2]) << 8) |
114 (
static_cast<uint64_t
>(buffer[3]));
115 mask &= (~IRQ_RESERVED_MASK);
116 if (clear && mask != 0) {
124 uint8_t buffer[4] = {0xFF, 0xFF, 0xFF, 0xFF};
125 int fault = _core.
readReg(axp517::tcpc::FAULT_STATUS);
130 uint8_t faultStatus =
static_cast<uint8_t
>(fault);
131 if (faultStatus && _core.
writeReg(axp517::tcpc::FAULT_STATUS, faultStatus) < 0) {
135 if (_core.
writeReg(axp517::tcpc::PD_ALERTL, 0xFF) < 0 ||
136 _core.
writeReg(axp517::tcpc::PD_ALERTH, 0xFF) < 0) {
#define SENSORLIB_LOG_E(...)
AXP517 low-level core driver.
bool enable(uint64_t mask) override
Enable one or more PMIC IRQ sources.
bool disable(uint64_t mask) override
Disable one or more PMIC IRQ sources.
uint64_t readStatus(bool clear=true) override
Read the current IRQ status.
AXP517Irq(AXP517Core &core)
Construct an AXP517 IRQ helper.
bool clearStatus() override
Clear all pending PMIC IRQ and TCPC alert status bits.
int readReg(uint8_t reg) const
int writeRegBuff(uint8_t reg, uint8_t *buf, size_t len)
int writeReg(uint8_t reg, uint8_t val)
int readRegBuff(uint8_t reg, uint8_t *buf, size_t len) const
static constexpr uint8_t ENABLE0
IRQ Enable 0.
static constexpr uint8_t STATUS0
IRQ Status 0.