功能:
重定位printf函数,使printf作为串口打印输出函数。代替usart_send_string()函数
步骤:
usart.c中包含USART初始化函数
1、USART初始化(使能时钟、使能GPIO、GPIO和USART初始化)
2、打开USART
3、在usart.c中加入如下代码
#ifdef __GNUC__
/* With GCC/RAISONANCE, small printf (option LD Linker->Libraries->Small printf
set to 'Yes') calls __io_putchar() */
#define PUTCHAR_PROTOTYPE int __io_putchar(int ch)
#else
#define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f)
#endif /* __GNUC__ */
/*******************