From 3de0b669e7de181f132f5d0bf4c96ade168403ad Mon Sep 17 00:00:00 2001 From: Song Ruo Jing Date: Thu, 6 Mar 2025 18:47:41 +0800 Subject: [PATCH] docs(uart): improve set/get baud rate API docs Closes https://github.com/espressif/esp-idf/issues/15449 --- components/esp_driver_uart/include/driver/uart.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/components/esp_driver_uart/include/driver/uart.h b/components/esp_driver_uart/include/driver/uart.h index ff3138ca7c..5ffb7dd269 100644 --- a/components/esp_driver_uart/include/driver/uart.h +++ b/components/esp_driver_uart/include/driver/uart.h @@ -34,7 +34,8 @@ extern "C" { * @brief UART configuration parameters for uart_param_config function */ typedef struct { - int baud_rate; /*!< UART baud rate*/ + int baud_rate; /*!< UART baud rate + Note that the actual baud rate set could have a slight deviation from the user-configured value due to rounding error*/ uart_word_length_t data_bits; /*!< UART byte size*/ uart_parity_t parity; /*!< UART parity mode*/ uart_stop_bits_t stop_bits; /*!< UART stop bits*/ @@ -225,7 +226,9 @@ esp_err_t uart_get_parity(uart_port_t uart_num, uart_parity_t* parity_mode); esp_err_t uart_get_sclk_freq(uart_sclk_t sclk, uint32_t* out_freq_hz); /** - * @brief Set UART baud rate. + * @brief Set desired UART baud rate. + * + * Note that the actual baud rate set could have a slight deviation from the user-configured value due to rounding error. * * @param uart_num UART port number, the max port number is (UART_NUM_MAX -1). * @param baudrate UART baud rate. @@ -237,7 +240,9 @@ esp_err_t uart_get_sclk_freq(uart_sclk_t sclk, uint32_t* out_freq_hz); esp_err_t uart_set_baudrate(uart_port_t uart_num, uint32_t baudrate); /** - * @brief Get the UART baud rate configuration. + * @brief Get the actual UART baud rate. + * + * It returns the real UART rate set in the hardware. It could have a slight deviation from the user-configured baud rate. * * @param uart_num UART port number, the max port number is (UART_NUM_MAX -1). * @param baudrate Pointer to accept value of UART baud rate