esp_system: remove duplicated esp_digital_reset function

esp_digital_reset was defined both in system_api.c and panic_handler.c
This commit is contained in:
Ivan Grokhotkov 2020-04-30 16:37:57 +02:00 committed by bot
parent 8bdfb265a4
commit c5f664d4ac
3 changed files with 21 additions and 32 deletions

View file

@ -36,6 +36,11 @@ extern "C" {
*/
void esp_restart_noos(void) __attribute__ ((noreturn));
/**
* @brief Similar to esp_restart_noos, but resets all the digital peripherals.
*/
void esp_restart_noos_dig(void) __attribute__ ((noreturn));
/**
* @brief Internal function to set reset reason hint
*

View file

@ -542,25 +542,6 @@ void xt_unhandled_exception(XtExcFrame *frame)
panic_handler(frame, false);
}
static __attribute__((noreturn)) void esp_digital_reset(void)
{
// make sure all the panic handler output is sent from UART FIFO
uart_tx_wait_idle(CONFIG_ESP_CONSOLE_UART_NUM);
// switch to XTAL (otherwise we will keep running from the PLL)
rtc_clk_cpu_freq_set_xtal();
#if CONFIG_IDF_TARGET_ESP32
esp_cpu_unstall(PRO_CPU_NUM);
#endif
// reset the digital part
SET_PERI_REG_MASK(RTC_CNTL_OPTIONS0_REG, RTC_CNTL_SW_SYS_RST);
while (true) {
;
}
}
void __attribute__((noreturn)) panic_restart(void)
{
bool digital_reset_needed = false;
@ -576,7 +557,7 @@ void __attribute__((noreturn)) panic_restart(void)
}
#endif
if (digital_reset_needed) {
esp_digital_reset();
esp_restart_noos_dig();
}
esp_restart_noos();
}

View file

@ -3,16 +3,16 @@
#include "esp_heap_caps.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#if CONFIG_IDF_TARGET_ESP32S2
#include "soc/rtc.h"
#include "soc/rtc_cntl_reg.h"
#include "panic_internal.h"
#if CONFIG_IDF_TARGET_ESP32
#include "esp32/rom/uart.h"
#elif CONFIG_IDF_TARGET_ESP32S2
#include "esp32s2/rom/uart.h"
#include "esp32s2/memprot.h"
#endif
#include "esp_system.h"
#include "panic_internal.h"
#define SHUTDOWN_HANDLERS_NO 2
static shutdown_handler_t shutdown_handlers[SHUTDOWN_HANDLERS_NO];
@ -41,22 +41,25 @@ esp_err_t esp_unregister_shutdown_handler(shutdown_handler_t handler)
return ESP_ERR_INVALID_STATE;
}
#if CONFIG_IDF_TARGET_ESP32S2
static __attribute__((noreturn)) void esp_digital_reset(void)
void IRAM_ATTR esp_restart_noos_dig(void)
{
// make sure all the panic handler output is sent from UART FIFO
uart_tx_wait_idle(CONFIG_ESP_CONSOLE_UART_NUM);
// switch to XTAL (otherwise we will keep running from the PLL)
if (CONFIG_ESP_CONSOLE_UART_NUM >= 0) {
uart_tx_wait_idle(CONFIG_ESP_CONSOLE_UART_NUM);
}
// switch to XTAL (otherwise we will keep running from the PLL)
rtc_clk_cpu_freq_set_xtal();
#if CONFIG_IDF_TARGET_ESP32
esp_cpu_unstall(PRO_CPU_NUM);
#endif
// reset the digital part
SET_PERI_REG_MASK(RTC_CNTL_OPTIONS0_REG, RTC_CNTL_SW_SYS_RST);
while (true) {
;
}
}
#endif
void IRAM_ATTR esp_restart(void)
{
@ -70,8 +73,8 @@ void IRAM_ATTR esp_restart(void)
vTaskSuspendAll();
#if CONFIG_IDF_TARGET_ESP32S2
if ( esp_memprot_is_intr_ena_any() || esp_memprot_is_locked_any()) {
esp_digital_reset();
if (esp_memprot_is_intr_ena_any() || esp_memprot_is_locked_any()) {
esp_restart_noos_dig();
}
#endif
esp_restart_noos();
@ -95,4 +98,4 @@ const char *esp_get_idf_version(void)
void __attribute__((noreturn)) esp_system_abort(const char *details)
{
panic_abort(details);
}
}