Merge branch 'bugfix/bod_reset_c6_h2' into 'master'

fix(bod): Fix issue that RF cannot be enabled again after BOD triggered.

See merge request espressif/esp-idf!27287
pull/12702/head
C.S.M 2023-11-29 17:21:38 +08:00
commit 96f49c2603
9 zmienionych plików z 71 dodań i 3 usunięć

Wyświetl plik

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@ -11,7 +11,7 @@
#include "esp_private/system_internal.h"
#include "esp_private/rtc_ctrl.h"
#include "esp_private/spi_flash_os.h"
#include "esp_rom_sys.h"
#include "esp_log.h"
#include "esp_cpu.h"
#include "soc/soc.h"
#include "soc/rtc_periph.h"
@ -28,6 +28,8 @@
#define BROWNOUT_DET_LVL 0
#endif
static __attribute__((unused)) DRAM_ATTR const char *TAG = "BOD";
#if CONFIG_ESP_SYSTEM_BROWNOUT_INTR
IRAM_ATTR static void rtc_brownout_isr_handler(void *arg)
{
@ -51,7 +53,7 @@ IRAM_ATTR static void rtc_brownout_isr_handler(void *arg)
} else
#endif // CONFIG_SPI_FLASH_BROWNOUT_RESET
{
esp_rom_printf("\r\nBrownout detector was triggered\r\n\r\n");
ESP_DRAM_LOGI(TAG, "Brownout detector was triggered\r\n\r\n");
}
esp_restart_noos();

Wyświetl plik

@ -15,6 +15,7 @@ void brownout_hal_config(const brownout_hal_config_t *cfg)
brownout_ll_set_intr_wait_cycles(2);
brownout_ll_enable_flash_power_down(cfg->flash_power_down);
brownout_ll_enable_rf_power_down(cfg->rf_power_down);
brownout_ll_clear_count();
brownout_ll_reset_config(cfg->reset_enabled, 0x3ff, 1);
brownout_ll_set_threshold(cfg->threshold);
brownout_ll_bod_enable(cfg->enabled);

Wyświetl plik

@ -112,6 +112,15 @@ static inline void brownout_ll_intr_clear(void)
RTCCNTL.int_clr.rtc_brown_out = 1;
}
/**
* @brief Clear BOD internal count.
*/
static inline void brownout_ll_clear_count(void)
{
// Not supported on esp32
}
#ifdef __cplusplus
}
#endif

Wyświetl plik

@ -115,6 +115,16 @@ static inline void brownout_ll_intr_clear(void)
RTCCNTL.int_clr.rtc_brown_out = 1;
}
/**
* @brief Clear BOD internal count.
*/
static inline void brownout_ll_clear_count(void)
{
RTCCNTL.brown_out.cnt_clr = 1;
RTCCNTL.brown_out.cnt_clr = 0;
}
#ifdef __cplusplus
}
#endif

Wyświetl plik

@ -115,6 +115,15 @@ static inline void brownout_ll_intr_clear(void)
RTCCNTL.int_clr.rtc_brown_out = 1;
}
/**
* @brief Clear BOD internal count.
*/
static inline void brownout_ll_clear_count(void)
{
RTCCNTL.brown_out.cnt_clr = 1;
RTCCNTL.brown_out.cnt_clr = 0;
}
#ifdef __cplusplus
}
#endif

Wyświetl plik

@ -115,6 +115,15 @@ static inline void brownout_ll_intr_clear(void)
LP_ANA_PERI.int_clr.bod_mode0 = 1;
}
/**
* @brief Clear BOD internal count.
*/
static inline void brownout_ll_clear_count(void)
{
LP_ANA_PERI.bod_mode0_cntl.bod_mode0_cnt_clr = 1;
LP_ANA_PERI.bod_mode0_cntl.bod_mode0_cnt_clr = 0;
}
#ifdef __cplusplus
}
#endif

Wyświetl plik

@ -115,6 +115,15 @@ static inline void brownout_ll_intr_clear(void)
LP_ANA_PERI.int_clr.bod_mode0_int_clr = 1;
}
/**
* @brief Clear BOD internal count.
*/
static inline void brownout_ll_clear_count(void)
{
LP_ANA_PERI.bod_mode0_cntl.bod_mode0_cnt_clr = 1;
LP_ANA_PERI.bod_mode0_cntl.bod_mode0_cnt_clr = 0;
}
#ifdef __cplusplus
}
#endif

Wyświetl plik

@ -116,6 +116,16 @@ static inline void brownout_ll_intr_clear(void)
RTCCNTL.int_clr.rtc_brown_out = 1;
}
/**
* @brief Clear BOD internal count.
*/
static inline void brownout_ll_clear_count(void)
{
RTCCNTL.brown_out.cnt_clr = 1;
RTCCNTL.brown_out.cnt_clr = 0;
}
#ifdef __cplusplus
}
#endif

Wyświetl plik

@ -115,6 +115,15 @@ static inline void brownout_ll_intr_clear(void)
RTCCNTL.int_clr.rtc_brown_out = 1;
}
/**
* @brief Clear BOD internal count.
*/
static inline void brownout_ll_clear_count(void)
{
RTCCNTL.brown_out.cnt_clr = 1;
RTCCNTL.brown_out.cnt_clr = 0;
}
#ifdef __cplusplus
}
#endif