?
主函數(shù)增加這些代碼即可實現(xiàn)printf打印輸出
?需要添加頭文件
#include "stdio.h"
---------------
源碼
struct __FILE { int handle; /* Add whatever you need here */ };
FILE __stdout;
FILE __stdin;
int fputc(int c, FILE *f)?
{
?? ?/* 發(fā)送一個字節(jié) */
?? ?USART_SendData(USART1,c);
?? ?/* 等待發(fā)送完畢 */
?? ?while(USART_GetFlagStatus(USART1,USART_FLAG_TXE) == RESET);
?? ?/* 返回發(fā)送的字符 */
?? ?return c;?? ?
}
int main(void)
{
?? ?NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4);
?? ??? ?//搶占優(yōu)先級0~3,支持4級!
?? ?//響應(yīng)優(yōu)先級0~3,支持4級!
?? ?key_init();
?? ?Led_init();
?? ?//初始化串口1波特率位115200bps,若發(fā)送/接收數(shù)據(jù)有亂碼,請檢查PLL
?? ?
?? ?usart1_init(115200);
?? ?usart1_send_str("hello5555\r\n");
?? ?
?? ?printf("請求");
?? ?while(1){文章來源:http://www.zghlxwxcb.cn/news/detail-672264.html
?? ?
?? ??? ?}
?? ?
}
?文章來源地址http://www.zghlxwxcb.cn/news/detail-672264.html
到了這里,關(guān)于stm32之12.如何使用printf打印輸出的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!