From 457e0818e9d1e412c2fdb2d56f8ee1e6786843e7 Mon Sep 17 00:00:00 2001 From: Song Ruo Jing Date: Fri, 5 Jul 2024 22:17:31 +0800 Subject: [PATCH] fix(uart): fix uart_config_t structure size difference in C and C++ --- components/driver/uart/include/driver/uart.h | 4 +--- components/driver/uart/uart.c | 4 ++++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/components/driver/uart/include/driver/uart.h b/components/driver/uart/include/driver/uart.h index 1d2446afd5..b6c2d9f937 100644 --- a/components/driver/uart/include/driver/uart.h +++ b/components/driver/uart/include/driver/uart.h @@ -50,11 +50,9 @@ typedef struct { #endif }; struct { -#if SOC_UART_SUPPORT_SLEEP_RETENTION - uint32_t backup_before_sleep: 1; /*!< If set, the driver will backup/restore the HP UART registers before/after entering/exist sleep mode. + uint32_t backup_before_sleep: 1; /*!< If set, the driver will backup/restore the HP UART registers before entering/after exiting sleep mode. By this approach, the system can power off HP UART's power domain. This can save power, but at the expense of more RAM being consumed */ -#endif } flags; /*!< Configuration flags */ } uart_config_t; diff --git a/components/driver/uart/uart.c b/components/driver/uart/uart.c index 8e7d1ce1af..8bcdbb51a1 100644 --- a/components/driver/uart/uart.c +++ b/components/driver/uart/uart.c @@ -848,6 +848,10 @@ esp_err_t uart_param_config(uart_port_t uart_num, const uart_config_t *uart_conf ESP_RETURN_ON_FALSE((uart_config->flow_ctrl < UART_HW_FLOWCTRL_MAX), ESP_FAIL, UART_TAG, "hw_flowctrl mode error"); ESP_RETURN_ON_FALSE((uart_config->data_bits < UART_DATA_BITS_MAX), ESP_FAIL, UART_TAG, "data bit error"); +#if !SOC_UART_SUPPORT_SLEEP_RETENTION + ESP_RETURN_ON_FALSE(uart_config->flags.backup_before_sleep == 0, ESP_ERR_NOT_SUPPORTED, UART_TAG, "register back up is not supported"); +#endif + uart_module_enable(uart_num); #if SOC_UART_SUPPORT_SLEEP_RETENTION && CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP