Merge branch 'bugfix/bootloader_disable_sar_test_mux' into 'master'

Deep sleep fixes

This change fixes extra 24 uA current consumption in deep sleep mode (https://esp32.com/viewtopic.php?f=2&t=1133).

Recent update to libphy/librtc caused another problem that WiFi related parts of RTC are no longer disabled by RTC sleep functions. This means that if WiFi is not disabled by the application before entering deep sleep, extra ~200uA of current would be consumed. This is fixed, and documentation for esp_deep_sleep and SNTP example are updated to mention that applications should take care of disabling WiFi and BT before going into the deep sleep mode.

See merge request !516
This commit is contained in:
Ivan Grokhotkov
2017-02-22 14:32:32 +08:00
4 changed files with 22 additions and 0 deletions

View File

@@ -135,4 +135,8 @@ void bootloader_random_disable(void)
/* Reset i2s peripheral */
SET_PERI_REG_MASK(DPORT_PERIP_RST_EN_REG, DPORT_I2S0_RST);
CLEAR_PERI_REG_MASK(DPORT_PERIP_RST_EN_REG, DPORT_I2S0_RST);
/* Disable pull supply voltage to SAR ADC */
CLEAR_PERI_REG_MASK(RTC_CNTL_TEST_MUX_REG, RTC_CNTL_ENT_RTC);
SET_PERI_REG_BITS(RTC_CNTL_TEST_MUX_REG, RTC_CNTL_DTEST_RTC, 0, RTC_CNTL_DTEST_RTC_S);
}

View File

@@ -22,6 +22,7 @@
#include "rom/uart.h"
#include "soc/cpu.h"
#include "soc/rtc_cntl_reg.h"
#include "soc/sens_reg.h"
#include "soc/dport_reg.h"
#include "driver/rtc_io.h"
#include "freertos/FreeRTOS.h"
@@ -111,6 +112,13 @@ void IRAM_ATTR esp_deep_sleep_start()
// Decide which power domains can be powered down
uint32_t pd_flags = get_power_down_flags();
// Shut down parts of RTC which may have been left enabled by the wireless drivers
CLEAR_PERI_REG_MASK(RTC_CNTL_ANA_CONF_REG,
RTC_CNTL_CKGEN_I2C_PU | RTC_CNTL_PLL_I2C_PU |
RTC_CNTL_RFRX_PBUS_PU | RTC_CNTL_TXRF_I2C_PU);
SET_PERI_REG_BITS(SENS_SAR_MEAS_WAIT2_REG, SENS_FORCE_XPD_SAR_M, 0, SENS_FORCE_XPD_SAR_S);
// Configure pins for external wakeup
if (s_config.wakeup_triggers & EXT_EVENT0_TRIG_EN) {
ext0_wakeup_prepare();

View File

@@ -164,6 +164,14 @@ void esp_deep_sleep_start() __attribute__((noreturn));
* Call to this function is equivalent to a call to esp_deep_sleep_enable_timer_wakeup
* followed by a call to esp_deep_sleep_start.
*
* esp_deep_sleep does not shut down WiFi, BT, and higher level protocol
* connections gracefully.
* Make sure relevant WiFi and BT stack functions are called to close any
* connections and deinitialize the peripherals. These include:
* - esp_bluedroid_disable
* - esp_bt_controller_disable
* - esp_wifi_stop
*
* This function does not return.
*
* @param time_in_us deep-sleep time, unit: microsecond

View File

@@ -110,6 +110,8 @@ static void obtain_time(void)
time(&now);
localtime_r(&now, &timeinfo);
}
ESP_ERROR_CHECK( esp_wifi_stop() );
}
static void initialize_sntp(void)