Explorar o código

light sleep: fix Flash leakage when its CS pin has no hardware pullup

Li Shuai %!s(int64=4) %!d(string=hai) anos
pai
achega
c5b481c6da
Modificáronse 2 ficheiros con 12 adicións e 0 borrados
  1. 8 0
      components/esp_hw_support/Kconfig
  2. 4 0
      components/esp_hw_support/sleep_gpio.c

+ 8 - 0
components/esp_hw_support/Kconfig

@@ -42,5 +42,13 @@ menu "Hardware Settings"
                 increase during light sleep. If the CS pin of SPIRAM has an external
                 pull-up, you do not need to select this option, otherwise, you
                 should enable this option.
+
+        config ESP_SLEEP_FLASH_LEAKAGE_WORKAROUND
+            bool "Flash leakage current workaround in light sleep"
+            help
+                When the CS pin of Flash is not pulled up, the sleep current will
+                increase during light sleep. If the CS pin of Flash has an external
+                pull-up, you do not need to select this option, otherwise, you
+                should enable this option.
     endmenu
 endmenu

+ 4 - 0
components/esp_hw_support/sleep_gpio.c

@@ -19,6 +19,7 @@
 #include "driver/gpio.h"
 #include "esp_private/gpio.h"
 #include "esp_private/sleep_gpio.h"
+#include "bootloader_common.h"
 
 #ifdef CONFIG_IDF_TARGET_ESP32
 #include "esp32/spiram.h"
@@ -64,6 +65,9 @@ void esp_sleep_config_gpio_isolate(void)
 #if CONFIG_ESP_SLEEP_PSRAM_LEAKAGE_WORKAROUND && CONFIG_SPIRAM
     gpio_sleep_set_pull_mode(esp_spiram_get_cs_io(), GPIO_PULLUP_ONLY);
 #endif
+#if CONFIG_ESP_SLEEP_FLASH_LEAKAGE_WORKAROUND
+    gpio_sleep_set_pull_mode(bootloader_flash_get_cs_io(), GPIO_PULLUP_ONLY);
+#endif
 }
 
 void esp_sleep_enable_gpio_switch(bool enable)