|
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.
Macros | |
| #define | PMIC_SDA 3 |
| #define | PMIC_SCL 2 |
| #define | PMIC_IRQ 44 |
| #define | PD_TARGET_MV 9000 |
| #define | PD_TIMEOUT_MS 6000 |
Functions | |
| void | onPmicIrq () |
| void | printSourceCaps (const AXP517PdNegotiator::SourceCaps &caps) |
| void | printIrqStatus (uint64_t status) |
| void | printVbus () |
| bool | isVbusPresentNow () |
| bool | waitForVbusPresent (uint32_t timeoutMs) |
| bool | isTcpcDetachAlert (uint64_t irqStatus, bool vbusPresent) |
| bool | isTcpcSourceActivityAlert (uint64_t irqStatus) |
| bool | isTcpcFaultAlert (uint64_t irqStatus) |
| bool | isStickyTcpcAlert (uint64_t irqStatus) |
| void | resetPdState (const char *reason) |
| void | requestPdVoltage () |
| bool | handlePmicIrq () |
| void | drainPmicIrq () |
| void | setup () |
| void | loop () |
Variables | |
| PmicAXP517 | pmic |
| AXP517PdNegotiator::SourceCaps | sourceCaps |
| volatile bool | irqTriggered = false |
| bool | pdReady = false |
@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_pd_auto_request.ino.
| #define PD_TARGET_MV 9000 |
Definition at line 47 of file axp517_pd_auto_request.ino.
| #define PD_TIMEOUT_MS 6000 |
Definition at line 51 of file axp517_pd_auto_request.ino.
| #define PMIC_IRQ 44 |
Definition at line 43 of file axp517_pd_auto_request.ino.
| #define PMIC_SCL 2 |
Definition at line 39 of file axp517_pd_auto_request.ino.
| #define PMIC_SDA 3 |
Definition at line 35 of file axp517_pd_auto_request.ino.
| void drainPmicIrq | ( | ) |
Definition at line 307 of file axp517_pd_auto_request.ino.
References handlePmicIrq(), and PMIC_IRQ.
Referenced by loop().
| bool handlePmicIrq | ( | ) |
Definition at line 233 of file axp517_pd_auto_request.ino.
References PmicAXP517::irq(), AXP517Irq::isBatteryInsert(), AXP517Irq::isBatteryRemove(), AXP517Irq::isPwrOnShortPress(), isStickyTcpcAlert(), isTcpcDetachAlert(), isTcpcFaultAlert(), isTcpcSourceActivityAlert(), AXP517Irq::isVbusInsert(), isVbusPresentNow(), AXP517Irq::isVbusRemove(), pdReady, pmic, printIrqStatus(), AXP517Irq::readStatus(), requestPdVoltage(), resetPdState(), and waitForVbusPresent().
Referenced by drainPmicIrq().
| bool isStickyTcpcAlert | ( | uint64_t | irqStatus | ) |
Definition at line 181 of file axp517_pd_auto_request.ino.
References AXP517Tcpc::AlertCcStatus, AXP517Tcpc::AlertPowerStatus, AXP517Tcpc::AlertRxHardReset, AXP517Tcpc::AlertRxStatus, AXP517Tcpc::AlertTxDiscarded, AXP517Tcpc::AlertTxFailed, AXP517Tcpc::AlertTxSuccess, and AXP517Tcpc::AlertVbusDisconnect.
Referenced by handlePmicIrq().
| bool isTcpcDetachAlert | ( | uint64_t | irqStatus, |
| bool | vbusPresent | ||
| ) |
Definition at line 145 of file axp517_pd_auto_request.ino.
References AXP517Tcpc::AlertCcStatus, AXP517Tcpc::AlertPowerStatus, AXP517Tcpc::AlertVbusDisconnect, AXP517Tcpc::isAttached(), pmic, and PmicAXP517::tcpc().
Referenced by handlePmicIrq().
| bool isTcpcFaultAlert | ( | uint64_t | irqStatus | ) |
Definition at line 175 of file axp517_pd_auto_request.ino.
References AXP517Tcpc::AlertFault.
Referenced by handlePmicIrq().
| bool isTcpcSourceActivityAlert | ( | uint64_t | irqStatus | ) |
Definition at line 168 of file axp517_pd_auto_request.ino.
References AXP517Tcpc::AlertPowerStatus, and AXP517Tcpc::AlertRxStatus.
Referenced by handlePmicIrq().
| bool isVbusPresentNow | ( | ) |
Definition at line 117 of file axp517_pd_auto_request.ino.
References PmicAXP517::charger(), AXP517Charger::getStatus(), AXP517Tcpc::isVbusPresent(), pmic, AXP517Tcpc::readVbusMv(), PmicAXP517::tcpc(), and PmicChargerBase::Status::vbusPresent.
Referenced by handlePmicIrq(), and waitForVbusPresent().
| void loop | ( | ) |
Definition at line 364 of file axp517_pd_auto_request.ino.
References drainPmicIrq(), irqTriggered, pdReady, PMIC_IRQ, and printVbus().
| void onPmicIrq | ( | ) |
Definition at line 68 of file axp517_pd_auto_request.ino.
References irqTriggered.
Referenced by setup().
| void printIrqStatus | ( | uint64_t | status | ) |
Definition at line 98 of file axp517_pd_auto_request.ino.
Referenced by handlePmicIrq().
| void printSourceCaps | ( | const AXP517PdNegotiator::SourceCaps & | caps | ) |
Definition at line 73 of file axp517_pd_auto_request.ino.
References AXP517PdNegotiator::SourceCaps::fixed, AXP517PdNegotiator::SourceCaps::fixedCount, i, and AXP517PdNegotiator::SourceCaps::totalPdoCount.
Referenced by requestPdVoltage().
| void printVbus | ( | ) |
Definition at line 106 of file axp517_pd_auto_request.ino.
References pmic, AXP517Tcpc::readVbusMv(), and PmicAXP517::tcpc().
Referenced by loop(), and requestPdVoltage().
| void requestPdVoltage | ( | ) |
Definition at line 211 of file axp517_pd_auto_request.ino.
References AXP517Irq::clearStatus(), PmicAXP517::irq(), PD_TARGET_MV, PD_TIMEOUT_MS, pdReady, pmic, printSourceCaps(), printVbus(), PmicAXP517::requestPd(), and sourceCaps.
Referenced by handlePmicIrq(), and setup().
| void resetPdState | ( | const char * | reason | ) |
Definition at line 198 of file axp517_pd_auto_request.ino.
References AXP517Irq::clearStatus(), AXP517Tcpc::clearTx(), PmicAXP517::irq(), PmicAXP517::pd(), pdReady, pmic, AXP517PdNegotiator::reset(), sourceCaps, and PmicAXP517::tcpc().
Referenced by handlePmicIrq().
| void setup | ( | ) |
Definition at line 329 of file axp517_pd_auto_request.ino.
References PmicAXP517::begin(), PmicAXP517::charger(), AXP517Irq::clearStatus(), AXP517Irq::enable(), AXP517Charger::getStatus(), PmicAXP517::irq(), AXP517Irq::IRQ_BATTERY_INSERT, AXP517Irq::IRQ_BATTERY_REMOVE, AXP517Irq::IRQ_PWR_ON_SHORT_PRESS, AXP517Irq::IRQ_VBUS_INSERT, AXP517Irq::IRQ_VBUS_REMOVE, onPmicIrq(), PD_TARGET_MV, pmic, PMIC_IRQ, PMIC_SCL, PMIC_SDA, requestPdVoltage(), and PmicChargerBase::Status::vbusPresent.
| bool waitForVbusPresent | ( | uint32_t | timeoutMs | ) |
Definition at line 131 of file axp517_pd_auto_request.ino.
References isVbusPresentNow().
Referenced by handlePmicIrq().
| volatile bool irqTriggered = false |
Definition at line 61 of file axp517_pd_auto_request.ino.
Referenced by loop(), and onPmicIrq().
| bool pdReady = false |
Definition at line 62 of file axp517_pd_auto_request.ino.
Referenced by handlePmicIrq(), loop(), requestPdVoltage(), and resetPdState().
| PmicAXP517 pmic |
Definition at line 58 of file axp517_pd_auto_request.ino.
Referenced by handlePmicIrq(), isTcpcDetachAlert(), isVbusPresentNow(), printVbus(), requestPdVoltage(), resetPdState(), and setup().
| AXP517PdNegotiator::SourceCaps sourceCaps |
Definition at line 59 of file axp517_pd_auto_request.ino.
Referenced by requestPdVoltage(), and resetPdState().