/****************************************************分割线*******************************************/
// 加入以下代码。支持printf函数,则不需要选择use MicroLIB
//添加头文件
#include <stdio.h>
//添加代码
#if 1
#pragma import(__use_no_semihosting)//标准库需要支持函数
struct __FILE
{
int handle;
};
FILE __stdout;
//定义_sys_exit()以避免使用半主机模式
_sys_exit(int x)
{
x = x;
}
扫描二维码关注公众号,回复:
5414976 查看本文章
//重定义fput()函数。UART5:根据需求更改串口(USART1-USART3、UART4-UART5)
int fputc(int ch, FILE *f)
{
/*将printf内容发往串口*/
USART_SendData(UART5,(uint8_t)ch);
while(USART_GetFlagStatus(UART5, USART_FLAG_TC) == RESET);
return ch;
}
#endif
/****************************************************分割线*******************************************/
_sys_exit()函数可能出现以下警告,不用理会。编译时不会出现警告