ソースを参照

修复BUG:串口启用DMA接收后,动态修改串口波特率扰乱接收检索

在串口不关闭的情况下,更改波特率后,清空上次数据检索,导致更新写入检索错误,
串口无法读出正确的数据。真实数据的位置和检索值之间总有一定的距离,导致读取
数据的时候会有一定的延时。缓冲区大,延时越长
breederbai 3 年 前
コミット
429e1cafe6
1 ファイル変更3 行追加1 行削除
  1. 3 1
      bsp/stm32/libraries/HAL_Drivers/drv_usart.c

+ 3 - 1
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)