Using two UARTs with fprintf

Discussion created by lpcware Employee on Jun 15, 2016
Content originally posted in LPCWare by mk1 on Fri Dec 21 11:16:28 MST 2012
Hi all,

I have implemented fputc and fgetc in retarget.c to successfully use printf via UART0.

However, I want a second uart channel for additional debug information.

How can I integrate this as nicely as I can UART0 using printf. I am guessing that using fprintf to specify a custom target would be the way to go? Perhaps using a #define to wrap it up nicely.

But I cannot see if fopen is called for stdout so I am struggling to see how to manually implement this. (If I just call fprintf(RANDOM_VALUE,..), I don't know how this will behave.

I guess that once I have it directed to a different 'FILE', then it is simply a matter of checking which is being pointed to within fputc but it is the initial setting of the FILE pointer that I am struggling with.

Also is fprintf in the microlib? If not, is there a better way to implement this?