|
SensorLib 0.5.0
Multi-platform sensor driver library for Arduino, PlatformIO, and ESP-IDF
|
AXP517 interrupt controller helper. More...
#include <AXP517Irq.hpp>
Public Member Functions | |
| AXP517Irq (AXP517Core &core) | |
| Construct an AXP517 IRQ helper. | |
| ~AXP517Irq ()=default | |
| 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. | |
| bool | clearStatus () override |
| Clear all pending PMIC IRQ and TCPC alert status bits. | |
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 combined IRQ status contains a specific IRQ source. | |
IRQ Status 0 helper checks (REG 48H) | |
| static bool | isSocWarningLevel (uint64_t mask) |
| static bool | isSocShutdownLevel (uint64_t mask) |
| static bool | isGaugeNewSoc (uint64_t mask) |
| static bool | isChargeToNormal (uint64_t mask) |
| static bool | isBoostOverVoltage (uint64_t mask) |
| static bool | isVbusOverVoltage (uint64_t mask) |
| static bool | isVbusFault (uint64_t mask) |
IRQ Status 1 helper checks (REG 49H) | |
| static bool | isVbusInsert (uint64_t mask) |
| static bool | isVbusRemove (uint64_t mask) |
| static bool | isBatteryInsert (uint64_t mask) |
| static bool | isBatteryRemove (uint64_t mask) |
| static bool | isPwrOnShortPress (uint64_t mask) |
| static bool | isPwrOnLongPress (uint64_t mask) |
| static bool | isPwrOnNegativeEdge (uint64_t mask) |
| static bool | isPwrOnPositiveEdge (uint64_t mask) |
IRQ Status 2 helper checks (REG 4AH) | |
| static bool | isWatchdogExpire (uint64_t mask) |
| static bool | isBatFetOcp (uint64_t mask) |
| static bool | isChargeDone (uint64_t mask) |
| static bool | isChargeStart (uint64_t mask) |
| static bool | isDieOverTempLevel1 (uint64_t mask) |
| static bool | isChgSafetyTimer (uint64_t mask) |
| static bool | isBatOverVoltage (uint64_t mask) |
IRQ Status 3 helper checks (REG 4BH) | |
| static bool | isBc12DetectFinished (uint64_t mask) |
| static bool | isBc12DetectChange (uint64_t mask) |
| static bool | isBatOverTempQuitChg (uint64_t mask) |
| static bool | isBatOverTempChg (uint64_t mask) |
| static bool | isBatUnderTempChg (uint64_t mask) |
| static bool | isBatOverTempWork (uint64_t mask) |
| static bool | isBatUnderTempWork (uint64_t mask) |
Static Public Attributes | |
IRQ Status 0 bits (REG48H) | |
Combined readStatus() bit mapping. Bits [31:24] map to STATUS0, [23:16] to STATUS1, [15:8] to STATUS2, [7:0] to STATUS3, and [47:32] to PD_ALERTL/H. | |
| static constexpr uint64_t | IRQ_SOC_WARNING_LEVEL = (1ULL << 31) |
| SOC drop to Warning Level. | |
| static constexpr uint64_t | IRQ_SOC_SHUTDOWN_LEVEL = (1ULL << 30) |
| SOC drop to Shutdown Level. | |
| static constexpr uint64_t | IRQ_GAUGE_NEW_SOC = (1ULL << 28) |
| Gauge New SOC. | |
| static constexpr uint64_t | IRQ_CHARGE_TO_NORMAL = (1ULL << 27) |
| Charge to normal. | |
| static constexpr uint64_t | IRQ_BOOST_OVER_VOLTAGE = (1ULL << 26) |
| BOOST Over Voltage. | |
| static constexpr uint64_t | IRQ_VBUS_OVER_VOLTAGE = (1ULL << 25) |
| VBUS Over Voltage. | |
| static constexpr uint64_t | IRQ_VBUS_FAULT = (1ULL << 24) |
| VBUS Fault. | |
IRQ Status 1 bits (REG49H) | |
| static constexpr uint64_t | IRQ_VBUS_INSERT = (1ULL << 23) |
| VBUS Insert. | |
| static constexpr uint64_t | IRQ_VBUS_REMOVE = (1ULL << 22) |
| VBUS Remove. | |
| static constexpr uint64_t | IRQ_BATTERY_INSERT = (1ULL << 21) |
| Battery Insert. | |
| static constexpr uint64_t | IRQ_BATTERY_REMOVE = (1ULL << 20) |
| Battery Remove. | |
| static constexpr uint64_t | IRQ_PWR_ON_SHORT_PRESS = (1ULL << 19) |
| PWR_ON pin Short PRESS. | |
| static constexpr uint64_t | IRQ_PWR_ON_LONG_PRESS = (1ULL << 18) |
| PWR_ON pin Long PRESS. | |
| static constexpr uint64_t | IRQ_PWR_ON_NEGATIVE_EDGE = (1ULL << 17) |
| PWR_ON pin Negative Edge. | |
| static constexpr uint64_t | IRQ_PWR_ON_POSITIVE_EDGE = (1ULL << 16) |
| PWR_ON pin Positive Edge. | |
IRQ Status 2 bits (REG4AH) | |
| static constexpr uint64_t | IRQ_WATCHDOG_EXPIRE = (1ULL << 15) |
| Watchdog Expire. | |
| static constexpr uint64_t | IRQ_BAT_FET_OCP = (1ULL << 13) |
| BAT FET Over Current Protection. | |
| static constexpr uint64_t | IRQ_CHARGE_DONE = (1ULL << 12) |
| Battery charge done. | |
| static constexpr uint64_t | IRQ_CHARGE_START = (1ULL << 11) |
| Battery charge start. | |
| static constexpr uint64_t | IRQ_DIE_OVER_TEMP_LEVEL1 = (1ULL << 10) |
| DIE Over Temperature level1. | |
| static constexpr uint64_t | IRQ_CHG_SAFETY_TIMER = (1ULL << 9) |
| Charger Safety Timer1/2 expire. | |
| static constexpr uint64_t | IRQ_BAT_OVER_VOLTAGE = (1ULL << 8) |
| Battery Over Voltage Protection. | |
IRQ Status 3 bits (REG4BH) | |
| static constexpr uint64_t | IRQ_BC12_DETECT_FINISHED = (1ULL << 7) |
| BC1.2 detect finished. | |
| static constexpr uint64_t | IRQ_BC12_DETECT_CHANGE = (1ULL << 6) |
| BC1.2 detect result change. | |
| static constexpr uint64_t | IRQ_BAT_OVER_TEMP_QUIT_CHG = (1ULL << 4) |
| Battery Over Temperature Quit in Charge mode. | |
| static constexpr uint64_t | IRQ_BAT_OVER_TEMP_CHG = (1ULL << 3) |
| Battery Over Temperature in Charge mode. | |
| static constexpr uint64_t | IRQ_BAT_UNDER_TEMP_CHG = (1ULL << 2) |
| Battery Under Temperature in Charge mode. | |
| static constexpr uint64_t | IRQ_BAT_OVER_TEMP_WORK = (1ULL << 1) |
| Battery Over Temperature in Work mode. | |
| static constexpr uint64_t | IRQ_BAT_UNDER_TEMP_WORK = (1ULL << 0) |
| Battery Under Temperature in Work mode. | |
| static constexpr uint64_t | IRQ_ALL_MASK = 0xffffffffULL |
| Mask for all valid IRQ bits. | |
| static constexpr uint64_t | IRQ_RESERVED_MASK = (1ULL << 29) | (1ULL << 14) | (1ULL << 5) |
| Reserved IRQ bits. | |
AXP517 interrupt controller helper.
AXP517 exposes normal PMIC IRQ status in REG48H-REG4BH and TCPC/PD alert status in REG B0H-B1H. readStatus() combines both spaces into a single 64-bit value so applications using the shared active-low PMIC_IRQ pin can drain all pending sources.
Definition at line 44 of file AXP517Irq.hpp.
|
explicit |
Construct an AXP517 IRQ helper.
| core | Shared AXP517 register transport. |
Definition at line 37 of file AXP517Irq.cpp.
|
default |
|
overridevirtual |
Clear all pending PMIC IRQ and TCPC alert status bits.
| true | on success, false on register access failure. |
Implements PmicIrqBase.
Definition at line 122 of file AXP517Irq.cpp.
References SensorCommWrapper::readReg(), SENSORLIB_LOG_E, axp517_regs::irq::STATUS0, SensorCommWrapper::writeReg(), and SensorCommWrapper::writeRegBuff().
Referenced by readStatus(), requestPdVoltage(), resetPdState(), and setup().
|
overridevirtual |
Disable one or more PMIC IRQ sources.
| mask | Bitwise OR of IRQ_* sources to disable. |
| true | on success, false on register access failure. |
Implements PmicIrqBase.
Definition at line 67 of file AXP517Irq.cpp.
References axp517_regs::irq::ENABLE0, SensorCommWrapper::readRegBuff(), SENSORLIB_LOG_E, and SensorCommWrapper::writeRegBuff().
|
overridevirtual |
Enable one or more PMIC IRQ sources.
| mask | Bitwise OR of IRQ_* sources to enable. |
| true | on success, false on register access failure. |
Implements PmicIrqBase.
Definition at line 41 of file AXP517Irq.cpp.
References axp517_regs::irq::ENABLE0, SensorCommWrapper::readRegBuff(), SENSORLIB_LOG_E, and SensorCommWrapper::writeRegBuff().
Referenced by setup().
|
inlinestatic |
Definition at line 137 of file AXP517Irq.hpp.
References IRQ_BAT_FET_OCP, and isIrqSet().
Referenced by printPmicIrqLine().
|
inlinestatic |
Definition at line 150 of file AXP517Irq.hpp.
References IRQ_BAT_OVER_TEMP_CHG, and isIrqSet().
Referenced by printPmicIrqLine().
|
inlinestatic |
Definition at line 149 of file AXP517Irq.hpp.
References IRQ_BAT_OVER_TEMP_QUIT_CHG, and isIrqSet().
Referenced by printPmicIrqLine().
|
inlinestatic |
Definition at line 152 of file AXP517Irq.hpp.
References IRQ_BAT_OVER_TEMP_WORK, and isIrqSet().
Referenced by printPmicIrqLine().
|
inlinestatic |
Definition at line 142 of file AXP517Irq.hpp.
References IRQ_BAT_OVER_VOLTAGE, and isIrqSet().
Referenced by printPmicIrqLine().
|
inlinestatic |
Definition at line 126 of file AXP517Irq.hpp.
References IRQ_BATTERY_INSERT, and isIrqSet().
Referenced by handlePmicIrq(), and printPmicIrqLine().
|
inlinestatic |
Definition at line 127 of file AXP517Irq.hpp.
References IRQ_BATTERY_REMOVE, and isIrqSet().
Referenced by handlePmicIrq(), and printPmicIrqLine().
|
inlinestatic |
Definition at line 151 of file AXP517Irq.hpp.
References IRQ_BAT_UNDER_TEMP_CHG, and isIrqSet().
Referenced by printPmicIrqLine().
|
inlinestatic |
Definition at line 153 of file AXP517Irq.hpp.
References IRQ_BAT_UNDER_TEMP_WORK, and isIrqSet().
Referenced by printPmicIrqLine().
|
inlinestatic |
Definition at line 148 of file AXP517Irq.hpp.
References IRQ_BC12_DETECT_CHANGE, and isIrqSet().
Referenced by printPmicIrqLine().
|
inlinestatic |
Definition at line 147 of file AXP517Irq.hpp.
References IRQ_BC12_DETECT_FINISHED, and isIrqSet().
Referenced by printPmicIrqLine().
|
inlinestatic |
Definition at line 117 of file AXP517Irq.hpp.
References IRQ_BOOST_OVER_VOLTAGE, and isIrqSet().
Referenced by printPmicIrqLine().
|
inlinestatic |
Definition at line 138 of file AXP517Irq.hpp.
References IRQ_CHARGE_DONE, and isIrqSet().
Referenced by printPmicIrqLine().
|
inlinestatic |
Definition at line 139 of file AXP517Irq.hpp.
References IRQ_CHARGE_START, and isIrqSet().
Referenced by printPmicIrqLine().
|
inlinestatic |
Definition at line 116 of file AXP517Irq.hpp.
References IRQ_CHARGE_TO_NORMAL, and isIrqSet().
Referenced by printPmicIrqLine().
|
inlinestatic |
Definition at line 141 of file AXP517Irq.hpp.
References IRQ_CHG_SAFETY_TIMER, and isIrqSet().
Referenced by printPmicIrqLine().
|
inlinestatic |
Definition at line 140 of file AXP517Irq.hpp.
References IRQ_DIE_OVER_TEMP_LEVEL1, and isIrqSet().
Referenced by printPmicIrqLine().
|
inlinestatic |
Definition at line 115 of file AXP517Irq.hpp.
References IRQ_GAUGE_NEW_SOC, and isIrqSet().
Referenced by printPmicIrqLine().
|
inlinestatic |
Check whether a combined IRQ status contains a specific IRQ source.
| irqMask | One IRQ_* source bit. |
| status | Combined IRQ status returned by readStatus(). |
| true | if the source is set, false otherwise. |
Definition at line 109 of file AXP517Irq.hpp.
Referenced by isBatFetOcp(), isBatOverTempChg(), isBatOverTempQuitChg(), isBatOverTempWork(), isBatOverVoltage(), isBatteryInsert(), isBatteryRemove(), isBatUnderTempChg(), isBatUnderTempWork(), isBc12DetectChange(), isBc12DetectFinished(), isBoostOverVoltage(), isChargeDone(), isChargeStart(), isChargeToNormal(), isChgSafetyTimer(), isDieOverTempLevel1(), isGaugeNewSoc(), isPwrOnLongPress(), isPwrOnNegativeEdge(), isPwrOnPositiveEdge(), isPwrOnShortPress(), isSocShutdownLevel(), isSocWarningLevel(), isVbusFault(), isVbusInsert(), isVbusOverVoltage(), isVbusRemove(), and isWatchdogExpire().
|
inlinestatic |
Definition at line 129 of file AXP517Irq.hpp.
References IRQ_PWR_ON_LONG_PRESS, and isIrqSet().
Referenced by printPmicIrqLine().
|
inlinestatic |
Definition at line 130 of file AXP517Irq.hpp.
References IRQ_PWR_ON_NEGATIVE_EDGE, and isIrqSet().
Referenced by printPmicIrqLine().
|
inlinestatic |
Definition at line 131 of file AXP517Irq.hpp.
References IRQ_PWR_ON_POSITIVE_EDGE, and isIrqSet().
Referenced by printPmicIrqLine().
|
inlinestatic |
Definition at line 128 of file AXP517Irq.hpp.
References IRQ_PWR_ON_SHORT_PRESS, and isIrqSet().
Referenced by handlePmicIrq(), and printPmicIrqLine().
|
inlinestatic |
Definition at line 114 of file AXP517Irq.hpp.
References IRQ_SOC_SHUTDOWN_LEVEL, and isIrqSet().
Referenced by printPmicIrqLine().
|
inlinestatic |
Definition at line 113 of file AXP517Irq.hpp.
References IRQ_SOC_WARNING_LEVEL, and isIrqSet().
Referenced by printPmicIrqLine().
|
inlinestatic |
Definition at line 119 of file AXP517Irq.hpp.
References IRQ_VBUS_FAULT, and isIrqSet().
Referenced by printPmicIrqLine().
|
inlinestatic |
Definition at line 124 of file AXP517Irq.hpp.
References IRQ_VBUS_INSERT, and isIrqSet().
Referenced by handlePmicIrq(), and printPmicIrqLine().
|
inlinestatic |
Definition at line 118 of file AXP517Irq.hpp.
References IRQ_VBUS_OVER_VOLTAGE, and isIrqSet().
Referenced by printPmicIrqLine().
|
inlinestatic |
Definition at line 125 of file AXP517Irq.hpp.
References IRQ_VBUS_REMOVE, and isIrqSet().
Referenced by handlePmicIrq(), and printPmicIrqLine().
|
inlinestatic |
Definition at line 136 of file AXP517Irq.hpp.
References IRQ_WATCHDOG_EXPIRE, and isIrqSet().
Referenced by printPmicIrqLine().
|
overridevirtual |
Read the current IRQ status.
| clear | If true, clear PMIC IRQ and TCPC alert status after reading. |
| Combined | current IRQ status. |
Implements PmicIrqBase.
Definition at line 93 of file AXP517Irq.cpp.
References clearStatus(), SensorCommWrapper::readReg(), SensorCommWrapper::readRegBuff(), SENSORLIB_LOG_E, and axp517_regs::irq::STATUS0.
Referenced by handleIrqOnce(), and handlePmicIrq().
|
staticconstexpr |
Mask for all valid IRQ bits.
Definition at line 98 of file AXP517Irq.hpp.
|
staticconstexpr |
BAT FET Over Current Protection.
Definition at line 80 of file AXP517Irq.hpp.
Referenced by isBatFetOcp(), and setup().
|
staticconstexpr |
Battery Over Temperature in Charge mode.
Definition at line 93 of file AXP517Irq.hpp.
Referenced by isBatOverTempChg(), and setup().
|
staticconstexpr |
Battery Over Temperature Quit in Charge mode.
Definition at line 92 of file AXP517Irq.hpp.
Referenced by isBatOverTempQuitChg(), and setup().
|
staticconstexpr |
Battery Over Temperature in Work mode.
Definition at line 95 of file AXP517Irq.hpp.
Referenced by isBatOverTempWork(), and setup().
|
staticconstexpr |
Battery Over Voltage Protection.
Definition at line 85 of file AXP517Irq.hpp.
Referenced by isBatOverVoltage(), and setup().
|
staticconstexpr |
Battery Under Temperature in Charge mode.
Definition at line 94 of file AXP517Irq.hpp.
Referenced by isBatUnderTempChg(), and setup().
|
staticconstexpr |
Battery Under Temperature in Work mode.
Definition at line 96 of file AXP517Irq.hpp.
Referenced by isBatUnderTempWork(), and setup().
|
staticconstexpr |
Battery Insert.
Definition at line 69 of file AXP517Irq.hpp.
Referenced by isBatteryInsert(), and setup().
|
staticconstexpr |
Battery Remove.
Definition at line 70 of file AXP517Irq.hpp.
Referenced by isBatteryRemove(), and setup().
|
staticconstexpr |
BC1.2 detect result change.
Definition at line 91 of file AXP517Irq.hpp.
Referenced by isBc12DetectChange(), and setup().
|
staticconstexpr |
BC1.2 detect finished.
Definition at line 90 of file AXP517Irq.hpp.
Referenced by isBc12DetectFinished(), and setup().
|
staticconstexpr |
BOOST Over Voltage.
Definition at line 60 of file AXP517Irq.hpp.
Referenced by isBoostOverVoltage(), and setup().
|
staticconstexpr |
Battery charge done.
Definition at line 81 of file AXP517Irq.hpp.
Referenced by isChargeDone(), and setup().
|
staticconstexpr |
Battery charge start.
Definition at line 82 of file AXP517Irq.hpp.
Referenced by isChargeStart(), and setup().
|
staticconstexpr |
Charge to normal.
Definition at line 59 of file AXP517Irq.hpp.
Referenced by isChargeToNormal(), and setup().
|
staticconstexpr |
Charger Safety Timer1/2 expire.
Definition at line 84 of file AXP517Irq.hpp.
Referenced by isChgSafetyTimer(), and setup().
|
staticconstexpr |
DIE Over Temperature level1.
Definition at line 83 of file AXP517Irq.hpp.
Referenced by isDieOverTempLevel1(), and setup().
|
staticconstexpr |
Gauge New SOC.
Definition at line 58 of file AXP517Irq.hpp.
Referenced by isGaugeNewSoc(), and setup().
|
staticconstexpr |
PWR_ON pin Long PRESS.
Definition at line 72 of file AXP517Irq.hpp.
Referenced by isPwrOnLongPress(), and setup().
|
staticconstexpr |
PWR_ON pin Negative Edge.
Definition at line 73 of file AXP517Irq.hpp.
Referenced by isPwrOnNegativeEdge(), and setup().
|
staticconstexpr |
PWR_ON pin Positive Edge.
Definition at line 74 of file AXP517Irq.hpp.
Referenced by isPwrOnPositiveEdge(), and setup().
|
staticconstexpr |
PWR_ON pin Short PRESS.
Definition at line 71 of file AXP517Irq.hpp.
Referenced by isPwrOnShortPress(), and setup().
|
staticconstexpr |
Reserved IRQ bits.
Definition at line 99 of file AXP517Irq.hpp.
|
staticconstexpr |
SOC drop to Shutdown Level.
Definition at line 57 of file AXP517Irq.hpp.
Referenced by isSocShutdownLevel(), and setup().
|
staticconstexpr |
SOC drop to Warning Level.
Definition at line 56 of file AXP517Irq.hpp.
Referenced by isSocWarningLevel(), and setup().
|
staticconstexpr |
|
staticconstexpr |
VBUS Insert.
Definition at line 67 of file AXP517Irq.hpp.
Referenced by isVbusInsert(), and setup().
|
staticconstexpr |
VBUS Over Voltage.
Definition at line 61 of file AXP517Irq.hpp.
Referenced by isVbusOverVoltage(), and setup().
|
staticconstexpr |
VBUS Remove.
Definition at line 68 of file AXP517Irq.hpp.
Referenced by isVbusRemove(), and setup().
|
staticconstexpr |
Watchdog Expire.
Definition at line 79 of file AXP517Irq.hpp.
Referenced by isWatchdogExpire(), and setup().