解决STM32编译错误:L6200E: Symbol __stdout multiply defined

STM32编译错误:…\OBJ\USART.axf: Error: L6200E: Symbol __stdout multiply defined (by stdio_streams.o and usart.o).

在usart.c中添加代码:

//getchar()等价于scanf()函数
//如果使用getchar函数也需要重新定义

重定向c库函数scanf到串口,重写后可以使用scanf和getchar函数
int fgetc(FILE *f)
{
	//等待串口输入数据
	/* 有了这个等待就不需要在中断中进行了 */
	while(USART_GetFlagStatus(USART1,USART_FLAG_RXNE)==RESET);
	return (int)USART_ReceiveData(USART1);
}
//如果在主函数中使用getchar()需要把下面的中断设置代码注释掉,否则会冲突
物联沃分享整理
物联沃-IOTWORD物联网 » 解决STM32编译错误:L6200E: Symbol __stdout multiply defined

发表评论