Skip to content

Commit 267beca

Browse files
Update drv_usart.c
Fixed bugs under different optimization levels
1 parent bac64ca commit 267beca

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

bsp/stm32/libraries/HAL_Drivers/drivers/drv_usart.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
* 2020-05-02 whj4674672 support stm32h7 uart dma
1212
* 2020-09-09 forest-rain support stm32wl uart
1313
* 2020-10-14 Dozingfiretruck Porting for stm32wbxx
14+
* 2025-08-24 ItsGettingWorse Fixed bugs under different optimization levels
1415
*/
1516

1617
#include "board.h"
@@ -353,7 +354,10 @@ static int stm32_putc(struct rt_serial_device *serial, char c)
353354
#else
354355
uart->handle.Instance->DR = c;
355356
#endif
356-
while (__HAL_UART_GET_FLAG(&(uart->handle), UART_FLAG_TC) == RESET && --block_timeout);
357+
while (__HAL_UART_GET_FLAG(&(uart->handle), UART_FLAG_TC) == RESET && --block_timeout)
358+
{
359+
__DSB(); // Data Synchronization Barrier
360+
}
357361
return (block_timeout != 0) ? 1 : -1;
358362
}
359363

0 commit comments

Comments
 (0)