|
SensorLib 0.5.0
Multi-platform sensor driver library for Arduino, PlatformIO, and ESP-IDF
|
@license MIT License More...
Go to the source code of this file.
Classes | |
| struct | StatusSnapshot |
Macros | |
| #define | PMIC_SDA 3 |
| #define | PMIC_SCL 2 |
| #define | PMIC_IRQ 44 |
Functions | |
| void | onPmicIrq () |
| const char * | bc12TypeName (PmicBc12Base::PortType type) |
| const char * | presentName (bool present) |
| const char * | attachedName (bool attached) |
| const char * | yesNoName (bool value) |
| const char * | chargeName (const StatusSnapshot &snapshot) |
| void | printHex16 (uint16_t value) |
| void | printHex32 (uint32_t value) |
| StatusSnapshot | readStatusSnapshot () |
| void | printEventItem (bool &first, const char *text) |
| void | printPdAlertLine (uint16_t pdAlert) |
| void | printPmicIrqLine (uint64_t status) |
| bool | printBoolChange (const char *label, bool before, bool after, const char *(*name)(bool), bool &first) |
| bool | printChargeChange (const StatusSnapshot &before, const StatusSnapshot &after, bool &first) |
| void | printStatusLine (const char *label, bool anyChange) |
| void | printSnapshot (const StatusSnapshot &snapshot) |
| void | printSnapshotChanges (const StatusSnapshot &before, const StatusSnapshot &after) |
| bool | handleIrqOnce () |
| void | drainIrq () |
| void | setup () |
| void | loop () |
Variables | |
| PmicAXP517 | pmic |
| volatile bool | irqTriggered = false |
| StatusSnapshot | lastSnapshot |
| uint32_t | irqCount = 0 |
@license MIT License
Copyright (c) 2026 lewis he
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Definition in file axp517_interrupt.ino.
| #define PMIC_IRQ 44 |
Definition at line 43 of file axp517_interrupt.ino.
| #define PMIC_SCL 2 |
Definition at line 39 of file axp517_interrupt.ino.
| #define PMIC_SDA 3 |
Definition at line 35 of file axp517_interrupt.ino.
| const char * attachedName | ( | bool | attached | ) |
Definition at line 99 of file axp517_interrupt.ino.
Referenced by printSnapshot(), and printSnapshotChanges().
| const char * bc12TypeName | ( | PmicBc12Base::PortType | type | ) |
Definition at line 80 of file axp517_interrupt.ino.
References PmicBc12Base::Apple_1A, PmicBc12Base::Apple_2_4A, PmicBc12Base::Apple_2A, PmicBc12Base::CDP, PmicBc12Base::DCP, PmicBc12Base::None, and PmicBc12Base::SDP.
Referenced by printSnapshot(), and printSnapshotChanges().
| const char * chargeName | ( | const StatusSnapshot & | snapshot | ) |
Definition at line 109 of file axp517_interrupt.ino.
References StatusSnapshot::chargeDone, and StatusSnapshot::charging.
Referenced by printChargeChange(), and printSnapshot().
| void drainIrq | ( | ) |
Definition at line 490 of file axp517_interrupt.ino.
References handleIrqOnce(), and PMIC_IRQ.
Referenced by loop().
| bool handleIrqOnce | ( | ) |
Definition at line 460 of file axp517_interrupt.ino.
References PmicAXP517::irq(), irqCount, lastSnapshot, pmic, PMIC_IRQ, printHex16(), printHex32(), printPdAlertLine(), printPmicIrqLine(), printSnapshotChanges(), AXP517Irq::readStatus(), and readStatusSnapshot().
Referenced by drainIrq().
| void loop | ( | ) |
Definition at line 581 of file axp517_interrupt.ino.
References drainIrq(), irqTriggered, and PMIC_IRQ.
| void onPmicIrq | ( | ) |
| const char * presentName | ( | bool | present | ) |
Definition at line 94 of file axp517_interrupt.ino.
Referenced by printSnapshot(), and printSnapshotChanges().
| bool printBoolChange | ( | const char * | label, |
| bool | before, | ||
| bool | after, | ||
| const char *(*)(bool) | name, | ||
| bool & | first | ||
| ) |
Definition at line 309 of file axp517_interrupt.ino.
Referenced by printSnapshotChanges().
| bool printChargeChange | ( | const StatusSnapshot & | before, |
| const StatusSnapshot & | after, | ||
| bool & | first | ||
| ) |
Definition at line 327 of file axp517_interrupt.ino.
References chargeName().
Referenced by printSnapshotChanges().
| void printEventItem | ( | bool & | first, |
| const char * | text | ||
| ) |
Definition at line 151 of file axp517_interrupt.ino.
Referenced by printPdAlertLine(), and printPmicIrqLine().
| void printHex16 | ( | uint16_t | value | ) |
Definition at line 116 of file axp517_interrupt.ino.
Referenced by handleIrqOnce(), printSnapshot(), and printSnapshotChanges().
| void printHex32 | ( | uint32_t | value | ) |
Definition at line 123 of file axp517_interrupt.ino.
Referenced by handleIrqOnce(), printSnapshot(), and printSnapshotChanges().
| void printPdAlertLine | ( | uint16_t | pdAlert | ) |
Definition at line 160 of file axp517_interrupt.ino.
References AXP517Tcpc::AlertCcStatus, AXP517Tcpc::AlertExtended, AXP517Tcpc::AlertExtendedStatus, AXP517Tcpc::AlertFault, AXP517Tcpc::AlertPowerStatus, AXP517Tcpc::AlertRxBufOverflow, AXP517Tcpc::AlertRxHardReset, AXP517Tcpc::AlertRxStatus, AXP517Tcpc::AlertTxDiscarded, AXP517Tcpc::AlertTxFailed, AXP517Tcpc::AlertTxSuccess, AXP517Tcpc::AlertVbusAlarmHi, AXP517Tcpc::AlertVbusAlarmLo, AXP517Tcpc::AlertVbusDisconnect, and printEventItem().
Referenced by handleIrqOnce().
| void printPmicIrqLine | ( | uint64_t | status | ) |
Definition at line 212 of file axp517_interrupt.ino.
References PmicAXP517::irq(), AXP517Irq::isBatFetOcp(), AXP517Irq::isBatOverTempChg(), AXP517Irq::isBatOverTempQuitChg(), AXP517Irq::isBatOverTempWork(), AXP517Irq::isBatOverVoltage(), AXP517Irq::isBatteryInsert(), AXP517Irq::isBatteryRemove(), AXP517Irq::isBatUnderTempChg(), AXP517Irq::isBatUnderTempWork(), AXP517Irq::isBc12DetectChange(), AXP517Irq::isBc12DetectFinished(), AXP517Irq::isBoostOverVoltage(), AXP517Irq::isChargeDone(), AXP517Irq::isChargeStart(), AXP517Irq::isChargeToNormal(), AXP517Irq::isChgSafetyTimer(), AXP517Irq::isDieOverTempLevel1(), AXP517Irq::isGaugeNewSoc(), AXP517Irq::isPwrOnLongPress(), AXP517Irq::isPwrOnNegativeEdge(), AXP517Irq::isPwrOnPositiveEdge(), AXP517Irq::isPwrOnShortPress(), AXP517Irq::isSocShutdownLevel(), AXP517Irq::isSocWarningLevel(), AXP517Irq::isVbusFault(), AXP517Irq::isVbusInsert(), AXP517Irq::isVbusOverVoltage(), AXP517Irq::isVbusRemove(), AXP517Irq::isWatchdogExpire(), pmic, and printEventItem().
Referenced by handleIrqOnce().
| void printSnapshot | ( | const StatusSnapshot & | snapshot | ) |
Definition at line 357 of file axp517_interrupt.ino.
References attachedName(), StatusSnapshot::batteryPresent, StatusSnapshot::bc12Detecting, StatusSnapshot::bc12Raw, StatusSnapshot::bc12Type, bc12TypeName(), chargeName(), StatusSnapshot::chargerFault, StatusSnapshot::chargerFaultCode, presentName(), printHex16(), printHex32(), StatusSnapshot::tcpcAttached, StatusSnapshot::tcpcVbusMv, StatusSnapshot::tcpcVbusValid, StatusSnapshot::vbusPresent, and yesNoName().
Referenced by printSnapshotChanges(), and setup().
| void printSnapshotChanges | ( | const StatusSnapshot & | before, |
| const StatusSnapshot & | after | ||
| ) |
Definition at line 392 of file axp517_interrupt.ino.
References attachedName(), StatusSnapshot::batteryPresent, StatusSnapshot::bc12Detecting, StatusSnapshot::bc12Raw, StatusSnapshot::bc12Type, bc12TypeName(), StatusSnapshot::chargerFault, StatusSnapshot::chargerFaultCode, presentName(), printBoolChange(), printChargeChange(), printHex16(), printHex32(), printSnapshot(), printStatusLine(), StatusSnapshot::tcpcAttached, StatusSnapshot::tcpcVbusMv, StatusSnapshot::tcpcVbusValid, StatusSnapshot::valid, StatusSnapshot::vbusPresent, and yesNoName().
Referenced by handleIrqOnce().
| void printStatusLine | ( | const char * | label, |
| bool | anyChange | ||
| ) |
Definition at line 346 of file axp517_interrupt.ino.
Referenced by printSnapshotChanges().
| StatusSnapshot readStatusSnapshot | ( | ) |
Definition at line 130 of file axp517_interrupt.ino.
References StatusSnapshot::batteryPresent, PmicAXP517::bc12(), StatusSnapshot::bc12Detecting, StatusSnapshot::bc12Raw, StatusSnapshot::bc12Type, StatusSnapshot::chargeDone, PmicAXP517::charger(), StatusSnapshot::chargerFault, StatusSnapshot::chargerFaultCode, StatusSnapshot::charging, AXP517Charger::getStatus(), AXP517Tcpc::isAttached(), pmic, AXP517Bc12::readResult(), AXP517Tcpc::readVbusMv(), PmicAXP517::tcpc(), StatusSnapshot::tcpcAttached, StatusSnapshot::tcpcVbusMv, StatusSnapshot::tcpcVbusValid, StatusSnapshot::valid, and StatusSnapshot::vbusPresent.
Referenced by handleIrqOnce(), and setup().
| void setup | ( | ) |
Definition at line 512 of file axp517_interrupt.ino.
References PmicAXP517::bc12(), PmicAXP517::begin(), AXP517Irq::clearStatus(), AXP517Irq::enable(), AXP517Bc12::enableAutoDetect(), PmicAXP517::enableModule(), PmicAXP517::irq(), AXP517Irq::IRQ_BAT_FET_OCP, AXP517Irq::IRQ_BAT_OVER_TEMP_CHG, AXP517Irq::IRQ_BAT_OVER_TEMP_QUIT_CHG, AXP517Irq::IRQ_BAT_OVER_TEMP_WORK, AXP517Irq::IRQ_BAT_OVER_VOLTAGE, AXP517Irq::IRQ_BAT_UNDER_TEMP_CHG, AXP517Irq::IRQ_BAT_UNDER_TEMP_WORK, AXP517Irq::IRQ_BATTERY_INSERT, AXP517Irq::IRQ_BATTERY_REMOVE, AXP517Irq::IRQ_BC12_DETECT_CHANGE, AXP517Irq::IRQ_BC12_DETECT_FINISHED, AXP517Irq::IRQ_BOOST_OVER_VOLTAGE, AXP517Irq::IRQ_CHARGE_DONE, AXP517Irq::IRQ_CHARGE_START, AXP517Irq::IRQ_CHARGE_TO_NORMAL, AXP517Irq::IRQ_CHG_SAFETY_TIMER, AXP517Irq::IRQ_DIE_OVER_TEMP_LEVEL1, AXP517Irq::IRQ_GAUGE_NEW_SOC, AXP517Irq::IRQ_PWR_ON_LONG_PRESS, AXP517Irq::IRQ_PWR_ON_NEGATIVE_EDGE, AXP517Irq::IRQ_PWR_ON_POSITIVE_EDGE, AXP517Irq::IRQ_PWR_ON_SHORT_PRESS, AXP517Irq::IRQ_SOC_SHUTDOWN_LEVEL, AXP517Irq::IRQ_SOC_WARNING_LEVEL, AXP517Irq::IRQ_VBUS_FAULT, AXP517Irq::IRQ_VBUS_INSERT, AXP517Irq::IRQ_VBUS_OVER_VOLTAGE, AXP517Irq::IRQ_VBUS_REMOVE, AXP517Irq::IRQ_WATCHDOG_EXPIRE, lastSnapshot, onPmicIrq(), pmic, PMIC_IRQ, PMIC_SCL, PMIC_SDA, printSnapshot(), and readStatusSnapshot().
| const char * yesNoName | ( | bool | value | ) |
Definition at line 104 of file axp517_interrupt.ino.
Referenced by printSnapshot(), and printSnapshotChanges().
| uint32_t irqCount = 0 |
Definition at line 73 of file axp517_interrupt.ino.
Referenced by handleIrqOnce().
| volatile bool irqTriggered = false |
Definition at line 54 of file axp517_interrupt.ino.
Referenced by loop(), and onPmicIrq().
| StatusSnapshot lastSnapshot |
Definition at line 72 of file axp517_interrupt.ino.
Referenced by handleIrqOnce(), and setup().
| PmicAXP517 pmic |
Definition at line 53 of file axp517_interrupt.ino.
Referenced by handleIrqOnce(), printPmicIrqLine(), readStatusSnapshot(), and setup().