|
SensorLib 0.5.0
Multi-platform sensor driver library for Arduino, PlatformIO, and ESP-IDF
|
Interrupt controller interface for the AXP2101 PMIC. More...
#include <AXP2101Irq.hpp>
Public Member Functions | |
| AXP2101Irq (AXP2101Core &core) | |
| ~AXP2101Irq ()=default | |
| bool | enable (uint64_t mask) override |
| Enable one or more interrupt sources. | |
| bool | disable (uint64_t mask) override |
| Disable one or more interrupt sources. | |
| uint64_t | readStatus (bool clear=true) override |
| Read the current interrupt status. | |
| bool | clearStatus () override |
| Clear all pending interrupt status registers. | |
Public Member Functions inherited from PmicIrqBase | |
| virtual | ~PmicIrqBase ()=default |
Static Public Member Functions | |
| static bool | isIrqSet (uint64_t irqMask, uint64_t status) |
| Check whether a specific interrupt bit is set in a status word. | |
| static bool | isBatOverTempWork (uint64_t mask) |
| Check if battery over-temperature (working range) interrupt is set. | |
| static bool | isBatUnderTempWork (uint64_t mask) |
| Check if battery under-temperature (working range) interrupt is set. | |
| static bool | isBatOverTempChg (uint64_t mask) |
| Check if battery over-temperature (charging range) interrupt is set. | |
| static bool | isBatUnderTempChg (uint64_t mask) |
| Check if battery under-temperature (charging range) interrupt is set. | |
| static bool | isGaugeNewSoc (uint64_t mask) |
| Check if gauge new state-of-charge interrupt is set. | |
| static bool | isGaugeWdtTimeout (uint64_t mask) |
| Check if gauge watchdog timeout interrupt is set. | |
| static bool | isWarningLevel1 (uint64_t mask) |
| Check if battery warning level 1 interrupt is set. | |
| static bool | isWarningLevel2 (uint64_t mask) |
| Check if battery warning level 2 interrupt is set. | |
| static bool | isVbusInsert (uint64_t mask) |
| Check if VBUS insertion interrupt is set. | |
| static bool | isVbusRemove (uint64_t mask) |
| Check if VBUS removal interrupt is set. | |
| static bool | isBatInsert (uint64_t mask) |
| Check if battery insertion interrupt is set. | |
| static bool | isBatRemove (uint64_t mask) |
| Check if battery removal interrupt is set. | |
| static bool | isPekeyShortPress (uint64_t mask) |
| Check if power key short press interrupt is set. | |
| static bool | isPekeyLongPress (uint64_t mask) |
| Check if power key long press interrupt is set. | |
| static bool | isPkeyNegativeEdge (uint64_t mask) |
| Check if power key negative (falling) edge interrupt is set. | |
| static bool | isPkeyPositiveEdge (uint64_t mask) |
| Check if power key positive (rising) edge interrupt is set. | |
| static bool | isWdtExpire (uint64_t mask) |
| Check if watchdog timer expired interrupt is set. | |
| static bool | isLdoOverCurr (uint64_t mask) |
| Check if LDO over-current interrupt is set. | |
| static bool | isBatfetOverCurr (uint64_t mask) |
| Check if BATFET over-current interrupt is set. | |
| static bool | isBatChgDone (uint64_t mask) |
| Check if battery charge done interrupt is set. | |
| static bool | isBatChgStart (uint64_t mask) |
| Check if battery charge start interrupt is set. | |
| static bool | isDieOverTemp (uint64_t mask) |
| Check if die over-temperature interrupt is set. | |
| static bool | isChgTimeout (uint64_t mask) |
| Check if charge timeout interrupt is set. | |
| static bool | isBatOverVolt (uint64_t mask) |
| Check if battery over-voltage interrupt is set. | |
Static Public Attributes | |
| static constexpr uint64_t | IRQ_BAT_UNDER_TEMP_WORK = (1ULL << 0) |
| Battery temperature dropped below the working threshold. | |
| static constexpr uint64_t | IRQ_BAT_OVER_TEMP_WORK = (1ULL << 1) |
| Battery temperature exceeded the working threshold. | |
| static constexpr uint64_t | IRQ_BAT_UNDER_TEMP_CHG = (1ULL << 2) |
| Battery temperature dropped below the charging threshold. | |
| static constexpr uint64_t | IRQ_BAT_OVER_TEMP_CHG = (1ULL << 3) |
| Battery temperature exceeded the charging threshold. | |
| static constexpr uint64_t | IRQ_GAUGE_NEW_SOC = (1ULL << 4) |
| Coulomb gauge reported a new state-of-charge value. | |
| static constexpr uint64_t | IRQ_GAUGE_WDT_TIMEOUT = (1ULL << 5) |
| Coulomb gauge watchdog timer expired. | |
| static constexpr uint64_t | IRQ_WARNING_LEVEL1 = (1ULL << 6) |
| Battery voltage crossed warning level 1 threshold. | |
| static constexpr uint64_t | IRQ_WARNING_LEVEL2 = (1ULL << 7) |
| Battery voltage crossed warning level 2 threshold. | |
| static constexpr uint64_t | IRQ_PEKEY_POSITIVE_EDGE = (1ULL << 8) |
| Power key rising edge detected. | |
| static constexpr uint64_t | IRQ_PEKEY_NEGATIVE_EDGE = (1ULL << 9) |
| Power key falling edge detected. | |
| static constexpr uint64_t | IRQ_PEKEY_LONG_PRESS = (1ULL << 10) |
| Power key held for a long press duration. | |
| static constexpr uint64_t | IRQ_PEKEY_SHORT_PRESS = (1ULL << 11) |
| Power key pressed briefly (short press). | |
| static constexpr uint64_t | IRQ_BAT_REMOVE = (1ULL << 12) |
| Battery removed from the system. | |
| static constexpr uint64_t | IRQ_BAT_INSERT = (1ULL << 13) |
| Battery inserted into the system. | |
| static constexpr uint64_t | IRQ_VBUS_REMOVE = (1ULL << 14) |
| VBUS power source removed. | |
| static constexpr uint64_t | IRQ_VBUS_INSERT = (1ULL << 15) |
| VBUS power source inserted. | |
| static constexpr uint64_t | IRQ_BAT_OVER_VOLT = (1ULL << 16) |
| Battery voltage exceeded the over-voltage threshold. | |
| static constexpr uint64_t | IRQ_CHG_TIMEOUT = (1ULL << 17) |
| Battery charge cycle timed out. | |
| static constexpr uint64_t | IRQ_DIE_OVER_TEMP = (1ULL << 18) |
| Die temperature exceeded the thermal shutdown threshold. | |
| static constexpr uint64_t | IRQ_BAT_CHG_START = (1ULL << 19) |
| Battery charging has started. | |
| static constexpr uint64_t | IRQ_BAT_CHG_DONE = (1ULL << 20) |
| Battery charging has completed. | |
| static constexpr uint64_t | IRQ_BATFET_OVER_CURR = (1ULL << 21) |
| BATFET over-current condition detected. | |
| static constexpr uint64_t | IRQ_LDO_OVER_CURR = (1ULL << 22) |
| LDO output over-current condition detected. | |
| static constexpr uint64_t | IRQ_WDT_EXPIRE = (1ULL << 23) |
| Watchdog timer expired. | |
| static constexpr uint64_t | IRQ_ALL_MASK = 0xFFFFFFULL |
| Mask covering all defined interrupt bits. | |
| static constexpr uint64_t | IRQ_RESERVED_MASK = ~0xFFFFFFULL |
| Mask for reserved / unused interrupt bits. | |
Interrupt controller interface for the AXP2101 PMIC.
Manages the three interrupt status registers (REG 0x48-0x4A) and three enable registers (REG 0x40-0x42). Supports 32 interrupt sources covering:
Interrupt status is returned as a 64-bit mask where each bit corresponds to a specific event. Provides inline query helpers for checking individual interrupt flags.
Definition at line 54 of file AXP2101Irq.hpp.
|
explicit |
Definition at line 38 of file AXP2101Irq.cpp.
|
default |
|
overridevirtual |
Clear all pending interrupt status registers.
Implements PmicIrqBase.
Definition at line 101 of file AXP2101Irq.cpp.
References i, axp2101_regs::irq::STATUS1, and SensorCommWrapper::writeReg().
Referenced by setup().
|
overridevirtual |
Disable one or more interrupt sources.
| mask | Bitmask of interrupts to disable. |
Implements PmicIrqBase.
Definition at line 60 of file AXP2101Irq.cpp.
References axp2101_regs::irq::ENABLE1, i, SensorCommWrapper::readReg(), and SensorCommWrapper::writeReg().
|
overridevirtual |
Enable one or more interrupt sources.
| mask | Bitmask of interrupts to enable. |
Implements PmicIrqBase.
Definition at line 42 of file AXP2101Irq.cpp.
References axp2101_regs::irq::ENABLE1, i, SensorCommWrapper::readReg(), and SensorCommWrapper::writeReg().
Referenced by setup().
|
inlinestatic |
Check if battery charge done interrupt is set.
Definition at line 167 of file AXP2101Irq.hpp.
References IRQ_BAT_CHG_DONE, and isIrqSet().
Referenced by loop().
|
inlinestatic |
Check if battery charge start interrupt is set.
Definition at line 169 of file AXP2101Irq.hpp.
References IRQ_BAT_CHG_START, and isIrqSet().
Referenced by loop().
|
inlinestatic |
Check if BATFET over-current interrupt is set.
Definition at line 165 of file AXP2101Irq.hpp.
References IRQ_BATFET_OVER_CURR, and isIrqSet().
Referenced by loop().
|
inlinestatic |
Check if battery insertion interrupt is set.
Definition at line 148 of file AXP2101Irq.hpp.
References IRQ_BAT_INSERT, and isIrqSet().
Referenced by loop().
|
inlinestatic |
Check if battery over-temperature (charging range) interrupt is set.
Definition at line 131 of file AXP2101Irq.hpp.
References IRQ_BAT_OVER_TEMP_CHG, and isIrqSet().
Referenced by loop().
|
inlinestatic |
Check if battery over-temperature (working range) interrupt is set.
Definition at line 127 of file AXP2101Irq.hpp.
References IRQ_BAT_OVER_TEMP_WORK, and isIrqSet().
Referenced by loop().
|
inlinestatic |
Check if battery over-voltage interrupt is set.
Definition at line 175 of file AXP2101Irq.hpp.
References IRQ_BAT_OVER_VOLT, and isIrqSet().
Referenced by loop().
|
inlinestatic |
Check if battery removal interrupt is set.
Definition at line 150 of file AXP2101Irq.hpp.
References IRQ_BAT_REMOVE, and isIrqSet().
Referenced by loop().
|
inlinestatic |
Check if battery under-temperature (charging range) interrupt is set.
Definition at line 133 of file AXP2101Irq.hpp.
References IRQ_BAT_UNDER_TEMP_CHG, and isIrqSet().
Referenced by loop().
|
inlinestatic |
Check if battery under-temperature (working range) interrupt is set.
Definition at line 129 of file AXP2101Irq.hpp.
References IRQ_BAT_UNDER_TEMP_WORK, and isIrqSet().
Referenced by loop().
|
inlinestatic |
Check if charge timeout interrupt is set.
Definition at line 173 of file AXP2101Irq.hpp.
References IRQ_CHG_TIMEOUT, and isIrqSet().
Referenced by loop().
|
inlinestatic |
Check if die over-temperature interrupt is set.
Definition at line 171 of file AXP2101Irq.hpp.
References IRQ_DIE_OVER_TEMP, and isIrqSet().
Referenced by loop().
|
inlinestatic |
Check if gauge new state-of-charge interrupt is set.
Definition at line 135 of file AXP2101Irq.hpp.
References IRQ_GAUGE_NEW_SOC, and isIrqSet().
Referenced by loop().
|
inlinestatic |
Check if gauge watchdog timeout interrupt is set.
Definition at line 137 of file AXP2101Irq.hpp.
References IRQ_GAUGE_WDT_TIMEOUT, and isIrqSet().
|
inlinestatic |
Check whether a specific interrupt bit is set in a status word.
| irqMask | Bitmask of the interrupt(s) to test. |
| status | The full status word to check. |
Definition at line 124 of file AXP2101Irq.hpp.
Referenced by isBatChgDone(), isBatChgStart(), isBatfetOverCurr(), isBatInsert(), isBatOverTempChg(), isBatOverTempWork(), isBatOverVolt(), isBatRemove(), isBatUnderTempChg(), isBatUnderTempWork(), isChgTimeout(), isDieOverTemp(), isGaugeNewSoc(), isGaugeWdtTimeout(), isLdoOverCurr(), isPekeyLongPress(), isPekeyShortPress(), isPkeyNegativeEdge(), isPkeyPositiveEdge(), isVbusInsert(), isVbusRemove(), isWarningLevel1(), isWarningLevel2(), and isWdtExpire().
|
inlinestatic |
Check if LDO over-current interrupt is set.
Definition at line 163 of file AXP2101Irq.hpp.
References IRQ_LDO_OVER_CURR, and isIrqSet().
Referenced by loop().
|
inlinestatic |
Check if power key long press interrupt is set.
Definition at line 154 of file AXP2101Irq.hpp.
References IRQ_PEKEY_LONG_PRESS, and isIrqSet().
Referenced by loop().
|
inlinestatic |
Check if power key short press interrupt is set.
Definition at line 152 of file AXP2101Irq.hpp.
References IRQ_PEKEY_SHORT_PRESS, and isIrqSet().
Referenced by loop().
|
inlinestatic |
Check if power key negative (falling) edge interrupt is set.
Definition at line 156 of file AXP2101Irq.hpp.
References IRQ_PEKEY_NEGATIVE_EDGE, and isIrqSet().
Referenced by loop().
|
inlinestatic |
Check if power key positive (rising) edge interrupt is set.
Definition at line 158 of file AXP2101Irq.hpp.
References IRQ_PEKEY_POSITIVE_EDGE, and isIrqSet().
Referenced by loop().
|
inlinestatic |
Check if VBUS insertion interrupt is set.
Definition at line 144 of file AXP2101Irq.hpp.
References IRQ_VBUS_INSERT, and isIrqSet().
Referenced by loop().
|
inlinestatic |
Check if VBUS removal interrupt is set.
Definition at line 146 of file AXP2101Irq.hpp.
References IRQ_VBUS_REMOVE, and isIrqSet().
Referenced by loop().
|
inlinestatic |
Check if battery warning level 1 interrupt is set.
Definition at line 139 of file AXP2101Irq.hpp.
References IRQ_WARNING_LEVEL1, and isIrqSet().
|
inlinestatic |
Check if battery warning level 2 interrupt is set.
Definition at line 141 of file AXP2101Irq.hpp.
References IRQ_WARNING_LEVEL2, and isIrqSet().
|
inlinestatic |
Check if watchdog timer expired interrupt is set.
Definition at line 161 of file AXP2101Irq.hpp.
References IRQ_WDT_EXPIRE, and isIrqSet().
Referenced by loop().
|
overridevirtual |
Read the current interrupt status.
Optionally clears all pending interrupts after reading.
| clear | If true, clear status registers after read (default: true). |
Implements PmicIrqBase.
Definition at line 78 of file AXP2101Irq.cpp.
References i, SensorCommWrapper::readReg(), axp2101_regs::irq::STATUS1, and SensorCommWrapper::writeReg().
Referenced by loop().
|
staticconstexpr |
Mask covering all defined interrupt bits.
Definition at line 112 of file AXP2101Irq.hpp.
|
staticconstexpr |
Battery charging has completed.
Definition at line 103 of file AXP2101Irq.hpp.
Referenced by isBatChgDone(), and setup().
|
staticconstexpr |
Battery charging has started.
Definition at line 101 of file AXP2101Irq.hpp.
Referenced by isBatChgStart(), and setup().
|
staticconstexpr |
Battery inserted into the system.
Definition at line 87 of file AXP2101Irq.hpp.
Referenced by isBatInsert(), and setup().
|
staticconstexpr |
Battery temperature exceeded the charging threshold.
Definition at line 65 of file AXP2101Irq.hpp.
Referenced by isBatOverTempChg().
|
staticconstexpr |
Battery temperature exceeded the working threshold.
Definition at line 61 of file AXP2101Irq.hpp.
Referenced by isBatOverTempWork().
|
staticconstexpr |
Battery voltage exceeded the over-voltage threshold.
Definition at line 95 of file AXP2101Irq.hpp.
Referenced by isBatOverVolt().
|
staticconstexpr |
Battery removed from the system.
Definition at line 85 of file AXP2101Irq.hpp.
Referenced by isBatRemove(), and setup().
|
staticconstexpr |
Battery temperature dropped below the charging threshold.
Definition at line 63 of file AXP2101Irq.hpp.
Referenced by isBatUnderTempChg().
|
staticconstexpr |
Battery temperature dropped below the working threshold.
Definition at line 59 of file AXP2101Irq.hpp.
Referenced by isBatUnderTempWork().
|
staticconstexpr |
BATFET over-current condition detected.
Definition at line 105 of file AXP2101Irq.hpp.
Referenced by isBatfetOverCurr().
|
staticconstexpr |
Battery charge cycle timed out.
Definition at line 97 of file AXP2101Irq.hpp.
Referenced by isChgTimeout().
|
staticconstexpr |
Die temperature exceeded the thermal shutdown threshold.
Definition at line 99 of file AXP2101Irq.hpp.
Referenced by isDieOverTemp(), and setup().
|
staticconstexpr |
Coulomb gauge reported a new state-of-charge value.
Definition at line 67 of file AXP2101Irq.hpp.
Referenced by isGaugeNewSoc().
|
staticconstexpr |
Coulomb gauge watchdog timer expired.
Definition at line 69 of file AXP2101Irq.hpp.
Referenced by isGaugeWdtTimeout().
|
staticconstexpr |
LDO output over-current condition detected.
Definition at line 107 of file AXP2101Irq.hpp.
Referenced by isLdoOverCurr().
|
staticconstexpr |
Power key held for a long press duration.
Definition at line 81 of file AXP2101Irq.hpp.
Referenced by isPekeyLongPress(), and setup().
|
staticconstexpr |
Power key falling edge detected.
Definition at line 79 of file AXP2101Irq.hpp.
Referenced by isPkeyNegativeEdge().
|
staticconstexpr |
Power key rising edge detected.
Definition at line 77 of file AXP2101Irq.hpp.
Referenced by isPkeyPositiveEdge().
|
staticconstexpr |
Power key pressed briefly (short press).
Definition at line 83 of file AXP2101Irq.hpp.
Referenced by isPekeyShortPress(), and setup().
|
staticconstexpr |
Mask for reserved / unused interrupt bits.
Definition at line 114 of file AXP2101Irq.hpp.
|
staticconstexpr |
VBUS power source inserted.
Definition at line 91 of file AXP2101Irq.hpp.
Referenced by isVbusInsert(), and setup().
|
staticconstexpr |
VBUS power source removed.
Definition at line 89 of file AXP2101Irq.hpp.
Referenced by isVbusRemove(), and setup().
|
staticconstexpr |
Battery voltage crossed warning level 1 threshold.
Definition at line 71 of file AXP2101Irq.hpp.
Referenced by isWarningLevel1().
|
staticconstexpr |
Battery voltage crossed warning level 2 threshold.
Definition at line 73 of file AXP2101Irq.hpp.
Referenced by isWarningLevel2().
|
staticconstexpr |
Watchdog timer expired.
Definition at line 109 of file AXP2101Irq.hpp.
Referenced by isWdtExpire(), and setup().