From 9278e9bafd96105b64f9946eb94f5618f01649d3 Mon Sep 17 00:00:00 2001 From: Paul Selkirk Date: Thu, 29 Oct 2015 15:42:29 -0400 Subject: add libhal tests, some cleanup (some mess-making) --- libc/printf.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) (limited to 'libc/printf.c') diff --git a/libc/printf.c b/libc/printf.c index 78f210a..695fcd7 100644 --- a/libc/printf.c +++ b/libc/printf.c @@ -47,6 +47,7 @@ mod: N near ptr DONE *****************************************************************************/ #include /* strlen() */ #include /* stdout, putchar(), fputs() (but not printf() :) */ +#undef putchar #if 1 #include /* va_list, va_start(), va_arg(), va_end() */ @@ -93,15 +94,9 @@ typedef void *va_list; #define PR_WS 0x20 /* PR_SG set and num was < 0 */ #define PR_LZ 0x40 /* pad left with '0' instead of ' ' */ #define PR_FP 0x80 /* pointers are far */ -#if 0 -/* largest number handled is 2^32-1, lowest radix handled is 8. -2^32-1 in base 8 has 11 digits (add 5 for trailing NUL and for slop) */ -#define PR_BUFLEN 16 -#else /* largest number handled is 2^64-1, lowest radix handled is 8. 2^64-1 in base 8 has 22 digits (add 2 for trailing NUL and for slop) */ #define PR_BUFLEN 24 -#endif typedef int (*fnptr_t)(unsigned c, void **helper); /***************************************************************************** @@ -410,3 +405,22 @@ int main(void) return 0; } #endif + +/***************************************************************************** +2015-10-29 pselkirk for cryptech +*****************************************************************************/ +/* gcc decides that a plain string with no formatting is best handled by puts() */ +int puts(const char *s) +{ + return printf("%s\n", s); +} + +/* transmit characters to the uart */ +#include "stm-uart.h" +int putchar(int c) +{ + if (c == '\n') + uart_send_char('\r'); + uart_send_char((uint8_t) c); + return c; +} -- cgit v1.2.3