stm32 printf重定向

printf函数调用fputc

int fputc(int ch, FILE *p)
{
    USART_SendData(USART1, ch); //重定向到串口
    while(USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET);

    return ch;
}

在KEIL中使用printf要勾选“微库”

1

原文地址:https://www.cnblogs.com/zhangxuechao/p/11709570.html