Add missing undefined symbols to be sure to use mine

Dependents:   DS130x_I2CApp MCP41xxxApp FM24Vxx_I2CApp MCP320xApp ... more

Revision:
4:d03fcf494eb6
Parent:
0:311a0646b95a
Child:
5:7ddb6bca6d01
--- a/Debug.cpp	Wed Nov 24 12:30:18 2010 +0000
+++ b/Debug.cpp	Wed Dec 08 13:16:16 2010 +0000
@@ -9,13 +9,70 @@
   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[91];
+    memset(line, 0x20, 91);
+    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[89] = 0x0d;
+        line[90] = 0x0a;    
+        printf(line);
+        if (currentIdx < endOfDump) { // Prepare next line, one line = 16 digits
+            startAddress += 16;
+            memset(line, 0x20, 91);
+            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