retarget printf to uart?
Jesper Vestergaard
openocd@jespervestergaard.dk
Wed May 27 16:10:00 GMT 2009
Jesper Vestergaard wrote:
> Hi guys
>
> I have been trying to retarget the printf in newlib so i can use it on
> a Icnova / Grasshopper avr32 board. I use the avr32 toolchain which
> uses newlib 1.16.0.
>
> I have read on a forum that i must implement _write_r in my code so
> that i use the uart but it doesn't work. How do i proper retarget the
> printf?
>
> Best regards
> Jesper
>
>
Btw i'm using FreeRTOS which i guess should be treated as a standalone
application.
Here's a snip of the code i have tried:
int putchar2(int c)
{
return usart_putchar(&AVR32_USART1,c);
}
int _write_r(void *reent, int fd, char *ptr, size_t len)
{
size_t i;
for (i=0; i<len; i++)
{
putchar2( ptr[i]);
}
return len;
}
int main(void)
{
printf("testing");
}
More information about the Newlib
mailing list