I have implemented fputc
and fgetc
in retarget.c to successfully use printf via UART0 on a Cortex-M3.
However, I want a second uart channel for additional debug information. How can I integrate this as nicely as I can UART0 using printf?
For example, using fprintf to a custom target and checking in fputc
which target to send the character to..
E.g. for normal output fprintf(UART0,"..");
and for debug output fprintf(UART1,"..");
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.
Perhaps some way to differentiate between stdout and stderr, although then I still have the same problem for getting input from the two separate channels.
Also is fprintf in the microlib? If not, is there a better way to implement this?
Thanks!