From 7487320265a85eacca808a46edbe249b3fca39a6 Mon Sep 17 00:00:00 2001 From: hathach Date: Fri, 2 Feb 2018 22:13:36 +0700 Subject: [PATCH] add dbgDumpMemoryCFormat() --- cores/nRF5/utility/debug.cpp | 43 +++++++++++++++++++++++++++++++----- cores/nRF5/utility/debug.h | 1 + 2 files changed, 39 insertions(+), 5 deletions(-) diff --git a/cores/nRF5/utility/debug.cpp b/cores/nRF5/utility/debug.cpp index 18a5df53..cb29e287 100644 --- a/cores/nRF5/utility/debug.cpp +++ b/cores/nRF5/utility/debug.cpp @@ -171,6 +171,11 @@ void dbgPrintVersion(void) cprintf("\n"); } +/******************************************************************************/ +/*! + @brief Helper function to display memory contents in a friendly format +*/ +/******************************************************************************/ static void dump_str_line(uint8_t const* buf, uint16_t count) { // each line is 16 bytes @@ -181,11 +186,6 @@ static void dump_str_line(uint8_t const* buf, uint16_t count) } } -/******************************************************************************/ -/*! - @brief Helper function to display memory contents in a friendly format -*/ -/******************************************************************************/ void dbgDumpMemory(void const *buf, uint8_t size, uint16_t count, bool printOffset) { if ( !buf ) @@ -253,6 +253,39 @@ void dbgDumpMemory(void const *buf, uint8_t size, uint16_t count, bool printOffs } +void dbgDumpMemoryCFormat(const char* str, void const *buf, uint16_t count) +{ + if ( !buf ) + { + cprintf("NULL\n"); + return; + } + + cprintf("%s = \n{\n ", str); + + uint8_t const *buf8 = (uint8_t const *) buf; + + for(int i=0; i