#include "sys.h"
#include "usart.h"
#if SYSTEM_SUPPORT_OS
#include "includes.h" //ucos 使用
#endif
//加入以下代码,支持printf函数,而不需要选择use MicroLIB
#if 1
#pragma import(__use_no_semihosting)
//标准库需要的支持函数
struct __FILE
{
int handle;
};
FILE __stdout;
//定义_sys_exit()以避免使用半主机模式
_sys_exit(int x)
{
x = x;
}
//重定义fputc函数
int fputc(int ch, FILE *f)
{
while((USART1->SR&0X40)==0);//循环发送,直到发送完毕
USART1->DR = (u8) ch;
return ch;
}
#endif
出现报错:..\SYSTEM\usart\usart.c(21): error: #260-D: explicit type is missing ("int" assumed)
报错分析:该函数没有返回类型,假设其返回类型为int,可以写为void void _sys_exit(int x) ,否则编译器会默认为返回int类型,所以才会出现上述警告。
解决办法:应该写成void _sys_exit(int x)