Closed vidavidorra closed 8 years ago
Both the stdout
and stderr
streams redirect their messages to the UART1.
After some testing in the code I found out that using printf drastically increases the size if implemented a lot. For example 57% with all Uart1_printf
calls replaced by printf
calls compared to 48% when using Uar1_printf
...
So for now I will be sticking with the uart printf!
I've created defines for uprintf
, uputc
, uputs
, uputnum
and uputbits
macros which are currently redirected to the Uart1_
equivalents.
From now on those functions should always be used for printing. That allows a easy change of stream.
Background info
Currently the custom
Uart1_printf
function is used which requires the following includes:This results in a rather large increasement in the amount of bytes used in the program register (25% to 44% on 60663 bytes of programming memory). Using the standard printf function reduces this according to the functionality used. For example when only using printing a string without formatting, it goes from 25% to 26%, and when using formatting it goes to about 30%. So this is quite a difference that is very welcome.
Steps
stderr
and alike streams;Uart1_NNN
functions inside a#if 0
equally block;Uart1_printf
with calls toprintf
idem forputc
andputs
;assert
anddebug
see if it should use the same stream as the standard output or whether a different stream could be used and implement those features accordingly;printf
,puts
orputc
for the functionsUart1_putNum
andUart1_putBits
and implement those features. Otherwise rewrite the putNum and putBits functions to drop theUart1_
prefixes and useputc
for printing inside those functions;gets
-family functions could be used instead ofUar1_gets
and change those features accordingly.