📄 dp_debug.c
字号:
/********************** Filename: dp_debug.c *******************************/
/* ========================================================================= */
/* */
/* 0000 000 000 00000 0 000 0 0 0 0000 */
/* 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 */
/* 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Einsteinstra遝 6 */
/* 0000 000 0 0 000 0 0 00000 0 0000 91074 Herzogenaurach */
/* 0 00 0 0 0 0 0 0 0 0 0 */
/* 0 0 0 0 0 0 0 0 0 0 0 0 0 Tel: ++49-9132-744-200 */
/* 0 0 0 000 0 0 000 0 0 0 0 GmbH Fax: ++49-9132-744-204 */
/* */
/* ========================================================================= */
/* */
/* Description: Print routines for serio.c. */
/* */
/* ------------------------------------------------------------------------- */
/* */
/* Technical support: P. Fredehorst */
/* Tel. : ++49-9132/744-214 */
/* Fax. : -204 */
/* eMail: pfredehorst@profichip.com */
/* */
/*****************************************************************************/
/*****************************************************************************/
/* contents:
- function prototypes
- data structures
- internal functions
*/
/*****************************************************************************/
/* include hierarchy */
#include "..\..\dp_inc\platform.h"
#include "..\..\dp_inc\dp_inc.h"
#ifdef RS232_SERIO
/*---------------------------------------------------------------------------*/
/* function prototypes */
/*---------------------------------------------------------------------------*/
extern UBYTE user_demo_diagnostic( UBYTE diag_nr, UBYTE module_nr );
/*---------------------------------------------------------------------------*/
/* function: wait */
/*---------------------------------------------------------------------------*/
void wait( void )
{
do
{
// wait!
VPC3_RESET_USER_WD(); // toggle user watchdog
}
while( snd_counter > 50);
}
/*---------------------------------------------------------------------------*/
/* function: write_debug_buffer */
/*---------------------------------------------------------------------------*/
#ifdef DP_DEBUG_ENABLE
void PrintDebugBuffer( void )
{
UWORD wIndex;
UWORD i;
print_string("\r\nDebug_Buffer: ");
print_hexbyte( bDebugBufferIndex );
print_hexbyte( bDebugBufferOverlapped );
wait();
wIndex = 0;
if( bDebugBufferOverlapped == TRUE )
{
for( i = bDebugBufferIndex; i < (MAX_NR_OF_DEBUG-1); i++ )
{
if( (wIndex%4) == 0 )
{
wait();
print_string("\r\n");
print_hexbyte(wIndex);
print_string(" ");
}//if( (wIndex%4) == 0 )
print_hexbyte( asDebugBuffer[i].bDebugCode );
print_hexbyte( asDebugBuffer[i].bDetail1 );
print_hexbyte( asDebugBuffer[i].bDetail2 );
print_string(" - ");
wIndex++;
}//for( i = 0; i < bDebugBufferIndex; i++ )
}//if( bDebugBufferOverlapped == TRUE )
for( i = 0; i < bDebugBufferIndex; i++ )
{
if( (wIndex%4) == 0 )
{
wait();
print_string("\r\n");
print_hexbyte(wIndex);
print_string(" ");
}//if( (wIndex%4) == 0 )
print_hexbyte( asDebugBuffer[i].bDebugCode );
print_hexbyte( asDebugBuffer[i].bDetail1 );
print_hexbyte( asDebugBuffer[i].bDetail2 );
print_string(" - ");
wIndex++;
}//for( i = 0; i < bDebugBufferIndex; i++ )
}//void print_debug_buffer( void )
#endif//#ifdef DP_DEBUG_ENABLE
/*---------------------------------------------------------------------------*/
/* function: print_help */
/*---------------------------------------------------------------------------*/
void print_help( void )
{
print_string("\r\nHelp: ");
print_string("\r\na,A : Statusregister");
print_string("\r\nb,B : Moderegister");
print_string("\r\nc,C : Organizational Parameter");
wait();
print_string("\r\ne,E : Diagnostic Data");
print_string("\r\nf,F : Parameter Data");
print_string("\r\ng,G : Check Config Data");
print_string("\r\nj,J : VPC3 Free Memory");
print_string("\r\n");
}//void print_help( void )
/*---------------------------------------------------------------------------*/
/* function: show_buffer */
/*---------------------------------------------------------------------------*/
void show_buffer(char * msg_ptr, UBYTE * ptr, UWORD length)
{
UWORD i;
print_string("\r\n");
print_string( msg_ptr );
print_string("\r\nAdr: ");
print_hexword(ptr);
print_string(" length: ");
print_hexword(length);
print_string("\r\nAdr: 00-01-02-03-04-05-06-07-08-09-0A-0B-0C-0D-0E-0F");
for( i = 0; i < length; i++ )
{
if( i%16 == 0 )
{
wait();
print_string("\r\n");
print_hexword(i);
print_string(" ");
}//if( i%16 == 0 )
print_string(" ");
print_hexbyte(*(ptr+i));
}//for( i = 0; i < length; i++ )
print_string("\r\n");
}//void show_buffer(char * msg_ptr, UBYTE * ptr, UWORD length)
/*---------------------------------------------------------------------------*/
/* function: print organizational parameters */
/*---------------------------------------------------------------------------*/
void print_org_para( void )
{
show_buffer("Organizational Parameters:", &p_Vpc3->slave_addr, 42 );
}//void print_org_para( void )
/*---------------------------------------------------------------------------*/
/* function: print sap list */
/*---------------------------------------------------------------------------*/
void print_sap_list( void )
{
#ifdef DP_FDL
UBYTE i;
for( i = 0; i < SAP_LENGTH/7; i++ )
{
show_buffer("SAP-List:", &p_Vpc3->sap_ctrl_list[i*7], 7 );
show_buffer("Buffer:", (UBYTE *)((VPC3_ADR)(p_Vpc3->sap_ctrl_list[(i*7)+4] << SEG_MULDIV)+(VPC3_ADR)VPC3_ASIC_ADDRESS), 16 );
}//for( i = 0; i < SAP_LENGTH/7; i++ )
#endif//#ifdef DP_FDL
return;
}//void print_sap_list( void )
/*---------------------------------------------------------------------------*/
/* function: print_diag_buffer */
/*---------------------------------------------------------------------------*/
void print_diag_buffer( void )
{
print_string("\r\nDiag_SM:");
print_hexbyte(p_Vpc3->ctrl_reg.rd.diag_buffer_sm);
show_buffer("Diag Buffer1:", VPC3_GET_DIAG1_PTR(), p_Vpc3->len_diag_buf[0] );
show_buffer("Diag Buffer2:", VPC3_GET_DIAG2_PTR(), p_Vpc3->len_diag_buf[1] );
}//void print_diag_buffer( void )
/*---------------------------------------------------------------------------*/
/* function: print_prm_data */
/*---------------------------------------------------------------------------*/
void print_prm_data( void )
{
show_buffer("NEW_PRM_DATA:", VPC3_GET_PRM_BUF_PTR(), VPC3_GET_PRM_LEN() );
}//void print_prm_data( void )
/*---------------------------------------------------------------------------*/
/* function: print cfg_data */
/*---------------------------------------------------------------------------*/
void print_cfg_data( void )
{
show_buffer("Read CFG Buffer:", VPC3_GET_READ_CFG_BUF_PTR(), VPC3_GET_READ_CFG_LEN() );
show_buffer("Check CFG Buffer:", VPC3_GET_CFG_BUF_PTR(), VPC3_GET_CFG_LEN() );
}//void print_cfg_data( void )
#ifdef DP_SUBSCRIBER
/*---------------------------------------------------------------------------*/
/* function: print_dxb_link_table */
/*---------------------------------------------------------------------------*/
void print_dxb_link_table(void)
{
VPC3_DXB_LINK_TABLE_PTR dxb_ptr;
UBYTE i;
print_string("\r\nDXB Link-Table: \r\n");
wait();
dxb_ptr = (VPC3_DXB_LINK_TABLE_PTR)VPC3_GET_DXB_LINK_TABLE_BUF_PTR();
for( i = 0; i < (VPC3_GET_DXB_LINK_TABLE_LEN()/4); i++)
{
print_hexbyte(dxb_ptr->link_table_entry[i].publisher_addr);
print_hexbyte(dxb_ptr->link_table_entry[i].publisher_length);
print_hexbyte(dxb_ptr->link_table_entry[i].sample_offset);
print_hexbyte(dxb_ptr->link_table_entry[i].sample_length);
print_string(" - ");
}
}
/*---------------------------------------------------------------------------*/
/* function: print_dxb_link_status */
/*---------------------------------------------------------------------------*/
void print_dxb_link_status( void )
{
VPC3_DXB_LINK_STATUS_PTR dxb_ptr;
UBYTE i;
print_string("\r\nDXB Link-Status: \r\n");
wait();
dxb_ptr = (VPC3_DXB_LINK_STATUS_PTR)VPC3_GET_DXB_LINK_STATUS_BUF_PTR();
print_hexbyte(dxb_ptr->header);
print_hexbyte(dxb_ptr->status_type);
print_hexbyte(dxb_ptr->slot_number);
print_hexbyte(dxb_ptr->status_specifier);
print_string(" - ");
for(i = 0; i < ((dxb_ptr->header-4) / 2); i++)
{
print_hexbyte(dxb_ptr->link_status[i].publisher_addr);
print_hexbyte(dxb_ptr->link_status[i].link_status);
}
}
#endif//#ifdef DP_SUBSCRIBER
/*---------------------------------------------------------------------------*/
/* */
/* function: reaction of serial inputs */
/* */
/*---------------------------------------------------------------------------*/
void print_serial_inputs(void)
{
if(rec_counter > 0)
{
switch (rec_buff[read_rec_ptr])
{
case 0x3F: // Key '?':
{
print_help();
rec_counter--;
break;
}
case 0x61: // Key 'a'
case 0x41: // Key 'A'
{
print_string("\r\nStatusreg: ");
print_hexbyte(p_Vpc3->isreg.rd.status_H);
print_string(" ");
print_hexbyte(p_Vpc3->isreg.rd.status_L);
rec_counter--;
break;
}
// SPC3: mode register only writable
case 0x62: // Key 'b'
case 0x42: // Key 'B'
{
print_string("\r\nModereg1: ");
print_hexbyte(p_Vpc3->ctrl_reg.rd.mode_reg1);
rec_counter--;
break;
}
case 0x63: // Key 'c'
case 0x43: // Key 'C'
{
print_org_para();
rec_counter--;
break;
}
case 0x64: // Key 'd'
case 0x44: // Key 'D'
{
print_sap_list();
rec_counter--;
break;
}
case 0x65: // Key 'e'
case 0x45: // Key 'E'
{
print_diag_buffer();
rec_counter--;
break;
}
case 0x66: // Key 'f'
case 0x46: // Key 'F'
{
print_prm_data();
rec_counter--;
break;
}
case 0x67: // Key 'g'
case 0x47: // Key 'G'
{
print_cfg_data();
rec_counter--;
break;
}
#ifdef DP_SUBSCRIBER
case 0x68: // Key 'h'
case 0x48: // Key 'H'
{
print_dxb_link_table();
rec_counter--;
break;
}
case 0x69: // Key 'i'
case 0x49: // Key 'I'
{
print_dxb_link_status();
rec_counter--;
break;
}
#endif//#ifdef DP_SUBSCRIBER
case 0x6A: // Key 'j'
case 0x4A: // Key 'J'
{
UWORD length;
print_string("\r\nAddress of VPC3+ free memory: ");
print_hexword( vpc3_get_free_memory( &length ) );
print_string(" length: ");
print_hexword( length );
rec_counter--;
break;
}
#ifdef DP_DEBUG_ENABLE
case 0x79: // Taste 'y'
case 0x59: // Taste 'Y'
{
DP_ClearDebugBuffer();
rec_counter--;
break;
}
case 0x7A: // Taste 'z'
case 0x5A: // Taste 'Z'
{
PrintDebugBuffer();
rec_counter--;
break;
}
#endif//#ifdef DP_DEBUG_ENABLE
default:
{
rec_counter--;
break;
}
}//switch (rec_buff[read_rec_ptr])
read_rec_ptr++;
}// if(get_received_data_count())
}
#endif//#ifdef RS232_SERIO
/*****************************************************************************/
/* Copyright (C) profichip GmbH 2004. Confidential. */
/*****************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -