Add missing undefined symbols to be sure to use mine
Dependents: DS130x_I2CApp MCP41xxxApp FM24Vxx_I2CApp MCP320xApp ... more
Debug.cpp
- Committer:
- Yann
- Date:
- 2010-12-08
- Revision:
- 5:7ddb6bca6d01
- Parent:
- 4:d03fcf494eb6
- Child:
- 6:14a596126adf
File content as of revision 5:7ddb6bca6d01:
#include <cstdarg> #include "Debug.h" #ifdef __DEBUG #define __LINE_LENGTH__ 91 void DebugHelper::Debug(const char* p_format, ...) { va_list argp; va_start(argp, p_format); vprintf(p_format, argp); va_end(argp); } // End of method DebugHelper::Debug void DebugHelper::HexaDump(unsigned char* p_buffer, int p_count, int p_offset) { int currentIdx = p_offset; unsigned short startAddress = ((unsigned short)(p_offset / 16)) * 16; DEBUG(">>> %d - %d - %d - %d - %d", p_count, p_offset, p_count + p_offset, currentIdx / 16, currentIdx % 16); // Display header printf(" HEX | 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F : 0 1 2 3 4 5 6 7 8 9 A B C D E F \r\n"); printf("-----|+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+-:--+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\r\n"); // 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 // 0 1 2 3 4 5 6 7 8 9 // Address offset padding char line[__LINE_LENGTH__]; memset(line, 0x20, __LINE_LENGTH__); sprintf(line, "%04x |", (unsigned short)startAddress); line[6] = 0x20; // Remove NULL character added by sprintf int idx = 0; int hexOffset = 7; int charOffset = 58; for ( ; idx < (int)(currentIdx % 16); idx++) { line[hexOffset] = 0x30; line[hexOffset + 1] = 0x30; hexOffset += 3; charOffset += 2; } // Fill line by line int endOfDump = p_count + p_offset; while(currentIdx < endOfDump) { for ( ; (idx < 16) && (currentIdx < endOfDump); idx++) { line[hexOffset] = DebugHelper::ToHexDigit(*(p_buffer + currentIdx) >> 4); line[hexOffset + 1] = DebugHelper::ToHexDigit(*(p_buffer + currentIdx) & 0x0f); line[charOffset] = DebugHelper::ToCharDigit(*(p_buffer + currentIdx)); // Prepare next byte hexOffset += 3; charOffset += 2; currentIdx += 1; } // Display the line line[56] = ':'; line[__LINE_LENGTH__ - 2] = 0x0d; line[__LINE_LENGTH__ - 1] = 0x0a; printf(line); if (currentIdx < endOfDump) { // Prepare next line, one line = 16 digits startAddress += 16; memset(line, 0x20, __LINE_LENGTH__); sprintf(line, "%04x |", (unsigned short)startAddress); line[6] = 0x20; // Remove NULL character added by sprintf idx = 0; hexOffset = 7; charOffset = 58; } else { // End of line padding break; } } // End of 'while' statement } // End of method DebugHelper::HexaDump void DebugHelper::BreakPoint(const char* p_file, int p_line) { printf("Stop in %s at line %d\r\n", p_file, p_line); fflush(stdout); getchar(); fflush(stdin); } // End of method DebugHelper::BreakPoint #endif // __DEBUG