STM32 fprint的使用问题
我知道在stm32的程序中包含标准的stdio.h文件,对fprint函数重写,就可以使用fprint函数打印串口输出内容,具体是怎么实现的呢?添加Retarget.c文件,修改fputc函数
自己添加就行 小蚂蚁快溜跑 发表于 2015-4-30 12:05
添加Retarget.c文件,修改fputc函数
#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__ */
PUTCHAR_PROTOTYPE
{
#ifdef Gokit
//Place your implementation of fputc here , e.g. write a character to the USART
USART_SendData(USART1,(u8)ch);
//Loop until the end of transmission
while (USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET);
#endif
#ifdef STUNO
//Place your implementation of fputc here , e.g. write a character to the USART
USART_SendData(USART1,(u8)ch);
//Loop until the end of transmission
while (USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET);
#endif
#ifdef Xnucleo
//Place your implementation of fputc here , e.g. write a character to the USART
USART_SendData(USART3,(u8)ch);
//Loop until the end of transmission
while (USART_GetFlagStatus(USART3, USART_FLAG_TXE) == RESET);
#endif是这样。 hbzjt2012 发表于 2015-4-30 13:11
是这样。
无返回值啊
页:
[1]