From 3c367d7cc3ca0f5662e39bb8e08d39d3d69ab1ad Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Wed, 25 Nov 2020 22:07:47 +0100 Subject: [PATCH] msp432p401lp-cc256x: implement puts and putchar --- port/msp432p401lp-cc256x/main.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/port/msp432p401lp-cc256x/main.c b/port/msp432p401lp-cc256x/main.c index f8a857b99..a0292d79e 100755 --- a/port/msp432p401lp-cc256x/main.c +++ b/port/msp432p401lp-cc256x/main.c @@ -101,9 +101,6 @@ int _fstat(int file){ return -1; } -// with current Makefile, compiler, and linker flags, printf will call malloc -> sbrk -// we define printf, but compiler will replace call to printf with call to puts, which causes malloc -> sbrk again - // end of bss, start of heap extern int _end; void * _sbrk(int incr){ @@ -124,11 +121,22 @@ void * _sbrk(int incr){ int SEGGER_RTT_vprintf(unsigned BufferIndex, const char * sFormat, va_list * pParamList); +// gcc/clang map printf to puts or putchar for printf("...\n"), or printf("%c", c) respectively + +int puts(const char * s){ + SEGGER_RTT_WriteString(0, s); + SEGGER_RTT_PutChar(0, '\n'); +} + +int putchar(int c){ + SEGGER_RTT_PutChar(0, c); +} + int printf(const char * format, ...){ va_list argptr; va_start(argptr, format); SEGGER_RTT_vprintf(0, format, &argptr); - va_end(argptr); + va_end(argptr); } int vprintf(const char * format, va_list argptr){