📄 dp_user.c
字号:
{
//length error
ret_value = DP_PRM_LEN_ERROR;
}
}//if( ret_value == DP_OK )
}//if( len == 0x13 )
else
{
ret_value = DP_PRM_LEN_ERROR;
}//else of if( len == 0x13 )
if( ( VPC3_GET_DP_STATE() == DATA_EX ) && ( ret_value == DP_OK ) )
{
//don't send diagnostic here
}//if( ( VPC3_GET_DP_STATE() == DATA_EX ) && ( ret_value == DP_OK ) )
else
{
user_alarm( USER_TYPE_PRM_OK, 0, (ALARM_STATUS_PDU_PTR) NULL_PTR, FALSE );
}//else of if( ( VPC3_GET_DP_STATE() == DATA_EX ) && ( ret_value == DP_OK ) )
return ret_value;
}//UBYTE user_chk_new_prm_data(VPC3_UNSIGNED8_PTR prm_ptr, UBYTE len)
#endif//#if( ISR_ENABLE_VPC3_INT_NEW_PRM_DATA == 1 )
/*---------------------------------------------------------------------------*/
/* function: user_isr_new_ext_prm_data */
/* */
/* todo : check the prm-data */
/* return: DP_OK - prm-data OK */
/* DP_NOK - prm-data not OK */
/*---------------------------------------------------------------------------*/
#if( ISR_ENABLE_VPC3_INT_NEW_EXT_PRM_DATA == 1 )
UBYTE user_chk_new_ext_prm_data( VPC3_STRUC_PRM_BLOCK_PTR prmblock_ptr, UBYTE len )
{
UBYTE ret_value;
ret_value = DP_OK;
len = len;
if( ( prmblock_ptr->command == PBC_USER_PRM_DATA )
&& ( prmblock_ptr->len == 0x0C )
&& ( prmblock_ptr->slot_nr == 0x00 )
&& ( prmblock_ptr->index == 0x00 )
)
{
//copy counter parameter data
memcpy( &sSystem.prm, &prmblock_ptr->user_data+1, 7 );
//check parameter of counter module
if( ( sSystem.prm.alarm & 0xFC ) //check alarm
|| ( sSystem.prm.mode > 0x01 ) //check counter mode
|| ( sSystem.prm.time_base > 0x05 ) //check counter timebase
)
{
//error
ret_value = DP_PRM_ENTRY_ERROR;
}//if( ( counter.prm.len != 9 ) ...
}
else
{
ret_value = DP_PRM_BLOCK_ERROR;
}
return ret_value;
}//UBYTE user_chk_new_ext_prm_data( VPC3_STRUC_PRM_BLOCK_PTR prmblock_ptr, UBYTE len )
#endif//#if( ISR_ENABLE_VPC3_INT_NEW_EXT_PRM_DATA == 1 )
/*---------------------------------------------------------------------------*/
/* function: user_isr_new_cfg_data */
/* */
/* todo : check cfg data */
/* */
/* return: VPC3_CFG_OK 0 */
/* VPC3_CFG_FAULT 1 */
/* VPC3_CFG_UPDATE 2 */
/*---------------------------------------------------------------------------*/
#if( ISR_ENABLE_VPC3_INT_NEW_CFG_DATA == 1 )
UBYTE user_chk_new_cfg_data( void )
{
VPC3_UNSIGNED8_PTR cfg_ptr; // pointer check config buffer
UBYTE nr_of_check_modules;
UBYTE nr_of_modules;
UBYTE real_cfg_len;
UBYTE ret_value;
UBYTE cfg_len;
UBYTE i;
cfg_ptr = VPC3_GET_CFG_BUF_PTR();
real_cfg_len = sSystem.NrOfModules * 4; //4 cfg-byte per module
cfg_len = VPC3_GET_CFG_LEN();
//build modulstatus diagnose
memcpy( &status_diag.sign_len, &DefStatusDiag[0], sizeof_StatusDiag );
nr_of_check_modules = sSystem.NrOfModules;
if( cfg_len != real_cfg_len )
{
if( cfg_len < real_cfg_len )
{
nr_of_check_modules = ( cfg_len / 4 );
}//if( cfg_len < etm_cfg_len )
else
{
nr_of_modules = cfg_len / 5;
nr_of_modules += ( cfg_len % 5 ) ? 1 : 0 ;
for( i = nr_of_check_modules; i < nr_of_modules; i++)
{
status_diag.user_data[ i/4 ] |= (0x03 << ((i%4)*2));
}//for( i = 0; i < nr_of_modules; i++)
}//if( cfg_len > real_cfg_len )
ret_value = VPC3_CFG_FAULT;
}//if( cfg_len != real_cfg_len )
else
{
ret_value = VPC3_CFG_OK;
}//if( cfg_len != real_cfg_len )
for( i = 0; i < nr_of_check_modules; i++)
{
if( memcmp( &user.real_cfg.cfg_data[i*4], cfg_ptr, 0x04 ) == 0 )
{
status_diag.user_data[ i/4 ] &= ~(0x02 << ((i%4)*2));
}
else
{
ret_value = VPC3_CFG_FAULT;
}
cfg_ptr += 4;
}//for( i = 0; i < nr_of_check_modules; i++)
if( ret_value == VPC3_CFG_OK )
{
user_alarm( USER_TYPE_CFG_OK, 0, (ALARM_STATUS_PDU_PTR) NULL_PTR, FALSE );
user.event |= VPC3_EV_NEW_CFG_DATA;
}//if( ret_value == VPC3_CFG_UPDATE )
else
{
user_alarm( USER_TYPE_CFG_NOK, status_diag.user_data[ 0 ], (ALARM_STATUS_PDU_PTR) NULL_PTR, FALSE );
}//else of if( ret_value == VPC3_CFG_UPDATE )
user_alarm_init();
return ret_value;
}//UBYTE user_chk_new_cfg_data( void )
#endif//#if( ISR_ENABLE_VPC3_INT_NEW_CFG_DATA == 1 )
/*---------------------------------------------------------------------------*/
/* function: user_isr_go_leave_data_ex */
/*---------------------------------------------------------------------------*/
#if( ISR_ENABLE_VPC3_INT_GO_LEAVE_DATA_EX == 1 )
void user_isr_go_leave_data_ex( void )
{
if( VPC3_GET_DP_STATE() != DATA_EX )
{
user.state = USER_STATE_CLEAR;
user.application_ready = FALSE;
}//if( VPC3_GET_DP_STATE() != DATA_EX )
}//void user_isr_go_leave_data_ex( void )
#endif//#if( ISR_ENABLE_VPC3_INT_GO_LEAVE_DATA_EX == 1 )
/*---------------------------------------------------------------------------*/
/* function: user_isr_dx_out */
/*---------------------------------------------------------------------------*/
#if( ISR_ENABLE_VPC3_INT_DX_OUT == 1 )
void user_isr_dx_out( void )
{
user.event |= VPC3_EV_DX_OUT;
}//void user_isr_dx_out( void )
#endif//#if( ISR_ENABLE_VPC3_INT_DX_OUT == 1 )
/*---------------------------------------------------------------------------*/
/* function: user_isr_diag_buf_changed */
/*---------------------------------------------------------------------------*/
#if( ISR_ENABLE_VPC3_INT_DIAG_BUF_CHANGED == 1 )
void user_isr_diag_buf_changed( void )
{
// diagnosis buffer has been changed
user.user_diag_active = FALSE;
// Fetch new diagnosis buffer
dp_sys.diag_buf_ptr.byte_ptr = vpc3_get_diagbufptr();
}//void user_isr_diag_buf_changed( void )
#endif//#if( ISR_ENABLE_VPC3_INT_DIAG_BUF_CHANGED == 1 )
/*---------------------------------------------------------------------------*/
/* function: user_isr_new_wd_timeout */
/*---------------------------------------------------------------------------*/
#if( ISR_ENABLE_VPC3_INT_WD_DP_TIMEOUT == 1 )
void user_isr_new_wd_dp_timeout( void )
{
reset_diagnostic_buffer();
}//void user_isr_new_wd_dp_timeout( void )
#endif//#if( ISR_ENABLE_VPC3_INT_WD_DP_TIMEOUT == 1 )
/*---------------------------------------------------------------------------*/
/* function: user_isr_mac_reset */
/*---------------------------------------------------------------------------*/
#if( ISR_ENABLE_VPC3_INT_MAC_RESET == 1 )
void user_isr_mac_reset( void )
{
//not used in our application
}//void user_isr_mac_reset( void )
#endif//#if( ISR_ENABLE_VPC3_INT_MAC_RESET == 1 )
/*---------------------------------------------------------------------------*/
/* function: user_isr_baudrate_detect */
/*---------------------------------------------------------------------------*/
#if( ISR_ENABLE_VPC3_INT_BAUDRATE_DETECT == 1 )
void user_isr_baudrate_detect( void )
{
//not used in our application
}//void user_isr_baudrate_detect( void )
#endif//#if( ISR_ENABLE_VPC3_INT_BAUDRATE_DETECT == 1 )
/*---------------------------------------------------------------------------*/
/* function: user_isr_new_gc_command */
/*---------------------------------------------------------------------------*/
#if( ISR_ENABLE_VPC3_INT_NEW_GC_COMMAND == 1 )
void user_isr_new_gc_command( void )
{
//not used in our application
}//void user_isr_new_gc_command( void )
#endif//#if( ISR_ENABLE_VPC3_INT_NEW_GC_COMMAND == 1 )
/*---------------------------------------------------------------------------*/
/* function: user_isr_new_ssa_data */
/*---------------------------------------------------------------------------*/
#if( ISR_ENABLE_VPC3_INT_NEW_SSA_DATA == 1 )
void user_isr_new_ssa_data( void )
{
//not used in our application
VPC3_STRUC_SSA_BLOCK_PTR ssa_ptr;
ssa_ptr = (VPC3_STRUC_SSA_BLOCK_PTR) VPC3_GET_SSA_BUF_PTR();
//store the new address and the bit real_no_add_chg for the next startup
/*
print_string("\r\nNewAddr: ");
print_hexbyte(ssa_ptr->address);
print_hexbyte(ssa_ptr->no_add_chg);
*/
}void user_isr_new_ssa_data( void )
#endif//#if( ISR_ENABLE_VPC3_INT_NEW_SSA_DATA == 1 )
/*---------------------------------------------------------------------------*/
/* function: user_isr_user_timer_clock (10ms) */
/*---------------------------------------------------------------------------*/
#if( ISR_ENABLE_VPC3_INT_USER_TIMER_CLOCK == 1 )
void user_isr_user_timer_clock( void )
{
//simulation for counter module
if( sSystem.output.counter[0] & 0x01 )
{
if( ++counter_timebase == sSystem.prm.time_base )
{
counter_timebase = 0x00;
counter_value = (sSystem.prm.mode == 0) ? counter_value+1 : counter_value-1;
sSystem.input.counter[0] = (UBYTE)(counter_value >> 8);
sSystem.input.counter[1] = (UBYTE)(counter_value & 0x00FF);
user.event |= VPC3_EV_NEW_INPUT_DATA;
}//if( ++counter_timebase == sSystem.prm.time_base )
}//if( sSystem.output.counter[0] & 0x01 )
}//void user_isr_user_timer_clock( void )
#endif//#if( ISR_ENABLE_VPC3_INT_USER_TIMER_CLOCK == 1 )
#ifdef DP_SUBSCRIBER
/*---------------------------------------------------------------------------*/
/* function: user_isr_dxb_out */
/*---------------------------------------------------------------------------*/
#if( ISR_ENABLE_VPC3_INT_DXB_OUT == 1 )
void user_isr_dxb_out( void )
{
user.event |= VPC3_EV_DXB_OUT;
}//void user_isr_dxb_out( void )
#endif//#if( ISR_ENABLE_VPC3_INT_DXB_OUT == 1 )
/*---------------------------------------------------------------------------*/
/* function: user_isr_dxb_link_error */
/*---------------------------------------------------------------------------*/
#if( ISR_ENABLE_VPC3_INT_DXB_LINK_ERROR == 1 )
void user_isr_dxb_link_error( void )
{
user.event |= VPC3_EV_DXB_LINK_ERROR;
}//void user_isr_dxb_link_error( void )
#endif//#if( ISR_ENABLE_VPC3_INT_DXB_LINK_ERROR == 1 )
#endif//#ifdef DP_SUBSCRIBER
/*****************************************************************************/
/* Copyright (C) profichip GmbH 2004. Confidential. */
/*****************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -