您现在的位置: 主页 > MCU > 单片机应用 > STM32串口通信printf重定向方法 -
本文所属标签:
为本文创立个标签吧:

STM32串口通信printf重定向方法 -

来源: 网络用户发布,如有版权联系网管删除 2018-09-11 

[导读]在源程序中加入如下代码,包含“stdio.h”。默认使用USART1,确认串口已经初始化成功、#pragmaimport(__use_no_semihosting)_sys_exit(intx){x=x;}struct__FILE{inthandle;/*Whateveryourequirehere.Iftheonlyfileyo

在源程序中加入如下代码,包含“stdio.h”。

本文引用地址: http://www.21ic.com/app/mcu/201809/781073.htm

默认使用USART1,确认串口已经初始化成功、


#pragmaimport(__use_no_semihosting)

_sys_exit(intx)

{

x=x;

}

struct__FILE

{

inthandle;

/*Whateveryourequirehere.Iftheonlyfileyouareusingis*/

/*standardoutputusingprintf()fordebugging,nofilehandling*/

/*isrequired.*/

};

/*FILEistypedef’dinstdio.h.*/

FILE__stdout;

intfputc(intch,FILE*f)

{

while(USART_GetFlagStatus(USART1,USART_FLAG_TC)==RESET);

USART_SendData(USART1,ch);

returnch;

}




              查看评论 回复



嵌入式交流网主页 > MCU > 单片机应用 > STM32串口通信printf重定向方法 -
 

"STM32串口通信printf重定向方法 -"的相关文章

网站地图

围观()