SensorLib 0.5.0
Multi-platform sensor driver library for Arduino, PlatformIO, and ESP-IDF
Loading...
Searching...
No Matches
axp517_interrupt.ino
Go to the documentation of this file.
1
30#include <Arduino.h>
31#include <Wire.h>
32#include <PmicDrv.hpp>
33
34#ifndef PMIC_SDA
35#define PMIC_SDA 3
36#endif
37
38#ifndef PMIC_SCL
39#define PMIC_SCL 2
40#endif
41
42#ifndef PMIC_IRQ
43#define PMIC_IRQ 44
44#endif
45
46#if PMIC_IRQ < 0
47#error "AXP517 interrupt example requires a valid PMIC_IRQ pin."
48#endif
49
50static constexpr uint32_t IRQ_DRAIN_MS = 250;
51static constexpr uint32_t IRQ_PENDING_PRINT_MS = 1000;
52
54volatile bool irqTriggered = false;
55
57 bool valid = false;
58 bool vbusPresent = false;
59 bool batteryPresent = false;
60 bool charging = false;
61 bool chargeDone = false;
62 bool chargerFault = false;
63 uint32_t chargerFaultCode = 0;
64 bool tcpcAttached = false;
65 bool tcpcVbusValid = false;
66 uint16_t tcpcVbusMv = 0;
68 uint8_t bc12Raw = 0;
69 bool bc12Detecting = false;
70};
71
73uint32_t irqCount = 0;
74
76{
77 irqTriggered = true;
78}
79
81{
82 switch (type) {
83 case PmicBc12Base::PortType::None: return "None";
84 case PmicBc12Base::PortType::SDP: return "SDP";
85 case PmicBc12Base::PortType::CDP: return "CDP";
86 case PmicBc12Base::PortType::DCP: return "DCP";
87 case PmicBc12Base::PortType::Apple_1A: return "Apple 1A";
88 case PmicBc12Base::PortType::Apple_2A: return "Apple 2A";
89 case PmicBc12Base::PortType::Apple_2_4A: return "Apple 2.4A";
90 default: return "Unknown";
91 }
92}
93
94const char *presentName(bool present)
95{
96 return present ? "Present" : "Absent";
97}
98
99const char *attachedName(bool attached)
100{
101 return attached ? "Attached" : "Detached";
102}
103
104const char *yesNoName(bool value)
105{
106 return value ? "yes" : "no";
107}
108
109const char *chargeName(const StatusSnapshot &snapshot)
110{
111 if (snapshot.charging) return "Charging";
112 if (snapshot.chargeDone) return "Done";
113 return "Idle";
114}
115
116void printHex16(uint16_t value)
117{
118 char buffer[7];
119 snprintf(buffer, sizeof(buffer), "0x%04X", value);
120 Serial.print(buffer);
121}
122
123void printHex32(uint32_t value)
124{
125 char buffer[11];
126 snprintf(buffer, sizeof(buffer), "0x%08lX", static_cast<unsigned long>(value));
127 Serial.print(buffer);
128}
129
131{
132 StatusSnapshot snapshot;
133 auto charger = pmic.charger().getStatus();
134 auto bc12 = pmic.bc12().readResult();
135
136 snapshot.valid = true;
137 snapshot.vbusPresent = charger.vbusPresent;
138 snapshot.batteryPresent = charger.batteryPresent;
139 snapshot.charging = charger.charging;
140 snapshot.chargeDone = charger.chargeDone;
141 snapshot.chargerFault = charger.fault;
142 snapshot.chargerFaultCode = charger.faultCode;
143 snapshot.tcpcAttached = pmic.tcpc().isAttached();
144 snapshot.tcpcVbusValid = pmic.tcpc().readVbusMv(snapshot.tcpcVbusMv);
145 snapshot.bc12Type = bc12.type;
146 snapshot.bc12Raw = bc12.raw;
147 snapshot.bc12Detecting = bc12.detecting;
148 return snapshot;
149}
150
151void printEventItem(bool &first, const char *text)
152{
153 if (!first) {
154 Serial.print(", ");
155 }
156 Serial.print(text);
157 first = false;
158}
159
160void printPdAlertLine(uint16_t pdAlert)
161{
162 Serial.print(" TCPC ");
163 bool first = true;
164 if (pdAlert & AXP517Tcpc::AlertCcStatus) {
165 printEventItem(first, "CC status");
166 }
167 if (pdAlert & AXP517Tcpc::AlertPowerStatus) {
168 printEventItem(first, "Power status");
169 }
170 if (pdAlert & AXP517Tcpc::AlertRxStatus) {
171 printEventItem(first, "RX SOP message");
172 }
173 if (pdAlert & AXP517Tcpc::AlertRxHardReset) {
174 printEventItem(first, "RX hard reset");
175 }
176 if (pdAlert & AXP517Tcpc::AlertTxFailed) {
177 printEventItem(first, "TX failed");
178 }
179 if (pdAlert & AXP517Tcpc::AlertTxDiscarded) {
180 printEventItem(first, "TX discarded");
181 }
182 if (pdAlert & AXP517Tcpc::AlertTxSuccess) {
183 printEventItem(first, "TX success");
184 }
185 if (pdAlert & AXP517Tcpc::AlertVbusAlarmHi) {
186 printEventItem(first, "VBUS alarm high");
187 }
188 if (pdAlert & AXP517Tcpc::AlertVbusAlarmLo) {
189 printEventItem(first, "VBUS alarm low");
190 }
191 if (pdAlert & AXP517Tcpc::AlertFault) {
192 printEventItem(first, "Fault");
193 }
194 if (pdAlert & AXP517Tcpc::AlertRxBufOverflow) {
195 printEventItem(first, "RX buffer overflow");
196 }
197 if (pdAlert & AXP517Tcpc::AlertVbusDisconnect) {
198 printEventItem(first, "VBUS sink disconnect");
199 }
200 if (pdAlert & AXP517Tcpc::AlertExtendedStatus) {
201 printEventItem(first, "Extended status");
202 }
203 if (pdAlert & AXP517Tcpc::AlertExtended) {
204 printEventItem(first, "Extended alert");
205 }
206 if (first) {
207 Serial.print("none");
208 }
209 Serial.println();
210}
211
212void printPmicIrqLine(uint64_t status)
213{
214 Serial.print(" PMIC ");
215 bool first = true;
216 if (pmic.irq().isSocWarningLevel(status)) {
217 printEventItem(first, "SOC warning");
218 }
219 if (pmic.irq().isSocShutdownLevel(status)) {
220 printEventItem(first, "SOC shutdown");
221 }
222 if (pmic.irq().isGaugeNewSoc(status)) {
223 printEventItem(first, "Gauge new SOC");
224 }
225 if (pmic.irq().isChargeToNormal(status)) {
226 printEventItem(first, "Charge normal");
227 }
228 if (pmic.irq().isBoostOverVoltage(status)) {
229 printEventItem(first, "Boost over voltage");
230 }
231 if (pmic.irq().isVbusOverVoltage(status)) {
232 printEventItem(first, "VBUS over voltage");
233 }
234 if (pmic.irq().isVbusFault(status)) {
235 printEventItem(first, "VBUS fault");
236 }
237 if (pmic.irq().isVbusInsert(status)) {
238 printEventItem(first, "VBUS inserted");
239 }
240 if (pmic.irq().isVbusRemove(status)) {
241 printEventItem(first, "VBUS removed");
242 }
243 if (pmic.irq().isBatteryInsert(status)) {
244 printEventItem(first, "Battery inserted");
245 }
246 if (pmic.irq().isBatteryRemove(status)) {
247 printEventItem(first, "Battery removed");
248 }
249 if (pmic.irq().isPwrOnShortPress(status)) {
250 printEventItem(first, "PWRON short press");
251 }
252 if (pmic.irq().isPwrOnLongPress(status)) {
253 printEventItem(first, "PWRON long press");
254 }
255 if (pmic.irq().isPwrOnNegativeEdge(status)) {
256 printEventItem(first, "PWRON negative edge");
257 }
258 if (pmic.irq().isPwrOnPositiveEdge(status)) {
259 printEventItem(first, "PWRON positive edge");
260 }
261 if (pmic.irq().isWatchdogExpire(status)) {
262 printEventItem(first, "Watchdog expired");
263 }
264 if (pmic.irq().isBatFetOcp(status)) {
265 printEventItem(first, "Battery FET OCP");
266 }
267 if (pmic.irq().isChargeDone(status)) {
268 printEventItem(first, "Charge done");
269 }
270 if (pmic.irq().isChargeStart(status)) {
271 printEventItem(first, "Charge started");
272 }
273 if (pmic.irq().isDieOverTempLevel1(status)) {
274 printEventItem(first, "Die over temperature");
275 }
276 if (pmic.irq().isChgSafetyTimer(status)) {
277 printEventItem(first, "Charge safety timer");
278 }
279 if (pmic.irq().isBatOverVoltage(status)) {
280 printEventItem(first, "Battery over voltage");
281 }
282 if (pmic.irq().isBc12DetectFinished(status)) {
283 printEventItem(first, "BC1.2 detect finished");
284 }
285 if (pmic.irq().isBc12DetectChange(status)) {
286 printEventItem(first, "BC1.2 result changed");
287 }
288 if (pmic.irq().isBatOverTempQuitChg(status)) {
289 printEventItem(first, "Battery over temp quit charge");
290 }
291 if (pmic.irq().isBatOverTempChg(status)) {
292 printEventItem(first, "Battery over temp charge");
293 }
294 if (pmic.irq().isBatUnderTempChg(status)) {
295 printEventItem(first, "Battery under temp charge");
296 }
297 if (pmic.irq().isBatOverTempWork(status)) {
298 printEventItem(first, "Battery over temp work");
299 }
300 if (pmic.irq().isBatUnderTempWork(status)) {
301 printEventItem(first, "Battery under temp work");
302 }
303 if (first) {
304 Serial.print("none");
305 }
306 Serial.println();
307}
308
309bool printBoolChange(const char *label, bool before, bool after, const char *(*name)(bool), bool &first)
310{
311 if (before == after) {
312 return false;
313 }
314
315 if (!first) {
316 Serial.print(" | ");
317 }
318 Serial.print(label);
319 Serial.print(": ");
320 Serial.print(name(before));
321 Serial.print(" -> ");
322 Serial.print(name(after));
323 first = false;
324 return true;
325}
326
327bool printChargeChange(const StatusSnapshot &before, const StatusSnapshot &after, bool &first)
328{
329 const char *beforeName = chargeName(before);
330 const char *afterName = chargeName(after);
331 if (strcmp(beforeName, afterName) == 0) {
332 return false;
333 }
334
335 if (!first) {
336 Serial.print(" | ");
337 }
338 Serial.print("Charge: ");
339 Serial.print(beforeName);
340 Serial.print(" -> ");
341 Serial.print(afterName);
342 first = false;
343 return true;
344}
345
346void printStatusLine(const char *label, bool anyChange)
347{
348 if (!anyChange) {
349 Serial.print(" ");
350 Serial.print(label);
351 Serial.println(" no change");
352 } else {
353 Serial.println();
354 }
355}
356
357void printSnapshot(const StatusSnapshot &snapshot)
358{
359 Serial.print(" CHG VBUS=");
360 Serial.print(presentName(snapshot.vbusPresent));
361 Serial.print(" Battery=");
362 Serial.print(presentName(snapshot.batteryPresent));
363 Serial.print(" Charge=");
364 Serial.print(chargeName(snapshot));
365 Serial.print(" Fault=");
366 Serial.print(yesNoName(snapshot.chargerFault));
367 if (snapshot.chargerFault) {
368 Serial.print(" code=");
370 }
371 Serial.println();
372
373 Serial.print(" TCPC CC=");
374 Serial.print(attachedName(snapshot.tcpcAttached));
375 Serial.print(" VBUS=");
376 if (snapshot.tcpcVbusValid) {
377 Serial.print(snapshot.tcpcVbusMv);
378 Serial.print(" mV");
379 } else {
380 Serial.print("n/a");
381 }
382 Serial.println();
383
384 Serial.print(" BC1.2 Type=");
385 Serial.print(bc12TypeName(snapshot.bc12Type));
386 Serial.print(" raw=");
387 printHex16(snapshot.bc12Raw);
388 Serial.print(" detecting=");
389 Serial.println(yesNoName(snapshot.bc12Detecting));
390}
391
392void printSnapshotChanges(const StatusSnapshot &before, const StatusSnapshot &after)
393{
394 if (!before.valid) {
395 printSnapshot(after);
396 return;
397 }
398
399 Serial.print(" CHG ");
400 bool first = true;
401 printBoolChange("VBUS", before.vbusPresent, after.vbusPresent, presentName, first);
402 printBoolChange("Battery", before.batteryPresent, after.batteryPresent, presentName, first);
403 printChargeChange(before, after, first);
404 printBoolChange("Fault", before.chargerFault, after.chargerFault, yesNoName, first);
405 if (before.chargerFaultCode != after.chargerFaultCode) {
406 if (!first) Serial.print(" | ");
407 Serial.print("FaultCode: ");
409 Serial.print(" -> ");
411 first = false;
412 }
413 printStatusLine("CHG ", !first);
414
415 Serial.print(" TYPEC ");
416 first = true;
417 printBoolChange("CC", before.tcpcAttached, after.tcpcAttached, attachedName, first);
418 if (before.tcpcVbusValid != after.tcpcVbusValid ||
419 before.tcpcVbusMv != after.tcpcVbusMv) {
420 if (!first) Serial.print(" | ");
421 Serial.print("VBUS: ");
422 if (before.tcpcVbusValid) {
423 Serial.print(before.tcpcVbusMv);
424 Serial.print(" mV");
425 } else {
426 Serial.print("n/a");
427 }
428 Serial.print(" -> ");
429 if (after.tcpcVbusValid) {
430 Serial.print(after.tcpcVbusMv);
431 Serial.print(" mV");
432 } else {
433 Serial.print("n/a");
434 }
435 first = false;
436 }
437 printStatusLine("TYPEC", !first);
438
439 Serial.print(" BC1.2 ");
440 first = true;
441 if (before.bc12Type != after.bc12Type) {
442 Serial.print("Type: ");
443 Serial.print(bc12TypeName(before.bc12Type));
444 Serial.print(" -> ");
445 Serial.print(bc12TypeName(after.bc12Type));
446 first = false;
447 }
448 if (before.bc12Raw != after.bc12Raw) {
449 if (!first) Serial.print(" | ");
450 Serial.print("Raw: ");
451 printHex16(before.bc12Raw);
452 Serial.print(" -> ");
453 printHex16(after.bc12Raw);
454 first = false;
455 }
456 printBoolChange("Detecting", before.bc12Detecting, after.bc12Detecting, yesNoName, first);
457 printStatusLine("BC1.2", !first);
458}
459
461{
462 uint64_t status = pmic.irq().readStatus(true);
463 if (status == 0) {
464 return false;
465 }
466
468
469 Serial.println();
470 Serial.print("[");
471 Serial.print(millis());
472 Serial.print(" ms] IRQ #");
473 Serial.println(++irqCount);
474
475 Serial.print(" RAW pd=");
476 printHex16(static_cast<uint16_t>(status >> 32));
477 Serial.print(" pmic=");
478 printHex32(static_cast<uint32_t>(status));
479 Serial.print(" pin=");
480 Serial.println(digitalRead(PMIC_IRQ) == LOW ? "LOW" : "HIGH");
481
482 printPmicIrqLine(status);
483 printPdAlertLine(static_cast<uint16_t>(status >> 32));
485 Serial.println();
486 lastSnapshot = snapshot;
487 return true;
488}
489
491{
492 uint32_t start = millis();
493
494 do {
495 bool handled = handleIrqOnce();
496 delay(2);
497
498 if (digitalRead(PMIC_IRQ) != LOW) {
499 return;
500 }
501
502 if (!handled) {
503 return;
504 }
505 } while (millis() - start < IRQ_DRAIN_MS);
506
507 if (digitalRead(PMIC_IRQ) == LOW) {
508 Serial.println("PMIC_IRQ is still LOW after drain.");
509 }
510}
511
512void setup()
513{
514 Serial.begin(115200);
515 delay(500);
516
517 Serial.println("\n=== AXP517 Interrupt Example ===\n");
518
519 if (!pmic.begin(Wire, AXP517_SLAVE_ADDRESS, PMIC_SDA, PMIC_SCL, PMIC_IRQ)) {
520 Serial.println("Failed to init AXP517 or PMIC_IRQ pin!");
521 while (1) delay(1000);
522 }
523
524 pmic.enableModule(PmicAXP517::Module::CHARGE, true);
525 pmic.enableModule(PmicAXP517::Module::BC12, true);
526 pmic.bc12().enableAutoDetect(true);
527
528 uint64_t mask =
558
559 if (!pmic.irq().enable(mask)) {
560 Serial.println("Failed to enable AXP517 IRQ mask.");
561 }
562 if (!pmic.irq().clearStatus()) {
563 Serial.println("Failed to clear AXP517 IRQ status.");
564 }
565
566 pinMode(PMIC_IRQ, INPUT_PULLUP);
567 attachInterrupt(PMIC_IRQ, onPmicIrq, FALLING);
568
569 Serial.print("SDA: ");
570 Serial.println(PMIC_SDA);
571 Serial.print("SCL: ");
572 Serial.println(PMIC_SCL);
573 Serial.print("PMIC_IRQ: ");
574 Serial.println(PMIC_IRQ);
576 Serial.println("\nInitial status:");
578 Serial.println("\nWaiting for AXP517 interrupts...");
579}
580
581void loop()
582{
583 static uint32_t lastPendingPrint = 0;
584
585 if (irqTriggered || digitalRead(PMIC_IRQ) == LOW) {
586 if (irqTriggered) {
587 Serial.println("\nIRQ Triggered");
588 } else if (millis() - lastPendingPrint > IRQ_PENDING_PRINT_MS) {
589 lastPendingPrint = millis();
590 Serial.println("\nIRQ Pending");
591 }
592
593 irqTriggered = false;
594 drainIrq();
595 }
596
597 delay(20);
598}
@license MIT License
PmicAXP517 pmic
#define PMIC_SDA
void printSnapshot(const StatusSnapshot &snapshot)
uint32_t irqCount
StatusSnapshot readStatusSnapshot()
const char * attachedName(bool attached)
bool printBoolChange(const char *label, bool before, bool after, const char *(*name)(bool), bool &first)
#define PMIC_SCL
const char * bc12TypeName(PmicBc12Base::PortType type)
void drainIrq()
void setup()
#define PMIC_IRQ
void printStatusLine(const char *label, bool anyChange)
void printHex16(uint16_t value)
bool handleIrqOnce()
bool printChargeChange(const StatusSnapshot &before, const StatusSnapshot &after, bool &first)
StatusSnapshot lastSnapshot
void printHex32(uint32_t value)
const char * presentName(bool present)
void printEventItem(bool &first, const char *text)
volatile bool irqTriggered
const char * chargeName(const StatusSnapshot &snapshot)
void printPmicIrqLine(uint64_t status)
void onPmicIrq()
const char * yesNoName(bool value)
void printPdAlertLine(uint16_t pdAlert)
void printSnapshotChanges(const StatusSnapshot &before, const StatusSnapshot &after)
void loop()
Result readResult() override
Read the current BC1.2 detection result.
bool enableAutoDetect(bool enable) override
Enable or disable automatic BC1.2 detection.
Status getStatus() override
Get current charger status (best-effort).
static constexpr uint64_t IRQ_CHARGE_START
Battery charge start.
Definition AXP517Irq.hpp:82
static bool isChargeToNormal(uint64_t mask)
static bool isBc12DetectFinished(uint64_t mask)
bool enable(uint64_t mask) override
Enable one or more PMIC IRQ sources.
Definition AXP517Irq.cpp:41
static bool isPwrOnShortPress(uint64_t mask)
static constexpr uint64_t IRQ_VBUS_FAULT
VBUS Fault.
Definition AXP517Irq.hpp:62
static constexpr uint64_t IRQ_BAT_UNDER_TEMP_CHG
Battery Under Temperature in Charge mode.
Definition AXP517Irq.hpp:94
static constexpr uint64_t IRQ_CHG_SAFETY_TIMER
Charger Safety Timer1/2 expire.
Definition AXP517Irq.hpp:84
static bool isBatteryRemove(uint64_t mask)
static bool isBatFetOcp(uint64_t mask)
static bool isBatOverTempWork(uint64_t mask)
static constexpr uint64_t IRQ_VBUS_REMOVE
VBUS Remove.
Definition AXP517Irq.hpp:68
static constexpr uint64_t IRQ_DIE_OVER_TEMP_LEVEL1
DIE Over Temperature level1.
Definition AXP517Irq.hpp:83
static bool isWatchdogExpire(uint64_t mask)
static bool isDieOverTempLevel1(uint64_t mask)
static constexpr uint64_t IRQ_VBUS_INSERT
VBUS Insert.
Definition AXP517Irq.hpp:67
static constexpr uint64_t IRQ_BATTERY_INSERT
Battery Insert.
Definition AXP517Irq.hpp:69
static constexpr uint64_t IRQ_BAT_FET_OCP
BAT FET Over Current Protection.
Definition AXP517Irq.hpp:80
static constexpr uint64_t IRQ_GAUGE_NEW_SOC
Gauge New SOC.
Definition AXP517Irq.hpp:58
static bool isSocShutdownLevel(uint64_t mask)
static bool isBatteryInsert(uint64_t mask)
static bool isBatOverTempQuitChg(uint64_t mask)
static constexpr uint64_t IRQ_CHARGE_DONE
Battery charge done.
Definition AXP517Irq.hpp:81
static constexpr uint64_t IRQ_PWR_ON_NEGATIVE_EDGE
PWR_ON pin Negative Edge.
Definition AXP517Irq.hpp:73
static bool isVbusFault(uint64_t mask)
static constexpr uint64_t IRQ_BC12_DETECT_FINISHED
BC1.2 detect finished.
Definition AXP517Irq.hpp:90
static constexpr uint64_t IRQ_BATTERY_REMOVE
Battery Remove.
Definition AXP517Irq.hpp:70
static bool isChgSafetyTimer(uint64_t mask)
static bool isBatUnderTempWork(uint64_t mask)
static constexpr uint64_t IRQ_CHARGE_TO_NORMAL
Charge to normal.
Definition AXP517Irq.hpp:59
static constexpr uint64_t IRQ_WATCHDOG_EXPIRE
Watchdog Expire.
Definition AXP517Irq.hpp:79
static constexpr uint64_t IRQ_PWR_ON_SHORT_PRESS
PWR_ON pin Short PRESS.
Definition AXP517Irq.hpp:71
static bool isBatUnderTempChg(uint64_t mask)
static bool isChargeDone(uint64_t mask)
static bool isSocWarningLevel(uint64_t mask)
static bool isVbusInsert(uint64_t mask)
static constexpr uint64_t IRQ_BAT_OVER_TEMP_CHG
Battery Over Temperature in Charge mode.
Definition AXP517Irq.hpp:93
uint64_t readStatus(bool clear=true) override
Read the current IRQ status.
Definition AXP517Irq.cpp:93
static constexpr uint64_t IRQ_VBUS_OVER_VOLTAGE
VBUS Over Voltage.
Definition AXP517Irq.hpp:61
static bool isVbusOverVoltage(uint64_t mask)
static bool isGaugeNewSoc(uint64_t mask)
static constexpr uint64_t IRQ_PWR_ON_LONG_PRESS
PWR_ON pin Long PRESS.
Definition AXP517Irq.hpp:72
static constexpr uint64_t IRQ_BC12_DETECT_CHANGE
BC1.2 detect result change.
Definition AXP517Irq.hpp:91
static constexpr uint64_t IRQ_BAT_OVER_VOLTAGE
Battery Over Voltage Protection.
Definition AXP517Irq.hpp:85
static bool isPwrOnPositiveEdge(uint64_t mask)
static constexpr uint64_t IRQ_BAT_UNDER_TEMP_WORK
Battery Under Temperature in Work mode.
Definition AXP517Irq.hpp:96
static bool isBc12DetectChange(uint64_t mask)
bool clearStatus() override
Clear all pending PMIC IRQ and TCPC alert status bits.
static bool isBatOverVoltage(uint64_t mask)
static bool isChargeStart(uint64_t mask)
static bool isVbusRemove(uint64_t mask)
static constexpr uint64_t IRQ_BAT_OVER_TEMP_QUIT_CHG
Battery Over Temperature Quit in Charge mode.
Definition AXP517Irq.hpp:92
static constexpr uint64_t IRQ_SOC_SHUTDOWN_LEVEL
SOC drop to Shutdown Level.
Definition AXP517Irq.hpp:57
static bool isPwrOnLongPress(uint64_t mask)
static bool isBatOverTempChg(uint64_t mask)
static bool isPwrOnNegativeEdge(uint64_t mask)
static constexpr uint64_t IRQ_SOC_WARNING_LEVEL
SOC drop to Warning Level.
Definition AXP517Irq.hpp:56
static constexpr uint64_t IRQ_BAT_OVER_TEMP_WORK
Battery Over Temperature in Work mode.
Definition AXP517Irq.hpp:95
static bool isBoostOverVoltage(uint64_t mask)
static constexpr uint64_t IRQ_PWR_ON_POSITIVE_EDGE
PWR_ON pin Positive Edge.
Definition AXP517Irq.hpp:74
static constexpr uint64_t IRQ_BOOST_OVER_VOLTAGE
BOOST Over Voltage.
Definition AXP517Irq.hpp:60
bool isAttached()
Check whether either CC pin indicates attachment.
@ AlertExtendedStatus
EXTENDED_STATUS register changed.
@ AlertTxFailed
Message transmission failed.
@ AlertPowerStatus
POWER_STATUS register changed.
@ AlertExtended
ALERT_EXTENDED register changed.
@ AlertTxSuccess
Message transmission completed.
@ AlertRxHardReset
Hard Reset received.
@ AlertVbusAlarmHi
VBUS high-voltage alarm.
@ AlertRxStatus
RX buffer contains a SOP message.
@ AlertTxDiscarded
Transmission discarded due to RX activity.
@ AlertVbusAlarmLo
VBUS low-voltage alarm.
@ AlertRxBufOverflow
RX buffer overflow.
@ AlertFault
TCPC fault status changed.
@ AlertVbusDisconnect
VBUS sink disconnect threshold crossed.
@ AlertCcStatus
CC_STATUS register changed.
bool readVbusMv(uint16_t &mv)
Read TCPC VBUS ADC value.
High-level driver facade for the X-Powers AXP517 PMIC.
AXP517Tcpc & tcpc()
Access the low-level AXP517 TCPC helper.
bool enableModule(Module module, bool enable)
Enable or disable a functional module.
AXP517Bc12 & bc12()
Access the AXP517 BC1.2 driver.
AXP517Charger & charger()
Access the AXP517 charger driver.
bool begin(SensorCommCustom::CustomCallback callback, SensorCommCustomHal::CustomHalCallback hal_cb, uint8_t addr)
Initialization using a custom communication interface.
AXP517Irq & irq()
Access the AXP517 IRQ driver.
PortType
Common detected port/source type.
@ SDP
Standard Downstream Port (USB 500mA/900mA)
@ None
no valid detection / not connected
@ DCP
Dedicated Charging Port.
@ CDP
Charging Downstream Port.
PmicBc12Base::PortType bc12Type