49 snprintf(buffer,
sizeof(buffer),
"0x%016llX", value);
58 Serial.println(
"\n=== AXP2101 IRQ Example ===\n");
61 Serial.println(
"Failed to init AXP2101!");
62 while (1) delay(1000);
64 Serial.println(
"AXP2101 initialized");
84 Serial.println(
"IRQ sources enabled");
89 Serial.println(
"\n=== Setup Complete ===\n");
97 Serial.print(
"\n--- Interrupt : 0x");
99 Serial.print(
" --- ");
102 Serial.println(
"VBUS inserted");
104 Serial.println(
"VBUS removed");
106 Serial.println(
"Battery inserted");
108 Serial.println(
"Battery removed");
110 Serial.println(
"Charge started");
112 Serial.println(
"Charge done");
114 Serial.println(
"PEKEY short press");
120 Serial.println(
"LED is ON");
123 Serial.println(
"LED is OFF");
126 Serial.println(
"LED is HiZ");
129 Serial.println(
"LED is blinking at 1Hz");
132 Serial.println(
"LED is blinking at 4Hz");
138 Serial.println(
"ON LED");
141 Serial.println(
"OFF LED");
146 Serial.println(
"PEKEY long press");
148 Serial.println(
"Watchdog expired");
150 Serial.println(
"Die over-temperature");
152 Serial.println(
"LDO over-current");
154 Serial.println(
"BATFET over-current");
156 Serial.println(
"Battery over-voltage");
158 Serial.println(
"Charge timeout");
160 Serial.println(
"New SOC reading");
162 Serial.println(
"Battery over-temp (work)");
164 Serial.println(
"Battery under-temp (work)");
166 Serial.println(
"Battery charge over-temp");
168 Serial.println(
"Battery charge under-temp");
170 Serial.println(
"PEKEY negative edge");
172 Serial.println(
"PEKEY positive edge");
void printU64(uint64_t value)
static bool isBatfetOverCurr(uint64_t mask)
Check if BATFET over-current interrupt is set.
static constexpr uint64_t IRQ_PEKEY_LONG_PRESS
Power key held for a long press duration.
static bool isBatOverTempChg(uint64_t mask)
Check if battery over-temperature (charging range) interrupt is set.
static constexpr uint64_t IRQ_VBUS_REMOVE
VBUS power source removed.
static bool isPekeyShortPress(uint64_t mask)
Check if power key short press interrupt is set.
static constexpr uint64_t IRQ_BAT_CHG_START
Battery charging has started.
static bool isPekeyLongPress(uint64_t mask)
Check if power key long press interrupt is set.
static constexpr uint64_t IRQ_PEKEY_SHORT_PRESS
Power key pressed briefly (short press).
static bool isGaugeNewSoc(uint64_t mask)
Check if gauge new state-of-charge interrupt is set.
static bool isBatOverVolt(uint64_t mask)
Check if battery over-voltage interrupt is set.
static bool isWdtExpire(uint64_t mask)
Check if watchdog timer expired interrupt is set.
static bool isChgTimeout(uint64_t mask)
Check if charge timeout interrupt is set.
static bool isLdoOverCurr(uint64_t mask)
Check if LDO over-current interrupt is set.
static bool isBatInsert(uint64_t mask)
Check if battery insertion interrupt is set.
static bool isBatOverTempWork(uint64_t mask)
Check if battery over-temperature (working range) interrupt is set.
static constexpr uint64_t IRQ_VBUS_INSERT
VBUS power source inserted.
static bool isBatRemove(uint64_t mask)
Check if battery removal interrupt is set.
static bool isPkeyPositiveEdge(uint64_t mask)
Check if power key positive (rising) edge interrupt is set.
static bool isVbusInsert(uint64_t mask)
Check if VBUS insertion interrupt is set.
static bool isBatUnderTempWork(uint64_t mask)
Check if battery under-temperature (working range) interrupt is set.
static constexpr uint64_t IRQ_BAT_INSERT
Battery inserted into the system.
bool enable(uint64_t mask) override
Enable one or more interrupt sources.
static bool isVbusRemove(uint64_t mask)
Check if VBUS removal interrupt is set.
uint64_t readStatus(bool clear=true) override
Read the current interrupt status.
static constexpr uint64_t IRQ_WDT_EXPIRE
Watchdog timer expired.
static constexpr uint64_t IRQ_BAT_REMOVE
Battery removed from the system.
static bool isBatChgDone(uint64_t mask)
Check if battery charge done interrupt is set.
static constexpr uint64_t IRQ_BAT_CHG_DONE
Battery charging has completed.
static bool isPkeyNegativeEdge(uint64_t mask)
Check if power key negative (falling) edge interrupt is set.
static bool isDieOverTemp(uint64_t mask)
Check if die over-temperature interrupt is set.
bool clearStatus() override
Clear all pending interrupt status registers.
static constexpr uint64_t IRQ_DIE_OVER_TEMP
Die temperature exceeded the thermal shutdown threshold.
static bool isBatUnderTempChg(uint64_t mask)
Check if battery under-temperature (charging range) interrupt is set.
static bool isBatChgStart(uint64_t mask)
Check if battery charge start interrupt is set.
bool setManualState(ManualState state) override
For manual mode, set the LED output state.
bool setMode(Mode mode) override
Set the LED operating mode.
ManualState getManualState() override
Get the current manual LED state.
Top-level unified interface for the AXP2101 PMIC.
bool begin(SensorCommCustom::CustomCallback callback, SensorCommCustomHal::CustomHalCallback hal_cb, uint8_t addr)
Initialise the AXP2101 with custom communication callbacks.
bool enableModule(Module module, bool enable)
Enable or disable an internal functional module.
AXP2101Led & led()
Get the chip-specific LED module.
AXP2101Irq & irq()
Get the chip-specific IRQ controller.
ManualState
Manual LED state (portable subset).
@ MANUAL
Manual control through registers.