cancel
Showing results for 
Search instead for 
Did you mean: 

PUTCHAR_PROTOTYPE

shaolei198
Associate II
Posted on May 02, 2012 at 03:04

#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__ */
 Can some one explain to me; what's the relationship between __io_putchar and fputc? are they from stand C library? and how it is related to printf() that is used in USART comunications? thanks a lot.

1 REPLY 1
Posted on May 02, 2012 at 04:03

Consider that the tool chain can't support serial output on every board with every UART combination. You have to provide a routine for your own board. The GNU and Keil/IAR compilers have different ways of doing it with their libraries, in the former case you're going to do this with a specific library, and a specific function, __io_putchar(). printf() then utilizes the character output routine to get the formatted string out the serial port.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..