mirror of
https://github.com/meshtastic/firmware.git
synced 2025-04-24 01:16:55 +00:00
fix: device PMU shutdown (part 2) (#3596)
* fix: device PMU shutdown (part 2) * fix error + enable nimble deinit
This commit is contained in:
parent
a4a8556aa2
commit
927d07e2c6
@ -500,12 +500,7 @@ void Power::shutdown()
|
||||
{
|
||||
LOG_INFO("Shutting down\n");
|
||||
|
||||
#ifdef HAS_PMU
|
||||
if (pmu_found == true) {
|
||||
PMU->setChargingLedMode(XPOWERS_CHG_LED_OFF);
|
||||
PMU->shutdown();
|
||||
}
|
||||
#elif defined(ARCH_NRF52) || defined(ARCH_ESP32)
|
||||
#if defined(ARCH_NRF52) || defined(ARCH_ESP32)
|
||||
#ifdef PIN_LED1
|
||||
ledOff(PIN_LED1);
|
||||
#endif
|
||||
|
@ -113,8 +113,8 @@ void NimbleBluetooth::shutdown()
|
||||
pAdvertising->reset();
|
||||
pAdvertising->stop();
|
||||
|
||||
#if defined(HELTEC_WIRELESS_PAPER) || defined(HELTEC_WIRELESS_PAPER_V1_0)
|
||||
// Saving of ~1mA
|
||||
#if defined(ARCH_ESP32)
|
||||
// Saving of ~1mA for esp32-s3 and 0.1mA for esp32
|
||||
// Probably applicable to other ESP32 boards - unverified
|
||||
NimBLEDevice::deinit();
|
||||
#endif
|
||||
|
@ -245,6 +245,22 @@ void doDeepSleep(uint32_t msecToWake, bool skipPreflight = false)
|
||||
digitalWrite(VEXT_ENABLE, 1); // turn off the display power
|
||||
#endif
|
||||
|
||||
#ifdef ARCH_ESP32
|
||||
if (shouldLoraWake(msecToWake)) {
|
||||
enableLoraInterrupt();
|
||||
}
|
||||
#ifdef BUTTON_PIN
|
||||
// Avoid leakage through button pin
|
||||
pinMode(BUTTON_PIN, INPUT);
|
||||
gpio_hold_en((gpio_num_t)BUTTON_PIN);
|
||||
#endif
|
||||
|
||||
// LoRa CS (RADIO_NSS) needs to stay HIGH, even during deep sleep
|
||||
pinMode(LORA_CS, OUTPUT);
|
||||
digitalWrite(LORA_CS, HIGH);
|
||||
gpio_hold_en((gpio_num_t)LORA_CS);
|
||||
#endif
|
||||
|
||||
#ifdef HAS_PMU
|
||||
if (pmu_found && PMU) {
|
||||
// Obsolete comment: from back when we we used to receive lora packets while CPU was in deep sleep.
|
||||
@ -257,6 +273,7 @@ void doDeepSleep(uint32_t msecToWake, bool skipPreflight = false)
|
||||
// If we want to leave the radio receiving in would be 11.5mA current draw, but most of the time it is just waiting
|
||||
// in its sequencer (true?) so the average power draw should be much lower even if we were listinging for packets
|
||||
// all the time.
|
||||
PMU->setChargingLedMode(XPOWERS_CHG_LED_OFF);
|
||||
|
||||
uint8_t model = PMU->getChipModel();
|
||||
if (model == XPOWERS_AXP2101) {
|
||||
@ -271,25 +288,15 @@ void doDeepSleep(uint32_t msecToWake, bool skipPreflight = false)
|
||||
// t-beam v1.1 radio power channel
|
||||
PMU->disablePowerOutput(XPOWERS_LDO2); // lora radio power channel
|
||||
}
|
||||
if (msecToWake == portMAX_DELAY) {
|
||||
LOG_INFO("PMU shutdown.\n");
|
||||
console->flush();
|
||||
PMU->shutdown();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef ARCH_ESP32
|
||||
if (shouldLoraWake(msecToWake)) {
|
||||
enableLoraInterrupt();
|
||||
}
|
||||
|
||||
#if defined(HELTEC_WIRELESS_PAPER) || defined(HELTEC_WIRELESS_PAPER_V1_0) // Applicable to most ESP32 boards?
|
||||
// Avoid leakage through button pin
|
||||
pinMode(BUTTON_PIN, INPUT);
|
||||
rtc_gpio_hold_en((gpio_num_t)BUTTON_PIN);
|
||||
|
||||
// LoRa CS (RADIO_NSS) needs to stay HIGH, even during deep sleep
|
||||
pinMode(LORA_CS, OUTPUT);
|
||||
digitalWrite(LORA_CS, HIGH);
|
||||
rtc_gpio_hold_en((gpio_num_t)LORA_CS);
|
||||
#endif
|
||||
#endif
|
||||
console->flush();
|
||||
cpuDeepSleep(msecToWake);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user