printf函数重定向

printf函数底层会调用fputc函数

/*重定向c库函数printf到USART1*/
int fputc(int ch, FILE *f)
{
        /*发送一个字节数据USART1 */
        USART_SendData(DEBUG_USART, (uint8_t) ch);
        
        /* 等待发送完毕 */
        while (USART_GetFlagStatus(DEBUG_USART, USART_FLAG_TXE) == RESET);        
    
        return (ch);
}
原文地址:https://www.cnblogs.com/prayer521/p/5843904.html