串口重定向打印

放在usart.c
#if 1
#ifdef GNUC
/* With GCC/RAISONANCE, small printf (option LD Linker->Libraries->Small printf
set to ‘Yes’) calls __io_putchar() */
#define PUTCHAR_PROTOTYPE int __io_putchar(int ch)
#else
#define PUTCHAR_PROTOTYPE int fputc(int ch, FILE f)
#endif /
GNUC /
PUTCHAR_PROTOTYPE
{
/
Place your implementation of fputc here /
/
使用的串口可根据实际配置修改 */
HAL_UART_Transmit(&huart1, (uint8_t *)&ch, 1, 0xFFFF);
return ch;
}
#endif

猜你喜欢

转载自blog.csdn.net/qq_28851611/article/details/102820423
今日推荐