📄 debugtask.c
字号:
c [ i ] = '\0';
}
else if( rem >= 0x00 && rem <= 0x09 )
{
/* Cases of the rest is 0 -- 9, then + 0x30 */
c [ i ] = ( CHAR ) (rem + 0x30);
}
else if( rem >= 0x0A && rem <= 0x0F )
{
/* Cases of the rest is 0x0a -- 0x0f, then + 0x37 */
c [ i ] = ( CHAR ) ( rem + 0x37 );
}
else
{
/* Never come here */
break;
}
Val = quot;
}
/* Insert 0 in case of it is all NULL in decimal */
if( mode == PRINT_DECIMAL_MODE )
{
if( i <= 0 )
{
*str = '0';
}
}
/* Get length of string */
strLen = strlen(c);
j = 0;
/* String change */
for( i = 0 ; i < type ; i++ )
{
if( mode == PRINT_DECIMAL_MODE )
{
if( c[ i ] != '\0' )
{
/* Output specified string */
*( str + j ) = c[ i ];
j++;
}
}
else
{
if( i >= strLen)
{
/* Output 0 in case of it exceed specified string */
*( str + ( type - 1 ) - i ) = '0';
}
else
{
/* Output specified string */
*( str + ( type - 1 ) - i ) = c[ strLen - i - 1];
}
}
}
}
/*
//=============================================================================
// Function_Name: PrintOut
// description : Print
// argument : ???
// return : ???
// flag : ???
// global : ???
//=============================================================================
*/
LONG PrintOut( CHAR* pStr )
{
UART_FuncSendText( 1, (UCHAR *)pStr );
return DBG_STATUS_SUCCESS;
}
/*
//=============================================================================
// Function_Name: DBG_WatchSetData
// description : Memory registration API
// argument :
// return :
// flag :
// global :
//=============================================================================
*/
long WatchSetData( const UCHAR* pName, UCHAR size, const UCHAR* pAddress )
{
INT i = 0;
/* Address registration */
Watch_Area.watchMember[Watch_Area.iSetCnt].address = (UCHAR *)pAddress;
/* Size registration */
switch ( size )
{
case DBG_STORE_BYTE:
Watch_Area.watchMember[Watch_Area.iSetCnt].size = DBG_VALUE_SIZE_BYTE;
break;
case DBG_STORE_WORD:
Watch_Area.watchMember[Watch_Area.iSetCnt].size = DBG_VALUE_SIZE_WORD;
break;
case DBG_STORE_DWORD:
Watch_Area.watchMember[Watch_Area.iSetCnt].size = DBG_VALUE_SIZE_DWORD;
break;
default :
break;
}
for( i = 0; i < 20; i++ )
{
/* Name registration */
if ( (UCHAR)*((UCHAR *)pName + i) == '\0' )
{
break;
}
else
{
*(Watch_Area.watchMember[Watch_Area.iSetCnt].name + i ) = (UCHAR)*((UCHAR *)pName + i);
}
}
/* Registration count up */
Watch_Area.iSetCnt++;
return DBG_STATUS_SUCCESS;
}
/*
//=============================================================================
// description : Flow output API ( string )
// argument :
// return :
// flag :
// global :
//=============================================================================
*/
long FlowStrPrint ( CHAR* pString , UCHAR level )
{
if( FlowToggle == TRUE )
{
if ( level >= FlowLevel )
{
/* Output string */
UART_FuncSendText( 1, (UCHAR*)pString );
}
}
return DBG_STATUS_SUCCESS;
}
/*
//=============================================================================
// description : Flow output API ( numeric value )
// argument :
// return :
// flag :
// global :
//=============================================================================
*/
long FlowValPrint ( UCHAR printType, UCHAR dataSize, LONG value , UCHAR level)
{
CHAR string[DBG_STR_MAX]; // String for editing
if( FlowToggle == TRUE )
{
/* Parameter check */
switch ( dataSize )
{
case DBG_STORE_BYTE:
case DBG_STORE_WORD:
case DBG_STORE_DWORD:
break;
default:
return DBG_STATUS_PARAM_ERROR;
}
/* Initialization of string for editing */
memset( string , 0x00 , sizeof( string ) );
/* Output format */
switch( printType )
{
/* Output in decimal */
case PRINT_DECIMAL_MODE:
ValChangeStr( string , (ULONG)value , dataSize * 2 , PRINT_DECIMAL_MODE );
break;
/* Output in hexadecimal */
case PRINT_HEXA_MODE:
ValChangeStr( string , (ULONG)value , dataSize * 2 , PRINT_HEXA_MODE );
break;
default:
return DBG_STATUS_PARAM_ERROR;
}
if ( level >= FlowLevel )
{
/* Output string */
UART_FuncSendText( 1, (UCHAR*)string );
}
}
return DBG_STATUS_SUCCESS;
}
/*
//=============================================================================
// description : Flow output API ( string & numeric value )
// argument :
// return :
// flag :
// global :
//=============================================================================
*/
long FlowPrint ( CHAR* pString, UCHAR printType, UCHAR dataSize, LONG value , UCHAR level)
{
CHAR string[DBG_STR_MAX]; // String for editing
if( FlowToggle == TRUE )
{
/* Parameter check */
switch ( dataSize )
{
case DBG_STORE_BYTE:
case DBG_STORE_WORD:
case DBG_STORE_DWORD:
break;
default:
return DBG_STATUS_PARAM_ERROR;
}
/* Initialization of string for editing */
memset( string , 0x00 , sizeof( string ) );
/* Output format */
switch( printType )
{
/* Output in decimal */
case PRINT_DECIMAL_MODE:
ValChangeStr( string , (ULONG)value , dataSize * 2 , PRINT_DECIMAL_MODE );
break;
/* Output in hexadecimal */
case PRINT_HEXA_MODE:
ValChangeStr( string , (ULONG)value , dataSize * 2 , PRINT_HEXA_MODE );
break;
default:
return DBG_STATUS_PARAM_ERROR;
}
if ( level >= FlowLevel )
{
/* Output string */
UART_FuncSendText(1, ( UCHAR *)pString );
UART_FuncSendText(1, ( UCHAR *)" = " );
UART_FuncSendText(1, (UCHAR *)string );
}
}
return DBG_STATUS_SUCCESS;
}
/*
//=============================================================================
// Function_Name: FlowGetStr
// description : Waiting for input without string comparison
// argument : const UCHAR *pString
// : USHORT dataSize
// : OS_TMP tmout ( Wait until 0 is inputted )
// return : LONG
//=============================================================================
*/
LONG FlowGetStr( CHAR* pString, USHORT* pDataSize, OS_TMO tmout )
{
#ifndef ECHO_OFF
unsigned char temp;
unsigned short rcvdSize = 0;
while(1){
temp = '\n';
UART_FuncReceiveData( 1, 1, &temp );
if( temp == '\r' || temp == '\n' ){
pString[rcvdSize] = (unsigned char)NULL; // NULL setting
break;
}else if( temp == '\b' ){
if( rcvdSize > 0 ){
UART_FuncSendText( 1, (unsigned char *)("\b \b") );
rcvdSize--;
pString[rcvdSize] = 0; // Erase received string with 0
}else{
// Ignore backspace for 0th byte
}
}else{
UART_FuncSendData( 1, 1, &temp );
pString[rcvdSize] = temp;
rcvdSize++;
}
}
*pDataSize = rcvdSize;
#else // ECHO_ON
UART_FuncReceiveText( 1, 80, pString, pDataSize);
#endif // ECHO_OFF
UART_FuncSendText ( 1, (unsigned char *)("\r\n>") );
return DBG_STATUS_SUCCESS;
}
/*
//=============================================================================
// Function_Name: FlowGetStr
// description : Waiting for input without string comparison
// argument : const UCHAR *pString
// : USHORT dataSize
// : OS_TMP tmout ( Wait until 0 is inputted )
// return : LONG
//=============================================================================
*/
static LONG GetStr( CHAR* pString, USHORT* pDataSize, OS_TMO tmout )
{
#ifndef ECHO_OFF
unsigned char temp;
unsigned short rcvdSize = 0;
while(1){
temp = '\n';
UART_FuncReceiveData( 1, 1, &temp );
if( temp == '\r' || temp == '\n' ){
pString[rcvdSize] = (unsigned char)NULL; // NULL setting
break;
}else if( temp == '\b' ){
if( rcvdSize > 0 ){
UART_FuncSendText( 1, (unsigned char *)("\b \b") );
rcvdSize--;
pString[rcvdSize] = 0; // Erase received string with 0
}else{
// Ignore backspace for 0th byte
}
}else{
UART_FuncSendData( 1, 1, &temp );
pString[rcvdSize] = temp;
rcvdSize++;
}
}
*pDataSize = rcvdSize;
#else // ECHO_ON
UART_FuncReceiveText( 1, 80, pString, pDataSize);
#endif // ECHO_OFF
UART_FuncSendText( 1, (unsigned char *)("\r\n") );
return DBG_STATUS_SUCCESS;
}
/*
//=============================================================================
// Function_Name: FlowGetStrCmp
// description : Wait until specified string by pString is inputted
// argument : const UCHAR *pString
// : USHORT dataSize
// : OS_TMP tmout ( Wait until 0 is inputted )
// return : LONG
//=============================================================================
*/
LONG FlowGetStrCmp( const UCHAR* pString, USHORT dataSize, OS_TMO tmout )
{
unsigned char buf[80];
#ifndef ECHO_OFF
unsigned char temp;
unsigned short rcvdSize = 0;
while(1){
while(1){
temp = '\n';
UART_FuncReceiveData( 1, 1, &temp );
if( temp == '\r' || temp == '\n' ){
buf[rcvdSize] = (unsigned char)NULL; // NULL setting
break;
}
if( temp == '\b' ){
if( rcvdSize > 0 ){
UART_FuncSendText( 1, (unsigned char *)("\b \b") );
rcvdSize--;
buf[rcvdSize] = (unsigned char )NULL; // Erase received string with 0
}else{
// Ignore backspace for 0th byte
}
}else{
UART_FuncSendData( 1, 1, &temp );
buf[rcvdSize] = temp;
rcvdSize++;
}
// Received all data of numbers requested
if( rcvdSize < dataSize ){
break;
}
}
if( memcmp( pString, buf, dataSize ) == 0 )
break;
}
#else // ECHO_ON
unsigned short wReadSize;
while( 1 ){
UART_FuncReceiveText( 1, sizeof(buf), buf, &wReadSize);
if( wReadSize == dataSize ){
if( memcmp( pString, buf, dataSize ) == 0 )
break;
}
}
#endif // ECHO_OFF
UART_FuncSendText( 1, (unsigned char *)("\r\n>") );
return DBG_STATUS_SUCCESS;
}
// Add for Analog evaluation use
/*
//=============================================================================
// Function_Name: FlowKeyHit
// description : Input interrupt notification without string comparison
// argument : CALLBACK_PROC pfnCallback
// return : LONG
//=============================================================================
*/
LONG FlowKeyHit( CALLBACK_PROC pfnCallback )
{
KeyCallback = pfnCallback;
static unsigned char key;
UART_FuncReceiveDataA( 1, 1, &key, UART_Callback );
return DBG_STATUS_SUCCESS;
}
short UART_Callback( unsigned short wMsg, unsigned short wParam0, void *pParam1 )
{
KeyCallback(0, 0, 0);
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -