mirror of
				https://github.com/espressif/esp-idf.git
				synced 2025-10-31 04:59:55 +00:00 
			
		
		
		
	Merge branch 'bugfix/deepsleep_disable_brownout_s2_v4.3' into 'release/v4.3'
deep_sleep: on S2 disable the brown out detector before deep sleeping (v4.3) See merge request espressif/esp-idf!12499
This commit is contained in:
		| @@ -16,6 +16,16 @@ | |||||||
| #ifndef __ESP_BROWNOUT_H | #ifndef __ESP_BROWNOUT_H | ||||||
| #define __ESP_BROWNOUT_H | #define __ESP_BROWNOUT_H | ||||||
|  |  | ||||||
|  | #ifdef __cplusplus | ||||||
|  | extern "C" { | ||||||
|  | #endif | ||||||
|  |  | ||||||
| void esp_brownout_init(void); | void esp_brownout_init(void); | ||||||
|  |  | ||||||
|  | void esp_brownout_disable(void); | ||||||
|  |  | ||||||
|  | #ifdef __cplusplus | ||||||
|  | } | ||||||
|  | #endif | ||||||
|  |  | ||||||
| #endif | #endif | ||||||
|   | |||||||
| @@ -1,4 +1,4 @@ | |||||||
| // Copyright 2015-2020 Espressif Systems (Shanghai) PTE LTD | // Copyright 2015-2021 Espressif Systems (Shanghai) PTE LTD | ||||||
| // | // | ||||||
| // Licensed under the Apache License, Version 2.0 (the "License"); | // Licensed under the Apache License, Version 2.0 (the "License"); | ||||||
| // you may not use this file except in compliance with the License. | // you may not use this file except in compliance with the License. | ||||||
| @@ -16,6 +16,16 @@ | |||||||
| #ifndef __ESP_BROWNOUT_H | #ifndef __ESP_BROWNOUT_H | ||||||
| #define __ESP_BROWNOUT_H | #define __ESP_BROWNOUT_H | ||||||
|  |  | ||||||
|  | #ifdef __cplusplus | ||||||
|  | extern "C" { | ||||||
|  | #endif | ||||||
|  |  | ||||||
| void esp_brownout_init(void); | void esp_brownout_init(void); | ||||||
|  |  | ||||||
|  | void esp_brownout_disable(void); | ||||||
|  |  | ||||||
|  | #ifdef __cplusplus | ||||||
|  | } | ||||||
|  | #endif | ||||||
|  |  | ||||||
| #endif | #endif | ||||||
|   | |||||||
| @@ -1,4 +1,4 @@ | |||||||
| // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD | // Copyright 2015-2021 Espressif Systems (Shanghai) PTE LTD | ||||||
| // | // | ||||||
| // Licensed under the Apache License, Version 2.0 (the "License"); | // Licensed under the Apache License, Version 2.0 (the "License"); | ||||||
| // you may not use this file except in compliance with the License. | // you may not use this file except in compliance with the License. | ||||||
| @@ -22,6 +22,8 @@ extern "C" { | |||||||
|  |  | ||||||
| void esp_brownout_init(void); | void esp_brownout_init(void); | ||||||
|  |  | ||||||
|  | void esp_brownout_disable(void); | ||||||
|  |  | ||||||
| #ifdef __cplusplus | #ifdef __cplusplus | ||||||
| } | } | ||||||
| #endif | #endif | ||||||
|   | |||||||
| @@ -16,6 +16,16 @@ | |||||||
| #ifndef __ESP_BROWNOUT_H | #ifndef __ESP_BROWNOUT_H | ||||||
| #define __ESP_BROWNOUT_H | #define __ESP_BROWNOUT_H | ||||||
|  |  | ||||||
|  | #ifdef __cplusplus | ||||||
|  | extern "C" { | ||||||
|  | #endif | ||||||
|  |  | ||||||
| void esp_brownout_init(void); | void esp_brownout_init(void); | ||||||
|  |  | ||||||
|  | void esp_brownout_disable(void); | ||||||
|  |  | ||||||
|  | #ifdef __cplusplus | ||||||
|  | } | ||||||
|  | #endif | ||||||
|  |  | ||||||
| #endif | #endif | ||||||
|   | |||||||
| @@ -85,3 +85,18 @@ void esp_brownout_init(void) | |||||||
|     brownout_hal_intr_enable(true); |     brownout_hal_intr_enable(true); | ||||||
| #endif // not SOC_BROWNOUT_RESET_SUPPORTED | #endif // not SOC_BROWNOUT_RESET_SUPPORTED | ||||||
| } | } | ||||||
|  |  | ||||||
|  | void esp_brownout_disable(void) | ||||||
|  | { | ||||||
|  |     brownout_hal_config_t cfg = { | ||||||
|  |         .enabled = false, | ||||||
|  |     }; | ||||||
|  |  | ||||||
|  |     brownout_hal_config(&cfg); | ||||||
|  |  | ||||||
|  | #ifndef SOC_BROWNOUT_RESET_SUPPORTED | ||||||
|  |     brownout_hal_intr_enable(false); | ||||||
|  |  | ||||||
|  |     rtc_isr_deregister(rtc_brownout_isr_handler, NULL); | ||||||
|  | #endif // not SOC_BROWNOUT_RESET_SUPPORTED | ||||||
|  | } | ||||||
|   | |||||||
| @@ -58,6 +58,7 @@ | |||||||
| #include "esp32s2/clk.h" | #include "esp32s2/clk.h" | ||||||
| #include "esp32s2/rom/cache.h" | #include "esp32s2/rom/cache.h" | ||||||
| #include "esp32s2/rom/rtc.h" | #include "esp32s2/rom/rtc.h" | ||||||
|  | #include "esp32s2/brownout.h" | ||||||
| #include "soc/extmem_reg.h" | #include "soc/extmem_reg.h" | ||||||
| #include "driver/gpio.h" | #include "driver/gpio.h" | ||||||
| #elif CONFIG_IDF_TARGET_ESP32S3 | #elif CONFIG_IDF_TARGET_ESP32S3 | ||||||
| @@ -597,6 +598,12 @@ inline static uint32_t IRAM_ATTR call_rtc_sleep_start(uint32_t reject_triggers) | |||||||
|  |  | ||||||
| void IRAM_ATTR esp_deep_sleep_start(void) | void IRAM_ATTR esp_deep_sleep_start(void) | ||||||
| { | { | ||||||
|  | #if CONFIG_IDF_TARGET_ESP32S2 | ||||||
|  |     /* Due to hardware limitations, on S2 the brownout detector sometimes trigger during deep sleep | ||||||
|  |        to circumvent this we disable the brownout detector before sleeping  */ | ||||||
|  |     esp_brownout_disable(); | ||||||
|  | #endif //CONFIG_IDF_TARGET_ESP32S2 | ||||||
|  |  | ||||||
|     // record current RTC time |     // record current RTC time | ||||||
|     s_config.rtc_ticks_at_sleep_start = rtc_time_get(); |     s_config.rtc_ticks_at_sleep_start = rtc_time_get(); | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Angus Gratton
					Angus Gratton