mirror of
https://github.com/espressif/esp-idf.git
synced 2025-07-30 10:47:19 +02:00
Merge branch 'fix/fix_uart_console_broken_after_sleep_v5.3' into 'release/v5.3'
fix(esp_hw_support): fixed gpio sleep switching filling junk data to the console UART FIFO (v5.3) See merge request espressif/esp-idf!38445
This commit is contained in:
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@ -21,6 +21,7 @@
|
|||||||
#include "hal/gpio_hal.h"
|
#include "hal/gpio_hal.h"
|
||||||
#include "hal/rtc_io_hal.h"
|
#include "hal/rtc_io_hal.h"
|
||||||
#include "soc/rtc_io_periph.h"
|
#include "soc/rtc_io_periph.h"
|
||||||
|
#include "soc/uart_channel.h"
|
||||||
|
|
||||||
#include "hal/rtc_hal.h"
|
#include "hal/rtc_hal.h"
|
||||||
|
|
||||||
@ -89,6 +90,18 @@ void esp_sleep_enable_gpio_switch(bool enable)
|
|||||||
ESP_EARLY_LOGI(TAG, "%s automatic switching of GPIO sleep configuration", enable ? "Enable" : "Disable");
|
ESP_EARLY_LOGI(TAG, "%s automatic switching of GPIO sleep configuration", enable ? "Enable" : "Disable");
|
||||||
for (gpio_num_t gpio_num = GPIO_NUM_0; gpio_num < GPIO_NUM_MAX; gpio_num++) {
|
for (gpio_num_t gpio_num = GPIO_NUM_0; gpio_num < GPIO_NUM_MAX; gpio_num++) {
|
||||||
if (GPIO_IS_VALID_GPIO(gpio_num)) {
|
if (GPIO_IS_VALID_GPIO(gpio_num)) {
|
||||||
|
#if CONFIG_ESP_CONSOLE_UART
|
||||||
|
#if CONFIG_ESP_CONSOLE_UART_CUSTOM
|
||||||
|
const int uart_tx_gpio = (CONFIG_ESP_CONSOLE_UART_TX_GPIO >= 0) ? CONFIG_ESP_CONSOLE_UART_TX_GPIO : UART_NUM_0_TXD_DIRECT_GPIO_NUM;
|
||||||
|
const int uart_rx_gpio = (CONFIG_ESP_CONSOLE_UART_RX_GPIO >= 0) ? CONFIG_ESP_CONSOLE_UART_RX_GPIO : UART_NUM_0_RXD_DIRECT_GPIO_NUM;
|
||||||
|
if ((gpio_num == uart_tx_gpio) || (gpio_num == uart_rx_gpio)) {
|
||||||
|
#else
|
||||||
|
if ((gpio_num == UART_NUM_0_TXD_DIRECT_GPIO_NUM) || (gpio_num == UART_NUM_0_RXD_DIRECT_GPIO_NUM)) {
|
||||||
|
#endif
|
||||||
|
gpio_sleep_sel_dis(gpio_num);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
/* If the PSRAM is disable in ESP32xx chips equipped with PSRAM, there will be a large current leakage. */
|
/* If the PSRAM is disable in ESP32xx chips equipped with PSRAM, there will be a large current leakage. */
|
||||||
#if CONFIG_ESP_SLEEP_PSRAM_LEAKAGE_WORKAROUND && CONFIG_SPIRAM
|
#if CONFIG_ESP_SLEEP_PSRAM_LEAKAGE_WORKAROUND && CONFIG_SPIRAM
|
||||||
if (gpio_num == esp_mspi_get_io(ESP_MSPI_IO_CS1)) {
|
if (gpio_num == esp_mspi_get_io(ESP_MSPI_IO_CS1)) {
|
||||||
|
@ -123,10 +123,7 @@ static esp_err_t uart_initialization(void)
|
|||||||
|
|
||||||
static esp_err_t uart_wakeup_config(void)
|
static esp_err_t uart_wakeup_config(void)
|
||||||
{
|
{
|
||||||
/* UART will wakeup the chip up from light sleep if the edges that RX pin received has reached the threshold
|
/* UART will wakeup the chip up from light sleep if the edges that RX pin received has reached the threshold */
|
||||||
* Besides, the Rx pin need extra configuration to enable it can work during light sleep */
|
|
||||||
ESP_RETURN_ON_ERROR(gpio_sleep_set_direction(EXAMPLE_UART_RX_IO_NUM, GPIO_MODE_INPUT), TAG, "Set uart sleep gpio failed");
|
|
||||||
ESP_RETURN_ON_ERROR(gpio_sleep_set_pull_mode(EXAMPLE_UART_RX_IO_NUM, GPIO_PULLUP_ONLY), TAG, "Set uart sleep gpio failed");
|
|
||||||
ESP_RETURN_ON_ERROR(uart_set_wakeup_threshold(EXAMPLE_UART_NUM, EXAMPLE_UART_WAKEUP_THRESHOLD),
|
ESP_RETURN_ON_ERROR(uart_set_wakeup_threshold(EXAMPLE_UART_NUM, EXAMPLE_UART_WAKEUP_THRESHOLD),
|
||||||
TAG, "Set uart wakeup threshold failed");
|
TAG, "Set uart wakeup threshold failed");
|
||||||
/* Only uart0 and uart1 (if has) support to be configured as wakeup source */
|
/* Only uart0 and uart1 (if has) support to be configured as wakeup source */
|
||||||
|
Reference in New Issue
Block a user