docs, examples: use rtc_gpio_isolate to disconnect GPIO12

This is needed to reduce deep sleep current on ESP32-WROVER modules.

Ref TW18165.
pull/1663/head
Ivan Grokhotkov 2018-02-10 00:34:38 +08:00
rodzic f45622ff17
commit af6cfc5552
5 zmienionych plików z 32 dodań i 8 usunięć

Wyświetl plik

@ -122,6 +122,20 @@ The following function can be used to enter deep sleep once wakeup sources are c
.. doxygenfunction:: esp_deep_sleep_start
Configuring IOs
---------------
Some ESP32 IOs have internal pullups or pulldowns, which are enabled by default. If an external circuit drives this pin in deep sleep mode, current consumption may increase due to current flowing through these pullups and pulldowns.
To isolate a pin, preventing extra current draw, call :cpp:func:`rtc_gpio_isolate` function.
For example, on ESP32-WROVER module, GPIO12 is pulled up externally. GPIO12 also has an internal pulldown in the ESP32 chip. This means that in deep sleep, some current will flow through these external and internal resistors, increasing deep sleep current above the minimal possible value.
Add the following code before :cpp:func:`esp_deep_sleep_start` to remove this extra current:
```c++
rtc_gpio_isolate(GPIO_NUM_12);
```
Checking sleep wakeup cause
---------------------------

Wyświetl plik

@ -113,6 +113,7 @@ static int deep_sleep(int argc, char** argv)
ESP_ERROR_CHECK( esp_sleep_enable_ext1_wakeup(1ULL << io_num, level) );
}
rtc_gpio_isolate(GPIO_NUM_12);
esp_deep_sleep_start();
}

Wyświetl plik

@ -157,6 +157,11 @@ void app_main()
esp_sleep_enable_ulp_wakeup();
#endif
// Isolate GPIO12 pin from external circuits. This is needed for modules
// which have an external pull-up resistor on GPIO12 (such as ESP32-WROVER)
// to minimize current consumption.
rtc_gpio_isolate(GPIO_NUM_12);
printf("Entering deep sleep\n");
gettimeofday(&sleep_enter_time, NULL);

Wyświetl plik

@ -68,11 +68,13 @@ static void init_ulp_program()
rtc_gpio_pullup_dis(gpio_num);
rtc_gpio_hold_en(gpio_num);
/* Disable pullup on GPIO15, in case it is connected to ground to suppress
* boot messages.
/* Disconnect GPIO12 and GPIO15 to remove current drain through
* pullup/pulldown resistors.
* GPIO15 may be connected to ground to suppress boot messages.
* GPIO12 may be pulled high to select flash voltage.
*/
rtc_gpio_pullup_dis(GPIO_NUM_15);
rtc_gpio_hold_en(GPIO_NUM_15);
rtc_gpio_isolate(GPIO_NUM_12);
rtc_gpio_isolate(GPIO_NUM_15);
/* Set ULP wake up period to T = 20ms (3095 cycles of RTC_SLOW_CLK clock).
* Minimum pulse width has to be T * (ulp_debounce_counter + 1) = 80ms.

Wyświetl plik

@ -74,11 +74,13 @@ static void init_ulp_program()
/* Set ULP wake up period to 20ms */
ulp_set_wakeup_period(0, 20000);
/* Disable pullup on GPIO15, in case it is connected to ground to suppress
* boot messages.
/* Disconnect GPIO12 and GPIO15 to remove current drain through
* pullup/pulldown resistors.
* GPIO15 may be connected to ground to suppress boot messages.
* GPIO12 may be pulled high to select flash voltage.
*/
rtc_gpio_pullup_dis(GPIO_NUM_15);
rtc_gpio_hold_en(GPIO_NUM_15);
rtc_gpio_isolate(GPIO_NUM_12);
rtc_gpio_isolate(GPIO_NUM_15);
}
static void start_ulp_program()