初级会员

- 积分
- 103
- 金钱
- 103
- 注册时间
- 2012-12-4
- 在线时间
- 14 小时
|

楼主 |
发表于 2015-6-29 10:00:24
|
显示全部楼层
回复【2楼】正点原子:
---------------------------------
还是你的源代码,如下:
#pragma import(__use_no_semihosting)
//标准库需要的支持函数
struct __FILE
{
int handle;
/* Whatever you require here. If the only file you are using is */
/* standard output using printf() for debugging, no file handling */
/* is required. */
};
/* FILE is typedef’ d in stdio.h. */
FILE __stdout;
//定义_sys_exit()以避免使用半主机模式
_sys_exit(int x)
{
x = x;
}
//重定义fputc函数
int fputc(int ch, FILE *f)
{
while((BAR_USARTn->SR&0X40)==0);//循环发送,直到发送完毕
BAR_USARTn->DR = (u8) ch;
return ch;
}
/*******************************************************************************
* Function Name: int fgetc(FILE *f)
* Description : Retargets the C library printf function to the USART.fgetc重定向
* Input : None
* Output : None
* Return : 读取到的字符(未调试)
*******************************************************************************/
int fgetc(FILE *f)
{
/* Loop until received a char */
while(!(USART_GetFlagStatus(BAR_USARTn, USART_FLAG_RXNE) == SET))
{
}
/* Read a character from the USART and RETURN */
return (USART_ReceiveData(BAR_USARTn));
} |
|