From bc8c26a7a664e601b6885881b1d127e093d4c05b Mon Sep 17 00:00:00 2001 From: IOsetting Date: Tue, 24 Jan 2023 14:53:24 +0800 Subject: [PATCH] fix: avoid printf io buffer --- Libraries/BSP_LL/Src/py32f0xx_bsp_printf.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Libraries/BSP_LL/Src/py32f0xx_bsp_printf.c b/Libraries/BSP_LL/Src/py32f0xx_bsp_printf.c index 778ab02..7d818db 100644 --- a/Libraries/BSP_LL/Src/py32f0xx_bsp_printf.c +++ b/Libraries/BSP_LL/Src/py32f0xx_bsp_printf.c @@ -38,6 +38,12 @@ void BSP_USART_Config(uint32_t baudRate) LL_GPIO_SetPinSpeed(DEBUG_USART_RX_GPIO_PORT, DEBUG_USART_RX_PIN, LL_GPIO_SPEED_FREQ_VERY_HIGH); LL_GPIO_SetPinPull(DEBUG_USART_RX_GPIO_PORT, DEBUG_USART_RX_PIN, LL_GPIO_PULL_UP); LL_GPIO_SetAFPin_0_7(DEBUG_USART_RX_GPIO_PORT, DEBUG_USART_RX_PIN, DEBUG_USART_RX_AF); + +#if defined (__GNUC__) && !defined (__clang__) + // To avoid io buffer + setvbuf(stdout, NULL, _IONBF, 0); + setvbuf(stdin, NULL, _IONBF, 0); +#endif }