From 429e1cafe6453af16f08ded4f1e13cc0c19100f7 Mon Sep 17 00:00:00 2001 From: breederbai Date: Mon, 25 Apr 2022 12:51:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DBUG=EF=BC=9A=E4=B8=B2?= =?UTF-8?q?=E5=8F=A3=E5=90=AF=E7=94=A8DMA=E6=8E=A5=E6=94=B6=E5=90=8E?= =?UTF-8?q?=EF=BC=8C=E5=8A=A8=E6=80=81=E4=BF=AE=E6=94=B9=E4=B8=B2=E5=8F=A3?= =?UTF-8?q?=E6=B3=A2=E7=89=B9=E7=8E=87=E6=89=B0=E4=B9=B1=E6=8E=A5=E6=94=B6?= =?UTF-8?q?=E6=A3=80=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在串口不关闭的情况下,更改波特率后,清空上次数据检索,导致更新写入检索错误, 串口无法读出正确的数据。真实数据的位置和检索值之间总有一定的距离,导致读取 数据的时候会有一定的延时。缓冲区大,延时越长 --- bsp/stm32/libraries/HAL_Drivers/drv_usart.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bsp/stm32/libraries/HAL_Drivers/drv_usart.c b/bsp/stm32/libraries/HAL_Drivers/drv_usart.c index 6211676056..fe9cc3bdcf 100644 --- a/bsp/stm32/libraries/HAL_Drivers/drv_usart.c +++ b/bsp/stm32/libraries/HAL_Drivers/drv_usart.c @@ -169,7 +169,9 @@ static rt_err_t stm32_configure(struct rt_serial_device *serial, struct serial_c } #ifdef RT_SERIAL_USING_DMA - uart->dma_rx.last_index = 0; + if (!(serial->parent.open_flag & RT_DEVICE_OFLAG_OPEN)) { + uart->dma_rx.last_index = 0; + } #endif if (HAL_UART_Init(&uart->handle) != HAL_OK)