stm32 uart redirection and use printf

why I  use the same code as keil, but UART can't work when I code in CLion.  use 'printf' can not send  anything, but use 'HAL_UART_Transmit' function is work normal,  the project is generate by Stm32cubeMX,

redirection code:

#ifdef __GNUC__
#define PUTCHAR_PROTOTYPE int __io_putchar(int ch)
#else
#define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f)
#endif
PUTCHAR_PROTOTYPE
{
HAL_UART_Transmit(&huart1 , (uint8_t *)&ch, 1 , 0x0f);
return ch;
}

1

请先登录再写评论。