Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use uppercase PRINTF.
This is a step in preparation for the ability to
change the default handler for printf(), such as
when advanced debug output capabilities make it
more performant to output via an alternative route.
  • Loading branch information
henrygab committed Mar 11, 2020
commit 4565d0cd7d1dd2a940e50e1137f6d2a7cac472ca
68 changes: 34 additions & 34 deletions cores/nRF5/utility/debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,14 @@ static void printMemRegion(const char* name, uint32_t top, uint32_t bottom, uint
sprintf(buffer, "%lu", top-bottom);
}

printf("| %-5s| 0x%04X - 0x%04X | %-19s |\n", name, (uint16_t) bottom, (uint16_t) (top-1), buffer);
PRINTF("| %-5s| 0x%04X - 0x%04X | %-19s |\n", name, (uint16_t) bottom, (uint16_t) (top-1), buffer);
}

void dbgMemInfo(void)
{
printf(" ______________________________________________\n");
printf("| Name | Addr 0x2000xxxx | Usage |\n");
printf("| ---------------------------------------------|\n");
PRINTF(" ______________________________________________\n");
PRINTF("| Name | Addr 0x2000xxxx | Usage |\n");
PRINTF("| ---------------------------------------------|\n");

// Pritn SRAM used for Stack executed by Softdevice and ISR
printMemRegion("Stack", ((uint32_t) __StackTop), ((uint32_t) __StackLimit), dbgStackUsed() );
Expand All @@ -127,29 +127,29 @@ void dbgMemInfo(void)
// Print SRAM Used by SoftDevice
printMemRegion("SD", (uint32_t) __data_start__, 0x20000000, 0);

printf("|______________________________________________|\n");
printf("\n");
PRINTF("|______________________________________________|\n");
PRINTF("\n");

// Print Task list
uint32_t tasknum = uxTaskGetNumberOfTasks();
char* buf = (char*) rtos_malloc(tasknum*40); // 40 bytes per task

vTaskList(buf);

printf("Task State Prio StackLeft Num\n");
printf("-----------------------------------\n");
printf(buf);
printf("\n");
PRINTF("Task State Prio StackLeft Num\n");
PRINTF("-----------------------------------\n");
PRINTF(buf);
PRINTF("\n");
rtos_free(buf);
}

void dbgPrintVersion(void)
{
printf("\n");
printf("BSP Library : " ARDUINO_BSP_VERSION "\n");
printf("Bootloader : %s\n", getBootloaderVersion());
printf("Serial No : %s\n", getMcuUniqueID());
printf("\n");
PRINTF("\n");
PRINTF("BSP Library : " ARDUINO_BSP_VERSION "\n");
PRINTF("Bootloader : %s\n", getBootloaderVersion());
PRINTF("Serial No : %s\n", getMcuUniqueID());
PRINTF("\n");
}

/******************************************************************************/
Expand All @@ -163,15 +163,15 @@ static void dump_str_line(uint8_t const* buf, uint16_t count)
for(int i=0; i<count; i++)
{
const char ch = buf[i];
printf("%c", isprint(ch) ? ch : '.');
PRINTF("%c", isprint(ch) ? ch : '.');
}
}

void dbgDumpMemory(void const *buf, uint8_t size, uint16_t count, bool printOffset)
{
if ( !buf || !count )
{
printf("NULL\n");
PRINTF("NULL\n");
return;
}

Expand All @@ -191,26 +191,26 @@ void dbgDumpMemory(void const *buf, uint8_t size, uint16_t count, bool printOffs
// Print Ascii
if ( i != 0 )
{
printf(" | ");
PRINTF(" | ");
dump_str_line(buf8-16, 16);
printf("\n");
PRINTF("\n");
}

// print offset or absolute address
if (printOffset)
{
printf("%03lX: ", 16*i/item_per_line);
PRINTF("%03lX: ", 16*i/item_per_line);
}else
{
printf("%08lX:", (uint32_t) buf8);
PRINTF("%08lX:", (uint32_t) buf8);
}
}

memcpy(&value, buf8, size);
buf8 += size;

printf(" ");
printf(format, value);
PRINTF(" ");
PRINTF(format, value);
}

// fill up last row to 16 for printing ascii
Expand All @@ -221,46 +221,46 @@ void dbgDumpMemory(void const *buf, uint8_t size, uint16_t count, bool printOffs
{
for(int i=0; i< 16-remain; i++)
{
printf(" ");
for(int j=0; j<2*size; j++) printf(" ");
PRINTF(" ");
for(int j=0; j<2*size; j++) PRINTF(" ");
}
}

printf(" | ");
PRINTF(" | ");
dump_str_line(buf8-nback, nback);
printf("\n");
PRINTF("\n");

printf("\n");
PRINTF("\n");
}


void dbgDumpMemoryCFormat(const char* str, void const *buf, uint16_t count)
{
if ( !buf )
{
printf("NULL\n");
PRINTF("NULL\n");
return;
}

printf("%s = \n{\n ", str);
PRINTF("%s = \n{\n ", str);

uint8_t const *buf8 = (uint8_t const *) buf;

for(uint32_t i=0; i<count; i++)
{
if ( i%16 == 0 )
{
if ( i != 0 ) printf(",\n ");
if ( i != 0 ) PRINTF(",\n ");
}else
{
if ( i != 0 ) printf(", ");
if ( i != 0 ) PRINTF(", ");
}

printf("0x%02X", *buf8);
PRINTF("0x%02X", *buf8);
buf8++;
}

printf("\n};\n");
PRINTF("\n};\n");
}


Expand Down
8 changes: 4 additions & 4 deletions cores/nRF5/verify.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,16 @@ extern "C"
#define VERIFY_MESS(_status, _functstr) VERIFY_MESS_impl(_status, _functstr, __PRETTY_FUNCTION__, __LINE__)
static inline void VERIFY_MESS_impl(int32_t _status, const char* (*_fstr)(int32_t), const char* func_name, int line_number)
{
printf("%s: %d: verify failed, error = ", func_name, line_number);
PRINTF("%s: %d: verify failed, error = ", func_name, line_number);
if (_fstr)
{
printf(_fstr(_status));
PRINTF(_fstr(_status));
}
else
{
printf("%ld", _status);
PRINTF("%ld", _status);
}
printf("\n");
PRINTF("\n");
}
#else
#define VERIFY_MESS(_status, _funcstr)
Expand Down
6 changes: 3 additions & 3 deletions libraries/Adafruit_LittleFS/src/littlefs/lfs_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,21 +56,21 @@ extern "C"
// Logging functions
#ifndef LFS_NO_DEBUG
#define LFS_DEBUG(fmt, ...) \
printf("lfs debug:%d: " fmt "\n", __LINE__, __VA_ARGS__)
PRINTF("lfs debug:%d: " fmt "\n", __LINE__, __VA_ARGS__)
#else
#define LFS_DEBUG(fmt, ...)
#endif

#ifndef LFS_NO_WARN
#define LFS_WARN(fmt, ...) \
printf("lfs warn:%d: " fmt "\n", __LINE__, __VA_ARGS__)
PRINTF("lfs warn:%d: " fmt "\n", __LINE__, __VA_ARGS__)
#else
#define LFS_WARN(fmt, ...)
#endif

#ifndef LFS_NO_ERROR
#define LFS_ERROR(fmt, ...) \
printf("lfs error:%d: " fmt "\n", __LINE__, __VA_ARGS__)
PRINTF("lfs error:%d: " fmt "\n", __LINE__, __VA_ARGS__)
#else
#define LFS_ERROR(fmt, ...)
#endif
Expand Down