mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
fix(esp_hw_support): fix coverity defects in sleep code
This commit is contained in:
parent
dde0b46390
commit
9ffd8aa017
@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
#include "sdkconfig.h"
|
#include "sdkconfig.h"
|
||||||
#include "esp_attr.h"
|
#include "esp_attr.h"
|
||||||
|
#include "esp_check.h"
|
||||||
#include "freertos/FreeRTOS.h"
|
#include "freertos/FreeRTOS.h"
|
||||||
#include "esp_private/esp_clk_tree_common.h"
|
#include "esp_private/esp_clk_tree_common.h"
|
||||||
#include "esp_private/io_mux.h"
|
#include "esp_private/io_mux.h"
|
||||||
@ -14,6 +15,8 @@
|
|||||||
#include "hal/rtc_io_ll.h"
|
#include "hal/rtc_io_ll.h"
|
||||||
#include "soc/soc_caps.h"
|
#include "soc/soc_caps.h"
|
||||||
|
|
||||||
|
static const char __attribute__((__unused__)) *IOMUX_TAG = "IO_MUX";
|
||||||
|
|
||||||
#define RTCIO_RCC_ATOMIC() PERIPH_RCC_ATOMIC()
|
#define RTCIO_RCC_ATOMIC() PERIPH_RCC_ATOMIC()
|
||||||
|
|
||||||
static portMUX_TYPE s_io_mux_spinlock = portMUX_INITIALIZER_UNLOCKED;
|
static portMUX_TYPE s_io_mux_spinlock = portMUX_INITIALIZER_UNLOCKED;
|
||||||
@ -52,6 +55,7 @@ esp_err_t io_mux_set_clock_source(soc_module_clk_t clk_src)
|
|||||||
|
|
||||||
void io_mux_enable_lp_io_clock(gpio_num_t gpio_num, bool enable)
|
void io_mux_enable_lp_io_clock(gpio_num_t gpio_num, bool enable)
|
||||||
{
|
{
|
||||||
|
ESP_RETURN_ON_FALSE(rtc_gpio_is_valid_gpio(gpio_num), ESP_ERR_INVALID_ARG, IOMUX_TAG, "RTCIO number error");
|
||||||
portENTER_CRITICAL(&s_io_mux_spinlock);
|
portENTER_CRITICAL(&s_io_mux_spinlock);
|
||||||
if (enable) {
|
if (enable) {
|
||||||
if (s_rtc_io_status.rtc_io_enabled_cnt[gpio_num] == 0) {
|
if (s_rtc_io_status.rtc_io_enabled_cnt[gpio_num] == 0) {
|
||||||
|
@ -983,6 +983,14 @@ static esp_err_t IRAM_ATTR esp_sleep_start(uint32_t pd_flags, esp_sleep_mode_t m
|
|||||||
#endif // SOC_PM_SUPPORT_DEEPSLEEP_CHECK_STUB_ONLY
|
#endif // SOC_PM_SUPPORT_DEEPSLEEP_CHECK_STUB_ONLY
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if SOC_DCDC_SUPPORTED
|
||||||
|
uint64_t ldo_increased_us = rtc_time_slowclk_to_us(rtc_time_get() - s_config.rtc_ticks_at_ldo_prepare, s_config.rtc_clk_cal_period);
|
||||||
|
if (ldo_increased_us < LDO_POWER_TAKEOVER_PREPARATION_TIME_US) {
|
||||||
|
esp_rom_delay_us(LDO_POWER_TAKEOVER_PREPARATION_TIME_US - ldo_increased_us);
|
||||||
|
}
|
||||||
|
pmu_sleep_shutdown_dcdc();
|
||||||
|
#endif
|
||||||
|
|
||||||
// Enter Deep Sleep
|
// Enter Deep Sleep
|
||||||
#if!ESP_ROM_SUPPORT_DEEP_SLEEP_WAKEUP_STUB || SOC_PM_SUPPORT_DEEPSLEEP_CHECK_STUB_ONLY || !CONFIG_ESP_SYSTEM_ALLOW_RTC_FAST_MEM_AS_HEAP
|
#if!ESP_ROM_SUPPORT_DEEP_SLEEP_WAKEUP_STUB || SOC_PM_SUPPORT_DEEPSLEEP_CHECK_STUB_ONLY || !CONFIG_ESP_SYSTEM_ALLOW_RTC_FAST_MEM_AS_HEAP
|
||||||
#if SOC_PMU_SUPPORTED
|
#if SOC_PMU_SUPPORTED
|
||||||
@ -1016,25 +1024,18 @@ static esp_err_t IRAM_ATTR esp_sleep_start(uint32_t pd_flags, esp_sleep_mode_t m
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if SOC_DCDC_SUPPORTED
|
#if CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP && SOC_PM_MMU_TABLE_RETENTION_WHEN_TOP_PD
|
||||||
#if CONFIG_ESP_SLEEP_KEEP_DCDC_ALWAYS_ON
|
if (pd_flags & PMU_SLEEP_PD_TOP) {
|
||||||
if (!deep_sleep) {
|
esp_sleep_mmu_retention(true);
|
||||||
// Keep DCDC always on during light sleep, no need to adjust LDO voltage.
|
}
|
||||||
} else
|
|
||||||
#endif
|
#endif
|
||||||
{
|
|
||||||
|
#if SOC_DCDC_SUPPORTED && !CONFIG_ESP_SLEEP_KEEP_DCDC_ALWAYS_ON
|
||||||
uint64_t ldo_increased_us = rtc_time_slowclk_to_us(rtc_time_get() - s_config.rtc_ticks_at_ldo_prepare, s_config.rtc_clk_cal_period);
|
uint64_t ldo_increased_us = rtc_time_slowclk_to_us(rtc_time_get() - s_config.rtc_ticks_at_ldo_prepare, s_config.rtc_clk_cal_period);
|
||||||
if (ldo_increased_us < LDO_POWER_TAKEOVER_PREPARATION_TIME_US) {
|
if (ldo_increased_us < LDO_POWER_TAKEOVER_PREPARATION_TIME_US) {
|
||||||
esp_rom_delay_us(LDO_POWER_TAKEOVER_PREPARATION_TIME_US - ldo_increased_us);
|
esp_rom_delay_us(LDO_POWER_TAKEOVER_PREPARATION_TIME_US - ldo_increased_us);
|
||||||
}
|
}
|
||||||
pmu_sleep_shutdown_dcdc();
|
pmu_sleep_shutdown_dcdc();
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP && SOC_PM_MMU_TABLE_RETENTION_WHEN_TOP_PD
|
|
||||||
if (pd_flags & PMU_SLEEP_PD_TOP) {
|
|
||||||
esp_sleep_mmu_retention(true);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if SOC_PMU_SUPPORTED
|
#if SOC_PMU_SUPPORTED
|
||||||
|
Loading…
Reference in New Issue
Block a user