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);
}

 

posted @ 2016-09-05 22:26  prayer521  阅读(2855)  评论(0编辑  收藏  举报