00001
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048 #include <stdlib.h>
00049 #include <string.h>
00050 #include "FreeRTOS.h"
00051 #include "task.h"
00052
00053 #include "serial.h"
00054 #include "tracedump.h"
00055
00056
00058 #define dumpCOM2_BAUDRATE ( ( unsigned portLONG ) 57600 )
00060 #define dumpCOM2_BUFFER_LEN ( ( unsigned portLONG ) 64 )
00061
00063
00064 #define TRACE_MSG_BANNER "\x0C\r\n---------- Traces Dump \r\n"
00065
00066 #define DUMPCOM2_NO_BLOCK ( ( portTickType ) 0 )
00067
00069 static xComPortHandle xComPort2Hndl = (xComPortHandle)NULL;
00070
00076 int itracedump_Init( void )
00077 {
00078 int iStatus = DUMP_SUCCESS;
00079
00080
00081
00082
00083
00084 xComPort2Hndl = xUsartInit(serCOM2, dumpCOM2_BAUDRATE, 0, dumpCOM2_BUFFER_LEN);
00085 if(xComPort2Hndl == 0)
00086 return(DUMP_FAILURE);
00087
00088
00089
00090
00091 vtracedump_PrintBlocking((const signed portCHAR * const)TRACE_MSG_BANNER);
00092
00093 return(iStatus);
00094 }
00095
00099 void v_tracedump_stopResources( void )
00100 {
00101 vSerialClose( xComPort2Hndl );
00102 }
00103
00110 unsigned portSHORT ustracedump_Print(const signed portCHAR * const pcString)
00111 {
00112 return( usUsartPutString( xComPort2Hndl, pcString, strlen( (const portCHAR * )pcString ) ) );
00113 }
00114
00115
00121 void vtracedump_PrintBlocking(const signed portCHAR * const pcString)
00122 {
00123 unsigned portSHORT usRemainChar = 0;
00124 unsigned portSHORT usMsgLen = strlen((const portCHAR * )pcString);
00125
00126 usRemainChar = usMsgLen;
00127 do{
00128 usRemainChar = usUsartPutString( xComPort2Hndl,
00129 (const signed portCHAR * const)(pcString + usMsgLen - usRemainChar),
00130 usRemainChar );
00131 }while( usRemainChar );
00132 }
00133
00134
00140 void vtracedump_Putchar(signed portCHAR cByte )
00141 {
00142 xUsartPutChar( xComPort2Hndl, cByte, DUMPCOM2_NO_BLOCK );
00143 }
00144
00150 void vtracedump_Putchar_Block(signed portCHAR cByte )
00151 {
00152 xUsartPutChar( xComPort2Hndl, cByte, -1 );
00153 }