mirror of
https://github.com/meshtastic/firmware.git
synced 2025-02-02 02:39:57 +00:00
Add some explanations about PMU and prevent null pointer judgment
This commit is contained in:
parent
35c77ef99c
commit
7d0e16d1b6
@ -391,6 +391,12 @@ bool Power::axpChipInit()
|
||||
}
|
||||
|
||||
if (!PMU) {
|
||||
/*
|
||||
* In XPowersLib, if the XPowersAXPxxx object is released, Wire.end() will be called at the same time.
|
||||
* In order not to affect other devices, if the initialization of the PMU fails, Wire needs to be re-initialized once,
|
||||
* if there are multiple devices sharing the bus.
|
||||
* * */
|
||||
Wire.begin(I2C_SDA, I2C_SCL);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -427,16 +433,6 @@ bool Power::axpChipInit()
|
||||
//disable all axp chip interrupt
|
||||
PMU->disableIRQ(XPOWERS_AXP192_ALL_IRQ);
|
||||
|
||||
/*
|
||||
PMU->enableIRQ(XPOWERS_AXP192_VBUS_REMOVE_IRQ |
|
||||
XPOWERS_AXP192_VBUS_INSERT_IRQ |
|
||||
XPOWERS_AXP192_BAT_CHG_DONE_IRQ |
|
||||
XPOWERS_AXP192_BAT_CHG_START_IRQ |
|
||||
XPOWERS_AXP192_BAT_REMOVE_IRQ |
|
||||
XPOWERS_AXP192_BAT_INSERT_IRQ |
|
||||
XPOWERS_AXP192_PKEY_SHORT_IRQ
|
||||
);
|
||||
*/
|
||||
|
||||
if(config.power.charge_current == Config_PowerConfig_ChargeCurrent_MAUnset){
|
||||
config.power.charge_current = Config_PowerConfig_ChargeCurrent_MA450;
|
||||
|
@ -3,7 +3,7 @@
|
||||
#include <Wire.h>
|
||||
#include "mesh/generated/telemetry.pb.h"
|
||||
|
||||
|
||||
// AXP192 and AXP2101 have the same device address, we just need to identify it in Power.cpp
|
||||
#ifndef XPOWERS_AXP192_AXP2101_ADDRESS
|
||||
#define XPOWERS_AXP192_AXP2101_ADDRESS 0x34
|
||||
#endif
|
||||
|
@ -79,7 +79,7 @@ void setLed(bool ledOn)
|
||||
#endif
|
||||
|
||||
#ifdef HAS_PMU
|
||||
if (pmu_found) {
|
||||
if (pmu_found && PMU) {
|
||||
// blink the axp led
|
||||
PMU->setChargingLedMode(ledOn ? XPOWERS_CHG_LED_ON : XPOWERS_CHG_LED_OFF);
|
||||
}
|
||||
@ -91,12 +91,15 @@ void setGPSPower(bool on)
|
||||
DEBUG_MSG("Setting GPS power=%d\n", on);
|
||||
|
||||
#ifdef HAS_PMU
|
||||
if (pmu_found){
|
||||
#ifdef LILYGO_TBEAM_S3_CORE
|
||||
on ? PMU->enablePowerOutput(XPOWERS_ALDO4) : PMU->disablePowerOutput(XPOWERS_ALDO4);
|
||||
#else
|
||||
on ? PMU->enablePowerOutput(XPOWERS_LDO3) : PMU->disablePowerOutput(XPOWERS_LDO3);
|
||||
#endif /*LILYGO_TBEAM_S3_CORE*/
|
||||
if (pmu_found && PMU){
|
||||
uint8_t model = PMU->getChipModel();
|
||||
if(model == XPOWERS_AXP2101){
|
||||
// t-beam-s3-core GNSS power channel
|
||||
on ? PMU->enablePowerOutput(XPOWERS_ALDO4) : PMU->disablePowerOutput(XPOWERS_ALDO4);
|
||||
}else if(model == XPOWERS_AXP192){
|
||||
// t-beam GNSS power channel
|
||||
on ? PMU->enablePowerOutput(XPOWERS_LDO3) : PMU->disablePowerOutput(XPOWERS_LDO3);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -191,7 +194,7 @@ void doDeepSleep(uint64_t msecToWake)
|
||||
#endif
|
||||
|
||||
#ifdef HAS_PMU
|
||||
if (pmu_found) {
|
||||
if (pmu_found && PMU) {
|
||||
// Obsolete comment: from back when we we used to receive lora packets while CPU was in deep sleep.
|
||||
// We no longer do that, because our light-sleep current draws are low enough and it provides fast start/low cost
|
||||
// wake. We currently use deep sleep only for 'we want our device to actually be off - because our battery is
|
||||
@ -203,11 +206,12 @@ void doDeepSleep(uint64_t msecToWake)
|
||||
// in its sequencer (true?) so the average power draw should be much lower even if we were listinging for packets
|
||||
// all the time.
|
||||
|
||||
#ifdef LILYGO_TBEAM_S3_CORE
|
||||
PMU->disablePowerOutput(XPOWERS_ALDO3); // lora radio power channel
|
||||
#else
|
||||
PMU->disablePowerOutput(XPOWERS_LDO2); // lora radio power channel
|
||||
#endif /*LILYGO_TBEAM_S3_CORE*/
|
||||
uint8_t model = PMU->getChipModel();
|
||||
if(model == XPOWERS_AXP2101){
|
||||
PMU->disablePowerOutput(XPOWERS_ALDO3); // lora radio power channel
|
||||
}else if(model == XPOWERS_AXP192){
|
||||
PMU->disablePowerOutput(XPOWERS_LDO2); // lora radio power channel
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user