From 5700cf96d55aebaf6fce714d8d2b626ecc19bd6a Mon Sep 17 00:00:00 2001 From: geeksville Date: Fri, 17 Jul 2020 09:14:23 -0700 Subject: [PATCH] redefine printf to use the segger output system (NRF52) --- src/nrf52/main-nrf52.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/nrf52/main-nrf52.cpp b/src/nrf52/main-nrf52.cpp index d2fd1e060..08d2baf00 100644 --- a/src/nrf52/main-nrf52.cpp +++ b/src/nrf52/main-nrf52.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #ifdef NRF52840_XXAA // #include @@ -63,6 +64,18 @@ void setBluetoothEnable(bool on) } } +/** + * Override printf to use the SEGGER output library + */ +int printf(const char *fmt, ...) +{ + va_list args; + va_start(args, fmt); + auto res = SEGGER_RTT_vprintf(0, fmt, &args); + va_end(args); + return res; +} + void nrf52Setup() { @@ -84,4 +97,5 @@ void nrf52Setup() // ble_controller_rand_vector_get_blocking(&r, sizeof(r)); // randomSeed(r); DEBUG_MSG("FIXME, call randomSeed\n"); + // ::printf("TESTING PRINTF\n"); } \ No newline at end of file