This is the mail archive of the newlib@sources.redhat.com mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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;
}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]