00001 /********************************************************* 00002 * Function: debug library 00003 * 00004 * File: debug.c 00005 * Author: Book Chen 00006 * Date 2009.07.06 00007 *********************************************************** 00008 */ 00009 #include "includes.h" 00010 /***************** 00011 * DebugBufferDump: 00012 * Dump buffer data 00013 * print 16 characters per line 00014 * like 00h xx xx xx xx xx xx xx xx .... xx 00015 ****************** 00016 */ 00017 void DebugBufferDump(INT8U *pData,INT32U Length){ 00018 INT8U LineByteCounter,LineCounter; 00019 INT32U i; 00020 00021 LineByteCounter=0; 00022 LineCounter=0; 00023 //while(Length>0){ 00024 for(i=0;i<Length;i++){ 00025 if(LineByteCounter==16){ 00026 LineByteCounter=0; 00027 LineCounter++; 00028 } 00029 if(LineByteCounter==0){ 00030 DebugStringPrint("\n\r"); 00031 DebugHex2AsciiInt8uPrint(LineCounter); 00032 DebugStringPrint("h"); 00033 } 00034 LineByteCounter++; 00035 DebugStringPrint(" "); 00036 DebugHex2AsciiInt8uPrint(*pData); 00037 pData++; 00038 //Length--; 00039 } 00040 } 00041 /***************** 00042 * DebugFirmwareInfoShow: 00043 * show firmware information 00044 * include address in spi flash,file length,file checksum 00045 ****************** 00046 */ 00047 void DebugFirmwareInfoShow(FIRMWARE_ENTRY *pFirmware){ 00048 if(pFirmware->HasFirmware==TRUE){ 00049 DebugStringPrint("\n\r address: "); 00050 DebugHex2AsciiInt32uPrint(pFirmware->Address); 00051 DebugStringPrint(" length: "); 00052 DebugHex2AsciiInt32uPrint(pFirmware->Length); 00053 DebugStringPrint(" checksum: "); 00054 DebugHex2AsciiInt8uPrint(pFirmware->Checksum); 00055 } 00056 else{ 00057 DebugStringPrint("\r\n firmware 10 does not exist."); 00058 } 00059 } 00060 /***************** 00061 * DebugHex2AsciiInt8uPrint: 00062 * show unsigned char value 00063 ****************** 00064 */ 00065 void DebugHex2AsciiInt8uPrint(INT8U Data){ 00066 INT8U i; 00067 00068 i=Data&0xf0; 00069 i=i>>4; 00070 i=SystemlibHex2AsciiCharGet(i); 00071 Uart1CharTx(i); 00072 i=Data&0x0f; 00073 i=SystemlibHex2AsciiCharGet(i); 00074 Uart1CharTx(i); 00075 } 00076 /***************** 00077 * DebugHex2AsciiInt16uPrint: 00078 * show unsigned int value (16 bit) 00079 ****************** 00080 */ 00081 void DebugHex2AsciiInt16uPrint(INT16U Data){ 00082 INT8U i; 00083 00084 i=(INT8U)((Data&0xf000)>>12); 00085 i=SystemlibHex2AsciiCharGet(i); 00086 Uart1CharTx(i); 00087 00088 i=(INT8U)((Data&0x0f00)>>8); 00089 i=SystemlibHex2AsciiCharGet(i); 00090 Uart1CharTx(i); 00091 00092 i=(INT8U)((Data&0x00f0)>>4); 00093 i=SystemlibHex2AsciiCharGet(i); 00094 Uart1CharTx(i); 00095 00096 i=(INT8U)(Data&0x000f); 00097 i=SystemlibHex2AsciiCharGet(i); 00098 Uart1CharTx(i); 00099 } 00100 /***************** 00101 * DebugHex2AsciiInt32uPrint: 00102 * show unsigned long value (32 bit) 00103 ****************** 00104 */ 00105 void DebugHex2AsciiInt32uPrint(INT32U Data){ 00106 INT8U i; 00107 00108 i=(INT8U)((Data&0xf0000000)>>28); 00109 i=SystemlibHex2AsciiCharGet(i); 00110 Uart1CharTx(i); 00111 00112 i=(INT8U)((Data&0x0f000000)>>24); 00113 i=SystemlibHex2AsciiCharGet(i); 00114 Uart1CharTx(i); 00115 00116 i=(INT8U)((Data&0x00f00000)>>20); 00117 i=SystemlibHex2AsciiCharGet(i); 00118 Uart1CharTx(i); 00119 00120 i=(INT8U)((Data&0x000f0000)>>16); 00121 i=SystemlibHex2AsciiCharGet(i); 00122 Uart1CharTx(i); 00123 00124 i=(INT8U)((Data&0x0000f000)>>12); 00125 i=SystemlibHex2AsciiCharGet(i); 00126 Uart1CharTx(i); 00127 00128 i=(INT8U)((Data&0x00000f00)>>8); 00129 i=SystemlibHex2AsciiCharGet(i); 00130 Uart1CharTx(i); 00131 00132 i=(INT8U)((Data&0x000000f0)>>4); 00133 i=SystemlibHex2AsciiCharGet(i); 00134 Uart1CharTx(i); 00135 00136 i=(INT8U)(Data&0x0000000f); 00137 i=SystemlibHex2AsciiCharGet(i); 00138 Uart1CharTx(i); 00139 } 00140 /***************** 00141 * DebugStringPrint: 00142 * show string 00143 ****************** 00144 */ 00145 void DebugStringPrint(const char *pString){ 00146 Uart1StringTx(pString); 00147 } 00148