add dbgDumpMemoryCFormat()

This commit is contained in:
hathach committed 2018-02-02 22:13:36 +07:00
1 parent f5c869a86b
commit 7487320265
2 files changed
+39 -5

No files matched your search

+38 -5
View File
@@ -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<count; i++)
{
uint32_t value=0;
if ( i%16 == 0 )
{
if ( i != 0 ) cprintf(",\n ");
}else
{
if ( i != 0 ) cprintf(", ");
}
cprintf("0x%02lX", *buf8);
buf8++;
}
cprintf("\n\};\n");
}
#if CFG_DEBUG
#include "ble.h"
+1
View File
@@ -62,6 +62,7 @@ static inline int dbgHeapFree(void)
void dbgMemInfo(void);
void dbgPrintVersion(void);
void dbgDumpMemory(void const *buf, uint8_t size, uint16_t count, bool printOffset);
void dbgDumpMemoryCFormat(const char* str, void const *buf, uint16_t count);
#ifdef __cplusplus
}