Retargeting getchar() function
To answer (or more precisely, not answer) your first question, I’ve never tried redirecting specific stdio library functions, I’ve always used some variant of the code I posted above to redirect everything, so I’m afraid I can’t answer that question for you.
I don’t normally use the ST HAL code, so I’m not familiar with the calling convention for the HAL_UART_Transmit() function, but I’ll make a general point here (forgive me if I’m stating the obvious): Make sure that the transmit function you call is done in such a way that it will “block” until the transmission is completed; that is, it does not return until it has completed transmitting the data you provide, or it will block if called again and the UART is still busy transmitting the last character or string passed to it.
As for how to get the gray box code highlight, you use this syntax:
{CODE(wrap=>1)} your code here... Note: Still chokes when the less-than or greater-than symbols are encountered. e.g. #include [stdio.h] // replace '[' and ']' with less/greater than symbols {CODE}
It took me a while to figure out how to get help on wiki syntax here. Start by selecting the small blue “?” symbol in the upper right hand corner of the edit window.
Then click on the “Wiki Syntax” link (near top of pop up dialog).
Then select the “Wiki Syntax Help” link on the page that comes up.
One could wish that the CODE segments were rendered using a monospaced font. This is normally the case for most forums, but not this one.