This is the mail archive of the
newlib@sources.redhat.com
mailing list for the newlib project.
how to retarget newlib printf scanf to embedded systemUART ?
- From: "wayne lee" <wnlee at cad dot csie dot ncku dot edu dot tw>
- To: <newlib at sources dot redhat dot com>
- Date: Fri, 6 Aug 2004 11:20:10 +0800
- Subject: how to retarget newlib printf scanf to embedded systemUART ?
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;
}