how to retarget newlib printf scanf to embedded systemUART ?
wayne lee
wnlee@cad.csie.ncku.edu.tw
Fri Aug 6 05:18:00 GMT 2004
Hi folks,
I successfully use GNU arm-elf toolchain to build a ROM image.
My program is linked with newlib.
Now, I am wonder how to retarget newlib stdin, stdout to UART
Does anyone who can give me hints?
Wayne
--
I have ever use ARM ADS1.2 to build ROM image.
ADS provides a retarget mechanism likes bellows:
struct __FILE { int handle; /* Add whatever you need here */};
FILE __stdout;
FILE __stdin;
void _ttywrch(int ch)
{
char tempch = ch;
write_ch_to_uart( &tempch );
}
int fputc(int ch, FILE *p_fd)
{
/* Place your implementation of fputc here */
/* e.g. write a character to a UART, or to the */
/* debugger console with SWI WriteC */
char tempch = ch;
write_ch_to_uart(&tempch);
return ch;
}
int fgetc(FILE *p_fd)
{
/* Place your implementation of fgetc here */
/* e.g. read a character from a UART, or from the */
/* debugger console with SWI ReadC */
char ch;
ch = get_ch_from_uart();
return ch;
}
More information about the Newlib
mailing list