From 7854a22fbfe03e55ae48cc0b05034c3230c6deaf Mon Sep 17 00:00:00 2001 From: Kevin Hester Date: Tue, 6 Oct 2020 12:45:19 +0800 Subject: [PATCH] bug #376 - stop using pmu IRQ - we don't need it and it causes LS wakes --- docs/software/gps-todo.txt | 4 ++-- src/Power.cpp | 7 +++++-- src/configuration.h | 5 +++-- src/sleep.cpp | 4 ++-- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/docs/software/gps-todo.txt b/docs/software/gps-todo.txt index 52d52f30..e3949ac2 100644 --- a/docs/software/gps-todo.txt +++ b/docs/software/gps-todo.txt @@ -6,9 +6,9 @@ bin/run.sh --set region 8 time only mode ./bin/run.sh --set gps_operation 3 -fix wake behavior when message arrives on lora +record power measurements and update spreadsheet -do new power measurements +fix uart wake from sleep fix has_gps based on new logic diff --git a/src/Power.cpp b/src/Power.cpp index bb89dda6..90e98816 100644 --- a/src/Power.cpp +++ b/src/Power.cpp @@ -204,8 +204,11 @@ bool Power::axp192Init() PMU_IRQ, [] { pmu_irq = true; }, FALLING); axp.adc1Enable(AXP202_BATT_CUR_ADC1, 1); - axp.enableIRQ(AXP202_BATT_REMOVED_IRQ | AXP202_BATT_CONNECT_IRQ | AXP202_CHARGING_FINISHED_IRQ | AXP202_CHARGING_IRQ | - AXP202_VBUS_REMOVED_IRQ | AXP202_VBUS_CONNECT_IRQ | AXP202_PEK_SHORTPRESS_IRQ, + // we do not look for AXP202_CHARGING_FINISHED_IRQ & AXP202_CHARGING_IRQ because it occurs repeatedly while there is + // no battery also it could cause inadvertent waking from light sleep just because the battery filled + // we don't look for AXP202_BATT_REMOVED_IRQ because it occurs repeatedly while no battery installed + // we don't look at AXP202_VBUS_REMOVED_IRQ because we don't have anything hooked to vbus + axp.enableIRQ(AXP202_BATT_CONNECT_IRQ | AXP202_VBUS_CONNECT_IRQ | AXP202_PEK_SHORTPRESS_IRQ, 1); axp.clearIRQ(); diff --git a/src/configuration.h b/src/configuration.h index 96c44a99..504a7aad 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -190,8 +190,9 @@ along with this program. If not, see . // code) #endif -// Leave undefined to disable our PMU IRQ handler -#define PMU_IRQ 35 +// Leave undefined to disable our PMU IRQ handler. DO NOT ENABLE THIS because the pmuirq can cause sperious interrupts +// and waking from light sleep +// #define PMU_IRQ 35 #define AXP192_SLAVE_ADDRESS 0x34 #elif defined(TBEAM_V07) diff --git a/src/sleep.cpp b/src/sleep.cpp index e96fe512..9503be32 100644 --- a/src/sleep.cpp +++ b/src/sleep.cpp @@ -176,7 +176,7 @@ void doDeepSleep(uint64_t msecToWake) // axp.setPowerOutPut(AXP192_LDO2, AXP202_OFF); // LORA radio - // now done by UBloxGPS.cpp + // now done by UBloxGPS.cpp // setGPSPower(false); } #endif @@ -275,7 +275,7 @@ esp_sleep_wakeup_cause_t doLightSleep(uint64_t sleepMsec) // FIXME, use a more r gpio_wakeup_enable((gpio_num_t)RF95_IRQ_GPIO, GPIO_INTR_HIGH_LEVEL); // RF95 interrupt, active high #endif #ifdef PMU_IRQ - // FIXME, disable wake due to PMU because it seems to fire all the time? + // wake due to PMU can happen repeatedly if there is no battery installed or the battery fills if (axp192_found) gpio_wakeup_enable((gpio_num_t)PMU_IRQ, GPIO_INTR_LOW_LEVEL); // pmu irq #endif