dp_if.c
资源名称:Profibus.rar [点击查看]
上传用户:hualang
上传日期:2022-04-11
资源大小:104k
文件大小:73k
源码类别:
能源行业(电力石油煤炭)
开发平台:
C/C++
- /*********************** Filename: dp_if.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 */
- /* */
- /* ========================================================================= */
- /* */
- /* Function: interface service routines for VPC3+ (dp-protocol) */
- /* */
- /* ------------------------------------------------------------------------- */
- /* history */
- /* ========================================================================= */
- /* 08.09.2005 [V5.00] Urversion */
- /* 22.10.2005 [V5.01] BugFix: */
- /* Dp_cfg.h: */
- /* Missing bracket: */
- /* #define ASIC_USER_RAM (ASIC_RAM_LENGTH - */
- /* DP_ORG_LENGTH - SAP_LENGTH) */
- /* */
- /* ------------------------------------------------------------------------- */
- /* */
- /* */
- /* 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_incplatform.h"
- #include "..dp_incdp_inc.h"
- //#include "E5_Inc.h"
- //#include <cdefBF536.h>
- /*---------------------------------------------------------------------------*/
- /* version */
- /*---------------------------------------------------------------------------*/
- #define DP_VERSION_MAIN_INTERFACE ((UBYTE)0x05)
- #define DP_VERSION_FUNCTION ((UBYTE)0x00)
- #define DP_VERSION_BUGFIX ((UBYTE)0x01)
- /*---------------------------------------------------------------------------*/
- /* function prototypes */
- /*---------------------------------------------------------------------------*/
- DP_ERROR_CODE vpc3_set_constants (UBYTE dev_num, UBYTE slave_address );
- DP_ERROR_CODE ssc_init (UBYTE dev_num);
- DP_ERROR_CODE vpc3_buf_init (UBYTE dev_num);
- UWORD assign_aux_buf (UBYTE dev_num, UWORD PTR_ATTR *lens, UBYTE count, UBYTE PTR_ATTR *assign, UWORD PTR_ATTR *aux_len );
- /*---------------------------------------------------------------------------*/
- /* global user data definitions */
- /*---------------------------------------------------------------------------*/
- SECTION_DEF_CommuData VPC3_STRUC VPC3_PTR p_Vpc3[MAX_DEV_NUM]; // pointer to Vpc3 structure
- SECTION_DEF_CommuData VPC3_SYSTEM_STRUC dp_sys[MAX_DEV_NUM]; // global system structure
- #ifdef DP_DEBUG_ENABLE
- SECTION_DEF_CommuData sDP_DEBUG_BUFFER_ITEM asDebugBuffer[MAX_DEV_NUM][ MAX_NR_OF_DEBUG ];
- SECTION_DEF_CommuData UBYTE bDebugBufferIndex[MAX_DEV_NUM];
- SECTION_DEF_CommuData UBYTE bDebugBufferOverlapped[MAX_DEV_NUM];
- #endif//#ifdef DP_DEBUG_ENABLE
- /*---------------------------------------------------------------------------*/
- /* defines */
- /*---------------------------------------------------------------------------*/
- /* Literals */
- /* Lage der Bits der AUX-Puffer-Zuordnung */
- #define RBL_PRM 0
- #define RBL_CFG 1
- #define RBL_SSA 2
- /*---------------------------------------------------------------------------*/
- /* function: DP_GetVersion */
- /*---------------------------------------------------------------------------*/
- SECTION_DEF_CommuCode void DP_GetVersion(UBYTE dev_num, psDP_VERSION pVersion )
- {
- pVersion->wComponentsInstalled = 0x0000
- #ifdef DP_MSAC_C1
- | DP_COMP_INSTALLED_MSAC1_IFA
- #ifdef DP_ALARM
- | DP_COMP_INSTALLED_SUB_AL
- #ifdef DP_ALARM_OVER_SAP50
- | DP_COMP_INSTALLED_SUB_AL_50
- #endif//DP_ALARM_OVER_SAP50
- #endif//#ifdef DP_ALARM
- #ifdef DPV1_IM_SUPP
- | DP_COMP_INSTALLED_IM
- #endif//#ifdef DPV1_IM_SUPP
- #endif//#ifdef DP_MSAC_C1
- #ifdef DP_MSAC_C2
- | DP_COMP_INSTALLED_MSAC2_IFA
- #ifdef DPV1_IM_SUPP
- | DP_COMP_INSTALLED_IM
- #endif//#ifdef DPV1_IM_SUPP
- #endif//#ifdef DP_MSAC_C2
- ;
- switch(VPC3_GET_ASIC_TYPE(dev_num) )
- {
- case AT_VPC3B:
- {
- pVersion->wComponentsInstalled |= DP_COMP_INSTALLED_VPC3_B ;
- break;
- }
- case AT_VPC3C:
- {
- pVersion->wComponentsInstalled |= DP_COMP_INSTALLED_VPC3_C ;
- break;
- }
- case AT_MPI12X:
- {
- pVersion->wComponentsInstalled |= DP_COMP_INSTALLED_VPC3_D ;
- break;
- }
- default:
- {
- //do nothing
- }
- }//switch(VPC3_GET_ASIC_TYPE(dev_num)
- pVersion->bMainInterface = DP_VERSION_MAIN_INTERFACE;
- pVersion->bFunction = DP_VERSION_FUNCTION;
- pVersion->bBugfix = DP_VERSION_BUGFIX;
- }//void DP_GetVersion(UBYTE dev_num, psDP_VERSION pVersion )
- /*---------------------------------------------------------------------------*/
- /* function: DP_WriteDebugBuffer */
- /*---------------------------------------------------------------------------*/
- #ifdef DP_DEBUG_ENABLE
- SECTION_DEF_CommuCode void DP_WriteDebugBuffer(UBYTE dev_num, DEBUG_CODE bDebugCode, UBYTE bDetail1, UBYTE bDetail2 )
- {
- asDebugBuffer[dev_num][ bDebugBufferIndex[dev_num] ].bDebugCode = bDebugCode;
- asDebugBuffer[dev_num][ bDebugBufferIndex[dev_num] ].bDetail1 = bDetail1;
- asDebugBuffer[dev_num][ bDebugBufferIndex[dev_num] ].bDetail2 = bDetail2;
- if( bDebugBufferIndex[dev_num] == (MAX_NR_OF_DEBUG-1) )
- {
- bDebugBufferOverlapped[dev_num] = TRUE;
- bDebugBufferIndex[dev_num] = 0;
- }
- else
- {
- bDebugBufferIndex[dev_num]++;
- }
- }//void DP_WriteDebugBuffer(UBYTE dev_num, DEBUG_CODE debug_code, UBYTE detail_1, UBYTE detail_2 )
- #endif//#ifdef DP_DEBUG_ENABLE
- /*---------------------------------------------------------------------------*/
- /* function: DP_ClearDebugBuffer */
- /*---------------------------------------------------------------------------*/
- #ifdef DP_DEBUG_ENABLE
- SECTION_DEF_CommuCode void DP_ClearDebugBuffer(dev_num)
- {
- UWORD i;
- bDebugBufferOverlapped[dev_num] = FALSE;
- bDebugBufferIndex[dev_num] = 0x00;
- for(i = 0; i < MAX_NR_OF_DEBUG; i++ )
- {
- asDebugBuffer[dev_num][i].bDebugCode = 0x00;
- asDebugBuffer[dev_num][i].bDetail1 = 0x00;
- asDebugBuffer[dev_num][i].bDetail2 = 0x00;
- }//for( i = 0; i < MAX_NR_OF_DEBUG; i++ )
- }//void DP_ClearDebugBuffer(dev_num)
- #endif//#ifdef DP_DEBUG_ENABLE
- /*--------------------------------------------------------------------------*/
- /*vpc3 reset function -*/
- /*--------------------------------------------------------------------------*/
- extern void ResetVPC3_0(void);
- SECTION_DEF_CommuCode void ResetVPC3(UBYTE dev_num)
- {
- if(dev_num == NET_A)
- {
- ResetVPC3_0();
- }
- else if(dev_num == NET_B)
- {
- }
- }
- /*---------------------------------------------------------------------------*/
- /* */
- /* UBYTE vpc3_initialization () */
- /* */
- /* function: initializing the vpc3+ controller */
- /* */
- /* parameter: VPC3_INIT, VPC3_DP_INIT */
- /* return value: errorcode (0 = no error) */
- /* */
- /*---------------------------------------------------------------------------*/
- SECTION_DEF_CommuCode DP_ERROR_CODE vpc3_initialization(UBYTE dev_num, UBYTE slave_address, CFG_STRUCT cfg )
- {
- DP_ERROR_CODE error;
- BLACKFIN_WORDPTR vpc3_ptr; // pointer to vpc3 memory area
- unsigned char j;
- UWORD i;
- int nBlackfinLoop;
- BLACKFINDATATYPE* pBlackfinAddr;
- /*-----------------------------------------------------------------------*/
- /* initialize global system structure */
- /*-----------------------------------------------------------------------*/
- memset(&dp_sys[dev_num], 0, sizeof(dp_sys[dev_num]));
- #ifdef DP_DEBUG_ENABLE
- DP_ClearDebugBuffer(dev_num);
- #endif//#ifdef DP_DEBUG_ENABLE
- /*-----------------------------------------------------------------------*/
- /* init vpc3 data */
- /*-----------------------------------------------------------------------*/
- p_Vpc3[dev_num] = (VPC3_STRUC VPC3_PTR)VPC3_ASIC_ADDRESS(dev_num);//设置vpc的基本地址
- //VPC3_CLEAR_RESET__;
- //NOP__();
- #ifdef MPI12x
- p_Vpc3[dev_num]->int_req1 = 0x03;
- NOP__();
- NOP__();
- NOP__();
- NOP__();
- #endif//#ifdef MPI12x
- //neccessary, if 4Kbyte mode enabled
- p_Vpc3[dev_num]->ctrl_reg.wr.mode_reg2 = INIT_VPC3_MODE_REG_2;
- // DELAY_TICK(1);
- /*-----------------------------------------------------------------------*/
- /* test and clear vpc3 ram */
- /*-----------------------------------------------------------------------*/
- error = DP_OK;
- j = 0;
- vpc3_ptr = &p_Vpc3[dev_num]->slave_addr;
- for(i = 0x16; i < ASIC_RAM_LENGTH;)
- {
- *((BLACKFINDATATYPE*)vpc3_ptr)=j;
- i++;
- j++;
- vpc3_ptr+=1;
- }
- j = 0;
- vpc3_ptr = &p_Vpc3[dev_num]->slave_addr;
- for(i = 0x16; i < ASIC_RAM_LENGTH;)
- {
- if( (*((BLACKFINDATATYPE*)vpc3_ptr)&0xFF) != (j&0xFF) )
- {
- error = DP_VPC3_ERROR; // ERROR
- break;
- }
- i++;
- j++;
- vpc3_ptr+=1;
- }
- if(DP_OK == error)
- {
- //clear VPC3
- memset(&p_Vpc3[dev_num]->slave_addr, 0, (ASIC_RAM_LENGTH-0x16)*BLACKFIN_MULTIPLER );
- /*-------------------------------------------------------------------*/
- /* check VPC3 is in OFFLINE */
- /*-------------------------------------------------------------------*/
- if( !VPC3_GET_OFF_PASS(dev_num) )
- {
- /*---------------------------------------------------------------*/
- /* set constant values */
- /*---------------------------------------------------------------*/
- error = vpc3_set_constants(dev_num, slave_address );
- if(DP_OK == error)
- {
- /*-----------------------------------------------------------*/
- /* calculate length of input and output data using cfg-data */
- /*-----------------------------------------------------------*/
- error = vpc3_calculate_inp_outp_len (dev_num, &cfg.cfg_data[0], cfg.length);
- if( DP_OK == error )
- {
- /*-------------------------------------------------------*/
- /* initialize buffer structure */
- /*-------------------------------------------------------*/
- error = vpc3_buf_init(dev_num);
- if (DP_OK == error)
- {
- /*---------------------------------------------------*/
- /* set real configuration data */
- /*---------------------------------------------------*/
- VPC3_SET_READ_CFG_LEN(dev_num,cfg.length); // set configuration length
- //memcpy(VPC3_GET_READ_CFG_BUF_PTR(dev_num), &cfg.cfg_data[0], cfg.length );
- pBlackfinAddr = (BLACKFINDATATYPE*)VPC3_GET_READ_CFG_BUF_PTR(dev_num);
- for (nBlackfinLoop=0; nBlackfinLoop<cfg.length; nBlackfinLoop++)
- {
- pBlackfinAddr[nBlackfinLoop] = cfg.cfg_data[nBlackfinLoop];
- }
- // set I/O length
- vpc3_set_io_data_len(dev_num);
- /*---------------------------------------------------*/
- /* initialize subscriber */
- /*---------------------------------------------------*/
- #ifdef DP_SUBSCRIBER
- error = ssc_init(dev_num);
- #endif//#ifdef DP_SUBSCRIBER
- /*---------------------------------------------------*/
- /* initialize fdl_interface */
- /*---------------------------------------------------*/
- #ifdef DP_FDL
- if(DP_OK == error)
- {
- error = fdl_init(dev_num);
- if(DP_OK == error)
- {
- /*-----------------------------------------------*/
- /* initialize MSAC_C1 */
- /*-----------------------------------------------*/
- #ifdef DP_MSAC_C1
- error = msac_c1_init(dev_num);
- #endif//#ifdef DP_MSAC_C1
- #ifdef DP_MSAC_C2
- if(DP_OK == error)
- {
- /*-------------------------------------------*/
- /* initialize MSAC_C2 */
- /*-------------------------------------------*/
- error = msac_c2_init(dev_num);
- }
- #endif//#ifdef DP_MSAC_C2
- }
- }
- #endif //#ifdef DP_FDL
- }//if(DP_OK == error)
- }//if(DP_OK == error)
- }//if(DP_OK == error)
- }//if( !VPC3_GET_OFF_PASS(dev_num) )
- else
- {
- error = DP_NOT_OFFLINE_ERROR;
- }
- }//if(DP_OK == error)
- return error;
- }
- /*---------------------------------------------------------------------------*/
- /* function: START_VPC3 */
- /*---------------------------------------------------------------------------*/
- SECTION_DEF_CommuCode void START_VPC3(UBYTE dev_num)
- {
- /*-----------------------------------------------------------------------*/
- /* start vpc3 */
- /*-----------------------------------------------------------------------*/
- START_VPC3__(dev_num);
- #ifdef DP_MSAC_C2
- msac_c2_open_channel(dev_num);
- #endif /* DP_MSAC_C2 */
- // Fetch the first diagnosis buffer
- dp_sys[dev_num].diag_buf_ptr.byte_ptr = vpc3_get_diagbufptr(dev_num);
- }//void START_VPC3(UBYTE dev_num)
- /*---------------------------------------------------------------------------*/
- /* */
- /* function: initializing constant vpc3 values */
- /* */
- /*---------------------------------------------------------------------------*/
- SECTION_DEF_CommuCode DP_ERROR_CODE vpc3_set_constants(UBYTE dev_num, UBYTE slave_address )
- {
- DP_ERROR_CODE error;
- error = DP_OK;
- dp_sys[dev_num].din_bufsize = DIN_BUFSIZE;
- dp_sys[dev_num].dout_bufsize = DOUT_BUFSIZE;
- dp_sys[dev_num].prm_bufsize = PRM_BUFSIZE;
- dp_sys[dev_num].diag_bufsize = DIAG_BUFSIZE;
- dp_sys[dev_num].cfg_bufsize = CFG_BUFSIZE;
- dp_sys[dev_num].ssa_bufsize = SSA_BUFSIZE;
- #ifdef DP_FDL
- #ifdef DP_MSAC_C2
- dp_sys[dev_num].c2_num_saps = C2_NUM_SAPS;
- dp_sys[dev_num].c2_len = DP_C2_LEN;
- #endif//#ifdef DP_MSAC_C2
- #endif//#ifdef DP_FDL
- /*-----------------------------------------------------------------------*/
- /* initialize control logic */
- /*-----------------------------------------------------------------------*/
- p_Vpc3[dev_num]->int_req1 = 0x00;
- p_Vpc3[dev_num]->int_req2 = 0x00;
- p_Vpc3[dev_num]->isreg.wr.int_ack1 = 0xFF;
- p_Vpc3[dev_num]->isreg.wr.int_ack2 = 0xFF;
- p_Vpc3[dev_num]->ctrl_reg.wr.mode_reg1_r = 0xFF; // reset mode register 1
- p_Vpc3[dev_num]->ctrl_reg.wr.reserved_12 = 0; // wusenlin
- /*-----------------------------------------------------------------------*/
- /* set modes of vpc3 */
- /*-----------------------------------------------------------------------*/
- p_Vpc3[dev_num]->mode_reg0_H = INIT_VPC3_MODE_REG_H;
- p_Vpc3[dev_num]->mode_reg0_L = INIT_VPC3_MODE_REG_L;
- p_Vpc3[dev_num]->ctrl_reg.wr.mode_reg2 = INIT_VPC3_MODE_REG_2;
- /*-----------------------------------------------------------------------*/
- /* set interrupt triggers */
- /*-----------------------------------------------------------------------*/
- p_Vpc3[dev_num]->isreg.wr.int_mask_H = (UBYTE) ~(INIT_VPC3_IND_H);
- p_Vpc3[dev_num]->isreg.wr.int_mask_L = (UBYTE) ~(INIT_VPC3_IND_L);
- dp_sys[dev_num].ind_high = (UBYTE) ~(INIT_VPC3_IND_H);
- dp_sys[dev_num].ind_low = (UBYTE) ~(INIT_VPC3_IND_L);
- /*-----------------------------------------------------------------------*/
- /* set time-variables */
- /*-----------------------------------------------------------------------*/
- p_Vpc3[dev_num]->ctrl_reg.wr.wd_baud_ctrl = 0x10; // WD Timeout
- p_Vpc3[dev_num]->ctrl_reg.wr.mintsdr = 0x0B; // Min Tsdr 11 BIT (11Bit .. 255Bit)
- /*-----------------------------------------------------------------------*/
- /* set variables for synch-mode */
- /*-----------------------------------------------------------------------*/
- #ifdef ISOCHRON_MODE
- p_Vpc3[dev_num]->ctrl_reg.wr.sync_pw_reg = SYNCH_PULSEWIDTH; // sync pulse width register
- p_Vpc3[dev_num]->ctrl_reg.wr.sync_group = 0x80;
- p_Vpc3[dev_num]->ctrl_reg.wr.sync_mode = 0x00;
- #endif//#ifdef ISOCHRON_MODE
- /*-----------------------------------------------------------------------*/
- /* set user watchdog (dataexchange telegram counter) */
- /*-----------------------------------------------------------------------*/
- p_Vpc3[dev_num]->user_wd_value[1] = (UBYTE)(USER_WD >> 8);
- p_Vpc3[dev_num]->user_wd_value[0] = (UBYTE)(USER_WD);
- /*-----------------------------------------------------------------------*/
- /* set pointer to FF */
- /*-----------------------------------------------------------------------*/
- p_Vpc3[dev_num]->fdl_sap_list_ptr = VPC3_SAP_CTRL_LIST_START(dev_num);
- p_Vpc3[dev_num]->sap_ctrl_list[0] = 0xFF;
- /*-----------------------------------------------------------------------*/
- /* ssa support */
- /*-----------------------------------------------------------------------*/
- p_Vpc3[dev_num]->real_no_add_change = (dp_sys[dev_num].ssa_bufsize == 0 ) ? 0xFF : 0x00;
- /*-----------------------------------------------------------------------*/
- /* set profibus ident number */
- /*-----------------------------------------------------------------------*/
- p_Vpc3[dev_num]->ident_high = (UBYTE)(IDENT_NR >> 8);
- p_Vpc3[dev_num]->ident_low = (UBYTE)(IDENT_NR);
- /*-----------------------------------------------------------------------*/
- /* set and check slave address */
- /*-----------------------------------------------------------------------*/
- if( slave_address < 126 && slave_address != 0 )
- {
- p_Vpc3[dev_num]->slave_addr = slave_address;
- }
- else
- {
- error = DP_ADDRESS_ERROR;
- }
- return error;
- }
- /*---------------------------------------------------------------------------*/
- /* */
- /* function: initializing subscriber */
- /* */
- /*---------------------------------------------------------------------------*/
- #ifdef DP_SUBSCRIBER
- SECTION_DEF_CommuCode DP_ERROR_CODE ssc_init(UBYTE dev_num)
- {
- DP_ERROR_CODE error;
- BLACKFIN_WORDPTR vpc3_ptr; // pointer to VPC3, 礐ontroller formatted
- UBYTE vpc3_seg_adr; // segment address in VPC3-ASIC
- error = DP_OK;
- /*-----------------------------------------------------------------------*/
- /* check buffer length */
- /*-----------------------------------------------------------------------*/
- if (DP_MAX_DATA_PER_LINK > 244)
- {
- error = SSC_MAX_DATA_PER_LINK;
- }
- else
- {
- // pointer mc formatted
- vpc3_ptr = &p_Vpc3[dev_num]->dpbuffer[dp_sys[dev_num].vpc3_used_dp_buf_mem];
- // pointer vpc3 formatted
- vpc3_seg_adr = (UBYTE)(((VPC3_ADR)vpc3_ptr-(VPC3_ADR)VPC3_ASIC_ADDRESS(dev_num)) >> BLACKFIN_SEG_MULDIV );
- // length dxb_out
- p_Vpc3[dev_num]->len_dxb_out_buf = (((DP_MAX_DATA_PER_LINK+2)+SEG_OFFSET) & SEG_ADDBYTE);
- dp_sys[dev_num].vpc3_used_dp_buf_mem += (3* BFWORD2BYTE(p_Vpc3[dev_num]->len_dxb_out_buf) );
- // length link status
- p_Vpc3[dev_num]->len_dxb_link_status_buf = ((((DP_MAX_LINK_SUPPORTED*2)+4)+SEG_OFFSET) & SEG_ADDBYTE);
- dp_sys[dev_num].vpc3_used_dp_buf_mem += p_Vpc3[dev_num]->len_dxb_link_status_buf;
- // length link table
- p_Vpc3[dev_num]->len_dxb_link_table_buf = (((DP_MAX_LINK_SUPPORTED*4)+SEG_OFFSET) & SEG_ADDBYTE);
- dp_sys[dev_num].vpc3_used_dp_buf_mem += p_Vpc3[dev_num]->len_dxb_link_table_buf;
- /*-------------------------------------------------------------------*/
- /* check memory consumption */
- /*-------------------------------------------------------------------*/
- if( dp_sys[dev_num].vpc3_used_dp_buf_mem > sizeof (p_Vpc3[dev_num]->dpbuffer)/BLACKFIN_MULTIPLER )
- {
- // Error: user needs too much memory
- dp_sys[dev_num].vpc3_used_dp_buf_mem = 0;
- error = DP_LESS_MEM_ERROR;
- }
- else
- {
- /*---------------------------------------------------------------*/
- /* set buffer pointer */
- /*---------------------------------------------------------------*/
- p_Vpc3[dev_num]->dxb_link_table_buf_ptr = vpc3_seg_adr;
- p_Vpc3[dev_num]->dxb_link_status_buf_ptr = p_Vpc3[dev_num]->dxb_link_table_buf_ptr + (p_Vpc3[dev_num]->len_dxb_link_table_buf >> SEG_MULDIV);
- p_Vpc3[dev_num]->dxb_out_buf_ptr1 = p_Vpc3[dev_num]->dxb_link_status_buf_ptr + (p_Vpc3[dev_num]->len_dxb_link_status_buf >> SEG_MULDIV);
- p_Vpc3[dev_num]->dxb_out_buf_ptr2 = p_Vpc3[dev_num]->dxb_out_buf_ptr1 + (p_Vpc3[dev_num]->len_dxb_out_buf >> SEG_MULDIV);
- p_Vpc3[dev_num]->dxb_out_buf_ptr3 = p_Vpc3[dev_num]->dxb_out_buf_ptr2 + (p_Vpc3[dev_num]->len_dxb_out_buf >> SEG_MULDIV);
- }
- }
- return error;
- }
- #endif//#ifdef DP_SUBSCRIBER
- /*---------------------------------------------------------------------------*/
- /* */
- /* DP_ERROR_CODE vpc3_calculate_inp_outp_len (UBYTE dev_num, */
- /* VPC3_UNSIGNED8_PTR cfg_ptr, */
- /* UBYTE cfg_len ) */
- /* */
- /* function: Calculation of Inputs/Outputs. */
- /* */
- /* parameter: cfg_ptr: Pointer to configuration buffer. */
- /* cfg_len: Length of configuration data. */
- /* return value: - */
- /* */
- /*---------------------------------------------------------------------------*/
- SECTION_DEF_CommuCode DP_ERROR_CODE vpc3_calculate_inp_outp_len (UBYTE dev_num,VPC3_UNSIGNED8_PTR cfg_ptr, UBYTE cfg_len)
- {
- DP_ERROR_CODE error;
- UBYTE specific_data_length;
- UBYTE temp_outp_data_len;
- UBYTE temp_inp_data_len;
- UBYTE length;
- UBYTE count;
- error = DP_OK;
- temp_outp_data_len = 0;
- temp_inp_data_len = 0;
- if( (cfg_len > 0) && (cfg_len <= dp_sys[dev_num].cfg_bufsize) )
- {
- for( ; cfg_len > 0; cfg_len -= count)
- {
- count = 0;
- if (*cfg_ptr & VPC3_CFG_IS_BYTE_FORMAT)
- {
- // general identifier format
- count++;
- // cfg_ptr points to "Configurationbyte", CFG_BF means "CFG_IS_BYTE_FORMAT"
- length = (UBYTE)( (*cfg_ptr & VPC3_CFG_BF_LENGTH) + 1 );
- if(*cfg_ptr & VPC3_CFG_LENGTH_IS_WORD_FORMAT)
- {
- length *= 2;
- }
- if(*cfg_ptr & VPC3_CFG_BF_OUTP_EXIST)
- {
- temp_outp_data_len += length;
- }
- if(*cfg_ptr & VPC3_CFG_BF_INP_EXIST)
- {
- temp_inp_data_len += length;
- }
- cfg_ptr++;
- }
- else
- {
- // cfg_ptr points to the headerbyte of "special identifier format
- // CFG_SF means "CFG_IS_SPECIAL_FORMAT"
- if(*cfg_ptr & VPC3_CFG_SF_OUTP_EXIST)
- {
- count++; // next UBYTE contains the length of outp_data
- length = (UBYTE)((*(cfg_ptr + count) & VPC3_CFG_SF_LENGTH) +1);
- if(*(cfg_ptr + count) & VPC3_CFG_LENGTH_IS_WORD_FORMAT)
- {
- temp_outp_data_len += (2*length);
- }
- else
- {
- temp_outp_data_len += length;
- }
- }
- if(*cfg_ptr & VPC3_CFG_SF_INP_EXIST)
- {
- count++; // next UBYTE copntains the length of inp_data
- length = (UBYTE)((*(cfg_ptr + count) & VPC3_CFG_SF_LENGTH) +1);
- if(*(cfg_ptr + count) & VPC3_CFG_LENGTH_IS_WORD_FORMAT)
- {
- temp_inp_data_len += (2*length);
- }
- else
- {
- temp_inp_data_len += length;
- }
- }
- specific_data_length = (UBYTE)(*cfg_ptr & VPC3_CFG_BF_LENGTH);
- if(specific_data_length != 15)
- {
- count = (UBYTE)(count + 1 + specific_data_length);
- cfg_ptr = cfg_ptr + count;
- }
- else
- {
- // specific data length = 15 not allowed
- dp_sys[dev_num].inp_data_len = 0xFF;
- dp_sys[dev_num].outp_data_len = 0xFF;
- error = DP_CALCULATE_IO_ERROR;
- }
- }
- }//for( ; cfg_len > 0; cfg_len -= count)
- if( ( cfg_len != 0 ) || ( temp_inp_data_len > dp_sys[dev_num].din_bufsize ) || ( temp_outp_data_len > dp_sys[dev_num].dout_bufsize ) )
- {
- dp_sys[dev_num].inp_data_len = 0xFF;
- dp_sys[dev_num].outp_data_len = 0xFF;
- error = DP_CALCULATE_IO_ERROR;
- }
- else
- {
- dp_sys[dev_num].inp_data_len = temp_inp_data_len;
- dp_sys[dev_num].outp_data_len = temp_outp_data_len;
- error = DP_OK;
- }
- }//if( (cfg_len > 0) && (cfg_len <= vpc3_dp_init.cfg_buf_len) )
- else
- {
- dp_sys[dev_num].inp_data_len = 0xFF;
- dp_sys[dev_num].outp_data_len = 0xFF;
- error = DP_CALCULATE_IO_ERROR;
- }
- //TRACE("Dev:%d inp_data_len: %d outp_data_len:%d ", dev_num, dp_sys[dev_num].inp_data_len,dp_sys[dev_num].outp_data_len);
- return error;
- }//vpc3_calculate_inp_outp_len (UBYTE dev_num,VPC3_UNSIGNED8_PTR cfg_ptr, UBYTE cfg_len)
- /*---------------------------------------------------------------------------*/
- /* */
- /* DP_ERROR_CODE vpc3_buf_init (UBYTE dev_num) */
- /* */
- /* function: Initializing VPC3 buffers. */
- /* */
- /* parameter: none */
- /* return value: DP_OK : Buffer length OK */
- /* ERROR : defined in dp_error.h */
- /* */
- /*---------------------------------------------------------------------------*/
- SECTION_DEF_CommuCode DP_ERROR_CODE vpc3_buf_init(UBYTE dev_num)
- {
- DP_ERROR_CODE error;
- UWORD aux_buf_len[2]; // calculated length of AUX buffer
- UWORD r_din_dout_buf_len; // calculated length of real I/O Data length
- UWORD real_buf_len[3]; // real length of AUX-Buffer
- UBYTE aux_ass; // Bit array, in which the assignments of AUX1/2 are defined
- error = DP_OK;
- /*-----------------------------------------------------------------------*/
- /* check buffer length */
- /*-----------------------------------------------------------------------*/
- if (dp_sys[dev_num].dout_bufsize > 244)
- {
- error = DP_DOUT_LEN_ERROR;
- }
- else if(dp_sys[dev_num].din_bufsize > 244)
- {
- error = DP_DIN_LEN_ERROR;
- }
- else if((dp_sys[dev_num].diag_bufsize < 6) || (dp_sys[dev_num].diag_bufsize > 244))
- {
- error = DP_DIAG_LEN_ERROR;
- }
- else if((dp_sys[dev_num].prm_bufsize < 7) || (dp_sys[dev_num].prm_bufsize > 244))
- {
- error = DP_PRM_LEN_ERROR;
- }
- else if((dp_sys[dev_num].cfg_bufsize < 1) || (dp_sys[dev_num].cfg_bufsize > 244))
- {
- error = DP_CFG_LEN_ERROR;
- }
- else if(dp_sys[dev_num].ssa_bufsize != 0 && ((dp_sys[dev_num].ssa_bufsize < 4) || (dp_sys[dev_num].ssa_bufsize > 244)))
- {
- error = DP_SSA_LEN_ERROR;
- }
- if(error == DP_OK)//else
- {
- /*-------------------------------------------------------------------*/
- /* length of buffers ok, check memory consumption */
- /*-------------------------------------------------------------------*/
- if(p_Vpc3[dev_num]->mode_reg0_H & VPC3_SPEC_PRM_BUF_MODE)
- {
- real_buf_len[RBL_PRM] = 0; /* prm-data goes directly into prm-buffer */
- }
- else
- {
- real_buf_len[RBL_PRM] = dp_sys[dev_num].prm_bufsize; // prm-data goes over AUX-buffer
- }
- // length of cfg and ssa buffer
- real_buf_len[RBL_CFG] = dp_sys[dev_num].cfg_bufsize;
- real_buf_len[RBL_SSA] = dp_sys[dev_num].ssa_bufsize;
- /*-------------------------------------------------------------------*/
- /* calculate aux-buffer */
- /*-------------------------------------------------------------------*/
- dp_sys[dev_num].vpc3_used_dp_buf_mem = assign_aux_buf(dev_num,&real_buf_len[0], 3, &aux_ass, &aux_buf_len[0]);
- /*-------------------------------------------------------------------*/
- /* check memory consumption */
- /*-------------------------------------------------------------------*/
- r_din_dout_buf_len = ((dp_sys[dev_num].dout_bufsize + SEG_OFFSET) & SEG_ADDWORD) + ((dp_sys[dev_num].din_bufsize + SEG_OFFSET) & SEG_ADDWORD);
- // DIn DOut buffer
- dp_sys[dev_num].vpc3_used_dp_buf_mem += r_din_dout_buf_len * 3;
- // add Read Config Buffer
- dp_sys[dev_num].vpc3_used_dp_buf_mem += real_buf_len[RBL_CFG];
- // diagnose buffer
- dp_sys[dev_num].vpc3_used_dp_buf_mem += ((dp_sys[dev_num].diag_bufsize + SEG_OFFSET) & SEG_ADDBYTE) * 2;
- // prm buffer
- if(p_Vpc3[dev_num]->mode_reg0_H & VPC3_SPEC_PRM_BUF_MODE)
- {
- // spec. PRM buffer
- real_buf_len[RBL_PRM] = (dp_sys[dev_num].prm_bufsize + SEG_OFFSET) & SEG_ADDBYTE;
- dp_sys[dev_num].vpc3_used_dp_buf_mem += real_buf_len[RBL_PRM];
- p_Vpc3[dev_num]->len_spec_prm_buf = dp_sys[dev_num].prm_bufsize;
- }
- else
- {
- p_Vpc3[dev_num]->len_spec_prm_buf = 0;
- }
- if( dp_sys[dev_num].vpc3_used_dp_buf_mem > sizeof (p_Vpc3[dev_num]->dpbuffer)/BLACKFIN_MULTIPLER )
- {
- // Error: user needs too much memory
- dp_sys[dev_num].vpc3_used_dp_buf_mem = 0;
- error = DP_LESS_MEM_ERROR;
- }
- else
- {
- /*---------------------------------------------------------------*/
- /* set buffer pointer */
- /*---------------------------------------------------------------*/
- p_Vpc3[dev_num]->aux_buf_sel = aux_ass; // AUX-Puffer zuordnen
- p_Vpc3[dev_num]->dout_buf_ptr[0] = VPC3_DP_BUF_START(dev_num);
- p_Vpc3[dev_num]->dout_buf_ptr[1] = p_Vpc3[dev_num]->dout_buf_ptr[0] + (((dp_sys[dev_num].dout_bufsize + SEG_OFFSET) & SEG_ADDBYTE)>>SEG_MULDIV);
- p_Vpc3[dev_num]->dout_buf_ptr[2] = p_Vpc3[dev_num]->dout_buf_ptr[1] + (((dp_sys[dev_num].dout_bufsize + SEG_OFFSET) & SEG_ADDBYTE)>>SEG_MULDIV);
- p_Vpc3[dev_num]->din_buf_ptr[0] = p_Vpc3[dev_num]->dout_buf_ptr[2] + (((dp_sys[dev_num].dout_bufsize + SEG_OFFSET) & SEG_ADDBYTE)>>SEG_MULDIV);
- p_Vpc3[dev_num]->din_buf_ptr[1] = p_Vpc3[dev_num]->din_buf_ptr[0] + (((dp_sys[dev_num].din_bufsize + SEG_OFFSET) & SEG_ADDBYTE)>>SEG_MULDIV);
- p_Vpc3[dev_num]->din_buf_ptr[2] = p_Vpc3[dev_num]->din_buf_ptr[1] + (((dp_sys[dev_num].din_bufsize + SEG_OFFSET) & SEG_ADDBYTE)>>SEG_MULDIV);
- p_Vpc3[dev_num]->diag_buf_ptr[0] = p_Vpc3[dev_num]->din_buf_ptr[2] + (((dp_sys[dev_num].din_bufsize + SEG_OFFSET) & SEG_ADDBYTE)>>SEG_MULDIV);
- p_Vpc3[dev_num]->diag_buf_ptr[1] = p_Vpc3[dev_num]->diag_buf_ptr[0] + (((dp_sys[dev_num].diag_bufsize + SEG_OFFSET) & SEG_ADDBYTE)>>SEG_MULDIV);
- p_Vpc3[dev_num]->cfg_buf_ptr = p_Vpc3[dev_num]->diag_buf_ptr[1] + (((dp_sys[dev_num].diag_bufsize + SEG_OFFSET) & SEG_ADDBYTE)>>SEG_MULDIV);
- p_Vpc3[dev_num]->read_cfg_buf_ptr = p_Vpc3[dev_num]->cfg_buf_ptr + (real_buf_len[RBL_CFG]>>SEG_MULDIV);
- p_Vpc3[dev_num]->prm_buf_ptr = p_Vpc3[dev_num]->read_cfg_buf_ptr + (real_buf_len[RBL_CFG]>>SEG_MULDIV);
- p_Vpc3[dev_num]->aux_buf_ptr[0] = p_Vpc3[dev_num]->prm_buf_ptr + (real_buf_len[RBL_PRM]>>SEG_MULDIV);
- if( aux_buf_len[1] != 0 )
- {
- p_Vpc3[dev_num]->aux_buf_ptr[1] = p_Vpc3[dev_num]->aux_buf_ptr[0] + (aux_buf_len[0]>>SEG_MULDIV);
- }
- else
- {
- p_Vpc3[dev_num]->aux_buf_ptr[1] = 0;
- }
- if (real_buf_len[RBL_SSA] == 0)
- {
- // no ssa supported
- p_Vpc3[dev_num]->ssa_buf_ptr = 0; /* Dienst sperren */
- }
- else
- {
- // ssa supported
- if( aux_buf_len[1] != 0 )
- {
- p_Vpc3[dev_num]->ssa_buf_ptr = p_Vpc3[dev_num]->aux_buf_ptr[1] + (aux_buf_len[1]>>SEG_MULDIV);
- }
- else
- {
- p_Vpc3[dev_num]->ssa_buf_ptr = p_Vpc3[dev_num]->aux_buf_ptr[0] + (aux_buf_len[0]>>SEG_MULDIV);
- }
- }
- /*---------------------------------------------------------------*/
- /* set buffer length */
- /*---------------------------------------------------------------*/
- p_Vpc3[dev_num]->len_dout_buf = dp_sys[dev_num].outp_data_len;
- p_Vpc3[dev_num]->len_din_buf = dp_sys[dev_num].inp_data_len;
- p_Vpc3[dev_num]->len_diag_buf[0] = 6; // length of Diag Buffers
- p_Vpc3[dev_num]->len_diag_buf[1] = 6;
- if(aux_buf_len[0] >= 244)
- {
- p_Vpc3[dev_num]->len_ctrl_buf[0] = 244; // Length AUX1-Buffer
- }
- else
- {
- p_Vpc3[dev_num]->len_ctrl_buf[0] = aux_buf_len[0]; // Length AUX1-Buffer
- }
- if(aux_buf_len[1] >= 244)
- {
- p_Vpc3[dev_num]->len_ctrl_buf[1] = 244; // Length AUX1-Buffer
- }
- else
- {
- p_Vpc3[dev_num]->len_ctrl_buf[1] = aux_buf_len[1]; // Length AUX1-Buffer
- }
- p_Vpc3[dev_num]->len_cfg_data = dp_sys[dev_num].cfg_bufsize;
- p_Vpc3[dev_num]->len_prm_data = dp_sys[dev_num].prm_bufsize;
- p_Vpc3[dev_num]->len_ssa_buf = dp_sys[dev_num].ssa_bufsize;
- }
- }
- return error;
- }//DP_ERROR_CODE vpc3_buf_init(UBYTE dev_num)
- /*---------------------------------------------------------------------------*/
- /* */
- /* UBYTE vpc3_cfg_data_ok(UBYTE dev_num) */
- /* */
- /* function: Set Configuration Data ok */
- /* */
- /* parameter: none */
- /* return value: VPC3_CFG_FINISHED: The transferred configuration is OK. */
- /* VPC3_CFG_CONFLICT: Repeat verification of the requested */
- /* configuration. */
- /* */
- /*---------------------------------------------------------------------------*/
- SECTION_DEF_CommuCode UBYTE vpc3_cfg_data_ok(UBYTE dev_num)
- {
- return p_Vpc3[dev_num]->ctrl_reg.rd.user_cfg_data_ok;
- }
- /*---------------------------------------------------------------------------*/
- /* */
- /* UBYTE vpc3_cfg_data_update(UBYTE dev_num) */
- /* */
- /* function: Update Configuration Data */
- /* */
- /* parameter: none */
- /* return value: VPC3_CFG_FINISHED: The transferred configuration is OK. */
- /* VPC3_CFG_CONFLICT: Repeat verification of the requested */
- /* configuration. */
- /* */
- /*---------------------------------------------------------------------------*/
- SECTION_DEF_CommuCode UBYTE vpc3_cfg_data_update(UBYTE dev_num)
- {
- int nBlackfinLoop;
- uint16* pBlackfinAddr;
- uint16* pSrcAddr;
- p_Vpc3[dev_num]->len_read_cfg_data = p_Vpc3[dev_num]->len_cfg_data;
- // memcpy( VPC3_GET_READ_CFG_BUF_PTR(dev_num), VPC3_GET_CFG_BUF_PTR(dev_num), p_Vpc3[dev_num]->len_cfg_data);
- pSrcAddr = (uint16*)VPC3_GET_CFG_BUF_PTR(dev_num);
- pBlackfinAddr = (uint16*)VPC3_GET_READ_CFG_BUF_PTR(dev_num);
- for (nBlackfinLoop=0; nBlackfinLoop<BFWORD2BYTE(p_Vpc3[dev_num]->len_cfg_data); nBlackfinLoop++)
- {
- pBlackfinAddr[nBlackfinLoop] = pSrcAddr[nBlackfinLoop];
- }
- return p_Vpc3[dev_num]->ctrl_reg.rd.user_cfg_data_ok;
- }
- /*---------------------------------------------------------------------------*/
- /* D e s c r i p t i o n : vpc3_cfg_data_not_ok */
- /* */
- /* function: Set Configuration Data not ok */
- /* */
- /* parameter: none */
- /* return value: VPC3_CFG_FINISHED: The transferred configuration is OK. */
- /* VPC3_CFG_CONFLICT: Repeat verification of the requested */
- /* configuration. */
- /*---------------------------------------------------------------------------*/
- SECTION_DEF_CommuCode UBYTE vpc3_cfg_data_not_ok(UBYTE dev_num)
- {
- return p_Vpc3[dev_num]->ctrl_reg.rd.user_cfg_data_nok;
- }
- /*---------------------------------------------------------------------------*/
- /* D e s c r i p t i o n : vpc3_get_doutbufptr */
- /* */
- /* This function fetches the pointer to the actual output buffer. */
- /*---------------------------------------------------------------------------*/
- SECTION_DEF_CommuCode VPC3_UNSIGNED8_PTR vpc3_get_doutbufptr (UBYTE dev_num,UBYTE PTR_ATTR *state_ptr)
- {
- VPC3_UNSIGNED8_PTR p_doutbuf; // pointer to output buffer ( DP-Master -> VPC3+ )
- *state_ptr = (p_Vpc3[dev_num]->ctrl_reg.rd.next_dout_buf_cmd & (VPC3_NEW_DOUT_BUF | VPC3_DOUT_BUF_CLEARED));
- switch (p_Vpc3[dev_num]->ctrl_reg.rd.dout_buffer_sm & 0x30) // locate user Dout Buffer
- {
- case 0x10:
- {
- p_doutbuf = (VPC3_UNSIGNED8_PTR)((VPC3_ADR)( BFWORD2BYTE(p_Vpc3[dev_num]->dout_buf_ptr[0]) << BLACKFIN_SEG_MULDIV)+(VPC3_ADR)VPC3_ASIC_ADDRESS(dev_num));
- break;
- }
- case 0x20:
- {
- p_doutbuf = (VPC3_UNSIGNED8_PTR)((VPC3_ADR)( BFWORD2BYTE(p_Vpc3[dev_num]->dout_buf_ptr[1]) << BLACKFIN_SEG_MULDIV)+(VPC3_ADR)VPC3_ASIC_ADDRESS(dev_num));
- break;
- }
- case 0x30:
- {
- p_doutbuf = (VPC3_UNSIGNED8_PTR)((VPC3_ADR)( BFWORD2BYTE(p_Vpc3[dev_num]->dout_buf_ptr[2]) << BLACKFIN_SEG_MULDIV)+(VPC3_ADR)VPC3_ASIC_ADDRESS(dev_num));
- break;
- }
- default:
- {
- p_doutbuf = NULL_PTR;
- break;
- }
- }//switch (p_Vpc3[dev_num]->ctrl_reg.rd.dout_buffer_sm & 0x30) // locate user Dout Buffer
- return p_doutbuf;
- }
- /*---------------------------------------------------------------------------*/
- /* D e s c r i p t i o n : vpc3_get_dinbufptr */
- /* */
- /* This function fetches the pointer to the actual input buffer. */
- /*---------------------------------------------------------------------------*/
- SECTION_DEF_CommuCode VPC3_UNSIGNED8_PTR vpc3_get_dinbufptr (UBYTE dev_num)
- {
- VPC3_UNSIGNED8_PTR p_dinbuf; // pointer to output buffer ( VPC3 -> DP-Master )
- switch (p_Vpc3[dev_num]->ctrl_reg.rd.din_buffer_sm & 0x30) // locate user Din Buffer
- {
- case 0x10:
- {
- p_dinbuf = (VPC3_UNSIGNED8_PTR)((VPC3_ADR)( BFWORD2BYTE(p_Vpc3[dev_num]->din_buf_ptr[0]) << BLACKFIN_SEG_MULDIV)+(VPC3_ADR)VPC3_ASIC_ADDRESS(dev_num));
- break;
- }
- case 0x20:
- {
- p_dinbuf = (VPC3_UNSIGNED8_PTR)((VPC3_ADR)( BFWORD2BYTE(p_Vpc3[dev_num]->din_buf_ptr[1]) << BLACKFIN_SEG_MULDIV)+(VPC3_ADR)VPC3_ASIC_ADDRESS(dev_num));
- break;
- }
- case 0x30:
- {
- p_dinbuf = (VPC3_UNSIGNED8_PTR)((VPC3_ADR)( BFWORD2BYTE(p_Vpc3[dev_num]->din_buf_ptr[2]) << BLACKFIN_SEG_MULDIV)+(VPC3_ADR)VPC3_ASIC_ADDRESS(dev_num));
- break;
- }
- default:
- {
- p_dinbuf = NULL_PTR;
- break;
- }
- }//switch (p_Vpc3[dev_num]->ctrl_reg.rd.din_buffer_sm & 0x30)
- return p_dinbuf;
- }
- /*---------------------------------------------------------------------------*/
- /* D e s c r i p t i o n : vpc3_get_dxb_outbufptr */
- /* */
- /* This function fetches the pointer to the actual dxb output buffer. */
- /*---------------------------------------------------------------------------*/
- #ifdef DP_SUBSCRIBER
- SECTION_DEF_CommuCode VPC3_UNSIGNED8_PTR vpc3_get_dxb_outbufptr (UBYTE dev_num,UBYTE PTR_ATTR *state_ptr)
- {
- VPC3_UNSIGNED8_PTR p_doutbuf; // pointer to output buffer (DP-Master -> VPC3+ )
- *state_ptr = (p_Vpc3[dev_num]->ctrl_reg.rd.next_dxb_buf_cmd & (VPC3_NEW_DOUT_BUF | VPC3_DOUT_BUF_CLEARED));
- switch (p_Vpc3[dev_num]->ctrl_reg.rd.dxbout_buffer_sm & 0x30) // locate user DXBout Buffer
- {
- case 0x10:
- {
- p_doutbuf = (VPC3_UNSIGNED8_PTR)((VPC3_ADR)( BFWORD2BYTE(p_Vpc3[dev_num]->dxb_out_buf_ptr1) << BLACKFIN_SEG_MULDIV)+(VPC3_ADR)VPC3_ASIC_ADDRESS(dev_num));
- break;
- }
- case 0x20:
- {
- p_doutbuf = (VPC3_UNSIGNED8_PTR)((VPC3_ADR)( BFWORD2BYTE(p_Vpc3[dev_num]->dxb_out_buf_ptr2) << BLACKFIN_SEG_MULDIV)+(VPC3_ADR)VPC3_ASIC_ADDRESS(dev_num));
- break;
- }
- case 0x30:
- {
- p_doutbuf = (VPC3_UNSIGNED8_PTR)((VPC3_ADR)( BFWORD2BYTE(p_Vpc3[dev_num]->dxb_out_buf_ptr3) << BLACKFIN_SEG_MULDIV)+(VPC3_ADR)VPC3_ASIC_ADDRESS(dev_num));
- break;
- }
- default:
- {
- p_doutbuf = NULL_PTR;
- break;
- }
- }//switch (p_Vpc3[dev_num]->ctrl_reg.rd.dxb_out_buffer_sm & 0x30) // locate user Dout Buffer
- return p_doutbuf;
- }
- /*-------------------------------------------------------------------*/
- /* function: dxb_subscriber_table_to_dxb_link_table */
- /*-------------------------------------------------------------------*/
- SECTION_DEF_CommuCode void dxb_subscriber_table_to_dxb_link_table(UBYTE dev_num, PRM_SUBSCRIBER_TABLE_PTR dxb_ptr, UBYTE NrOfLinks )
- {
- PRM_DXB_LINK_TABLE link_table;
- UBYTE i;
- int nBlackfinLoop;
- uint16* pBlackfinAddr;
- uint16* pSrcAddr;
- memset( &link_table, 0, sizeof(PRM_DXB_LINK_TABLE));//!!! 如果V2要改...
- link_table.version = dxb_ptr->version;
- for(i = 0; i < NrOfLinks; i++ )
- {
- link_table.link_table_entry[i].publisher_addr = dxb_ptr->subscriber_table_entry[i].publisher_addr;
- link_table.link_table_entry[i].publisher_length = dxb_ptr->subscriber_table_entry[i].publisher_length;
- link_table.link_table_entry[i].sample_offset = dxb_ptr->subscriber_table_entry[i].sample_offset;
- link_table.link_table_entry[i].sample_length = dxb_ptr->subscriber_table_entry[i].sample_length;
- }
- VPC3_SET_DXB_LINK_TABLE_LEN(dev_num, NrOfLinks<<2);
- //memcpy( VPC3_GET_DXB_LINK_TABLE_BUF_PTR(dev_num), &link_table.link_table_entry[0].publisher_addr, (NrOfLinks<<2));
- pBlackfinAddr = (uint16*)VPC3_GET_DXB_LINK_TABLE_BUF_PTR(dev_num);
- pSrcAddr = (uint16*)&link_table.link_table_entry[0].publisher_addr;
- for (nBlackfinLoop=0; nBlackfinLoop<(NrOfLinks<<2); nBlackfinLoop++)
- {
- pBlackfinAddr[nBlackfinLoop] = pSrcAddr[nBlackfinLoop];
- }
- }
- /*-------------------------------------------------------------------*/
- /* function: check_dxb_link_table */
- /*-------------------------------------------------------------------*/
- SECTION_DEF_CommuCode UBYTE check_dxb_link_table(UBYTE dev_num)
- {
- VPC3_DXB_LINK_TABLE_PTR dxb_ptr;
- UBYTE ret_value;
- UBYTE i;
- ret_value = DP_OK;
- dxb_ptr = (VPC3_DXB_LINK_TABLE_PTR)VPC3_GET_DXB_LINK_TABLE_BUF_PTR(dev_num);
- for(i = 0; i < (VPC3_GET_DXB_LINK_TABLE_LEN(dev_num)/4); i++)
- {
- if( (dxb_ptr->link_table_entry[i].publisher_addr > 125)
- || (dxb_ptr->link_table_entry[i].publisher_length < 1 )
- || (dxb_ptr->link_table_entry[i].publisher_length > 244)
- || (dxb_ptr->link_table_entry[i].sample_offset > (dxb_ptr->link_table_entry[i].publisher_length - 1))
- || ((dxb_ptr->link_table_entry[i].sample_offset + dxb_ptr->link_table_entry[i].sample_length) >
- (dxb_ptr->link_table_entry[i].publisher_length))
- || (dxb_ptr->link_table_entry[i].sample_length > MAX_DATA_PER_LINK-2)
- )
- {
- ret_value = DP_PRM_DXB_ERROR;
- VPC3_SET_DXB_LINK_TABLE_LEN(dev_num,0);
- break;
- }
- }
- return ret_value;
- }
- /*-------------------------------------------------------------------*/
- /* function: build_dxb_link_status */
- /*-------------------------------------------------------------------*/
- SECTION_DEF_CommuCode void build_dxb_link_status(UBYTE dev_num)
- {
- VPC3_DXB_LINK_TABLE_PTR dxb_ptr;
- VPC3_DXB_LINK_STATUS link_status;
- UBYTE i;
- int nBlackfinLoop;
- uint16* pBlackfinAddr;
- uint16* pSrcAddr;
- memset( &link_status, 0, sizeof(VPC3_DXB_LINK_STATUS));//!!! 如果V2要改...
- dxb_ptr = (VPC3_DXB_LINK_TABLE_PTR)VPC3_GET_DXB_LINK_TABLE_BUF_PTR(dev_num);
- link_status.header = 4+(VPC3_GET_DXB_LINK_TABLE_LEN(dev_num)/2);
- link_status.status_type = 0x83;
- link_status.slot_number = 0x00;
- link_status.status_specifier = 0x00;
- for(i = 0; i < ((link_status.header-4) / 2); i++)
- {
- link_status.link_status[i].publisher_addr = dxb_ptr->link_table_entry[i].publisher_addr;
- link_status.link_status[i].link_status = 0x00;
- }
- VPC3_SET_DXB_LINK_STATUS_LEN(dev_num, link_status.header);
- //memcpy( VPC3_GET_DXB_LINK_STATUS_BUF_PTR(dev_num), &link_status, link_status.header);
- pBlackfinAddr = (uint16*)VPC3_GET_DXB_LINK_STATUS_BUF_PTR(dev_num);
- pSrcAddr = (uint16*)&link_status;
- for (nBlackfinLoop=0; nBlackfinLoop<link_status.header; nBlackfinLoop++)
- {
- pBlackfinAddr[nBlackfinLoop] = pSrcAddr[nBlackfinLoop];
- }
- }
- #endif//#ifdef DP_SUBSCRIBER
- /*---------------------------------------------------------------------------*/
- /* */
- /* The function provides the actual prm-master by read out the diag- */
- /* buffer in vpc3. */
- /*---------------------------------------------------------------------------*/
- SECTION_DEF_CommuCode UBYTE vpc3_get_master(UBYTE dev_num)
- {
- UBYTE master;
- master = *((VPC3_UNSIGNED8_PTR)(((VPC3_ADR)(( BFWORD2BYTE(p_Vpc3[dev_num]->diag_buf_ptr[0]) << SEG_MULDIV)+3)*BLACKFIN_MULTIPLER+((VPC3_ADR)VPC3_ASIC_ADDRESS(dev_num)))));
- if( (master&0xff) == 0xFF )//2009.11.7
- {
- master = *((VPC3_UNSIGNED8_PTR)(((VPC3_ADR)(( BFWORD2BYTE(p_Vpc3[dev_num]->diag_buf_ptr[1]) << SEG_MULDIV)+3)*BLACKFIN_MULTIPLER+((VPC3_ADR)VPC3_ASIC_ADDRESS(dev_num)))));
- }
- return (master&0xff);//2009.11.7
- }
- /********************************************************************************
- * *
- * UWORD assign_aux_buf (UBYTE dev_num, UWORD PTR_ATTR *lens, UBYTE count, *
- * UBYTE PTR_ATTR *assign, *
- * UWORD PTR_ATTR *aux_len) *
- * *
- * function: Calculate length of AUX buffers. *
- * *
- * parameter: lens : pointer of list to the buffer length *
- * count : length of list (2..3) *
- * assign : Bit array, in which the assignments of the *
- * AUX-buffers1 and 2 are defined to the control *
- * buffers, SSA-Buf, PRM-Buf, Cfg-Buf *
- * aux_len : Pointer to a 2 byte field of aux-buffer length. *
- * return value: count of bytes used for aux buffers. *
- * *
- ********************************************************************************/
- SECTION_DEF_CommuCode UWORD assign_aux_buf(UBYTE dev_num,UWORD PTR_ATTR *lens, UBYTE count, UBYTE PTR_ATTR *assign, UWORD PTR_ATTR *aux_len)
- {
- UWORD min_len = 0xffff; // calculated minimal length
- UBYTE min_step = 0; // step by calculated minimal length
- UBYTE i,j;
- UBYTE pos[3]; // memory for position of length
- UWORD lensx[3]; // workarea for calculated length
- UBYTE step; // counter
- UWORD wtmp; // tmp-variable for calculated length
- UBYTE tmp; // tmp-variable for calculated length
- // tmp-varaiable for sorted positions
- // check count
- if((count == 2) || (count == 3))
- {
- for(i = 0; i < count; i++)
- {
- // init memory for position of length
- pos[i] = i;
- // copy length into workarea for calculated length
- lensx[i] = lens[i];
- // put length to 8 Bit Segmentaddresses
- lensx[i] = (lensx[i] + SEG_OFFSET) & SEG_ADDWORD;
- }
- // sort length, highest length to index 0
- for(i = 0; i < count-1; i++)
- {
- for(j = i+1; j < count; j++)
- {
- if(lensx[i] < lensx[j])
- {
- // found higher length
- tmp = lensx[i]; // swap length
- lensx[i] = lensx[j];
- lensx[j] = tmp;
- tmp = pos[i]; // swap position
- pos[i] = pos[j];
- pos[j] = tmp;
- }
- }
- }
- // delete zero length from list lensx
- for(i = count; i > 0; i--)
- {
- if(lensx[i-1] == 0)
- {
- count--;
- }
- }
- if( count == 0 )
- {
- min_len = 0; // Error: no defined buffer length
- }
- // gradual length assign to aux-buffer
- for(step = 0; step < count; step++)
- {
- // get length for AUX-Buffer 1
- aux_len[0] = 0;
- for(i = step; i < count; i++)
- {
- if(aux_len[0] < lensx[i])
- {
- aux_len[0] = lensx[i];
- }
- }
- aux_len[0] = aux_len[0] * (count - step + 1);
- // get length for AUX-Buffer 2
- aux_len[1] = 0;
- for(i = 0; i < step; i++)
- {
- if(aux_len[1] < lensx[i])
- {
- aux_len[1] = lensx[i];
- }
- }
- aux_len[1] = aux_len[1] * (step + 1);
- if((aux_len[0] + aux_len[1]) < min_len)
- {
- // new minimal length found
- min_len = aux_len[0] + aux_len[1];
- min_step = step;
- }
- }
- // calculate length for AUX Buffer 1
- aux_len[0] = 0;
- for(i = min_step; i < count; i++)
- {
- if(aux_len[0] < lensx[i])
- {
- aux_len[0] = lensx[i];
- }
- }
- // put length, assigned for AUX buffer 1
- for(i = min_step; i < count; i++)
- {
- lens[pos[i]] = aux_len[0];
- }
- // calculate length of AUX-Buffer 2
- aux_len[1] = 0;
- for(i = 0; i < min_step; i++)
- {
- if (aux_len[1] < lensx[i])
- {
- aux_len[1] = lensx[i];
- }
- }
- *assign = 0; // put all buffer to AUX-Buffer 1
- for(i = 0; i < min_step; i++)
- {
- lens[pos[i]] = aux_len[1];
- *assign |= 0x1 << pos[i];
- }
- //check here for VPC3+/B
- //handle Cfg-telegram only over AUX-Buffer 1
- if( *assign & 0x02 )
- {
- tmp = (*assign);
- *assign = ((~tmp)&0x07);
- //*assign &= 0x07;
- wtmp = aux_len[0];
- aux_len[0] = aux_len[1];
- aux_len[1] = wtmp;
- }
- }
- else
- {
- min_len = 0; // error
- }
- return min_len;
- }
- /*---------------------------------------------------------------------------*/
- /* void vpc3_set_io_data_len(UBYTE dev_num) */
- /*---------------------------------------------------------------------------*/
- SECTION_DEF_CommuCode void vpc3_set_io_data_len(UBYTE dev_num)
- {
- // length of buffers OK, set real buffers
- p_Vpc3[dev_num]->len_dout_buf = dp_sys[dev_num].outp_data_len;
- p_Vpc3[dev_num]->len_din_buf = dp_sys[dev_num].inp_data_len;
- }
- /*---------------------------------------------------------------------------*/
- /* D e s c r i p t i o n : vpc3_get_diagbufptr */
- /* */
- /* This function fetches the pointer to the actual diagnosis buffer. */
- /*---------------------------------------------------------------------------*/
- SECTION_DEF_CommuCode VPC3_UNSIGNED8_PTR vpc3_get_diagbufptr (UBYTE dev_num)
- {
- VPC3_UNSIGNED8_PTR p_diagbuf; // pointer to diagnosis buffer
- if((p_Vpc3[dev_num]->ctrl_reg.rd.diag_buffer_sm & 0x03) == 0x01) // locate Diag Buffer
- {
- p_diagbuf = (VPC3_UNSIGNED8_PTR)((VPC3_ADR)(( BFWORD2BYTE(p_Vpc3[dev_num]->diag_buf_ptr[0]) << BLACKFIN_SEG_MULDIV))+(VPC3_ADR)VPC3_ASIC_ADDRESS(dev_num));
- }
- else
- {
- if((p_Vpc3[dev_num]->ctrl_reg.rd.diag_buffer_sm & 0x0C) == 0x04)
- {
- p_diagbuf = (VPC3_UNSIGNED8_PTR)((VPC3_ADR)(( BFWORD2BYTE(p_Vpc3[dev_num]->diag_buf_ptr[1]) << BLACKFIN_SEG_MULDIV))+(VPC3_ADR)VPC3_ASIC_ADDRESS(dev_num));
- }
- else
- {
- p_diagbuf = NULL_PTR;
- }
- }
- return p_diagbuf;
- }
- /*---------------------------------------------------------------------------*/
- /* function: vpc3_set_diag_update_all */
- /*---------------------------------------------------------------------------*/
- SECTION_DEF_CommuCode VPC3_UNSIGNED8_PTR vpc3_set_diag_update_all(UBYTE dev_num, UBYTE diag_state, UBYTE diag_len )
- {
- VPC3_UNSIGNED8_PTR p_diagbuf; // pointer to diagnosis buffer
- if((p_Vpc3[dev_num]->ctrl_reg.rd.diag_buffer_sm & 0x03) == 0x01) // locate Diag Buffer
- {
- p_Vpc3[dev_num]->len_diag_buf[0] = diag_len; // length of Diag Buffer 1
- *((VPC3_UNSIGNED8_PTR)(((VPC3_ADR)( BFWORD2BYTE(p_Vpc3[dev_num]->diag_buf_ptr[0]) << BLACKFIN_SEG_MULDIV)+((VPC3_ADR)VPC3_ASIC_ADDRESS(dev_num))))) = diag_state;
- }
- else
- {
- if((p_Vpc3[dev_num]->ctrl_reg.rd.diag_buffer_sm & 0x0C) == 0x04)
- {
- p_Vpc3[dev_num]->len_diag_buf[1] = diag_len; // length of Diag Buffer 2
- *((VPC3_UNSIGNED8_PTR)(((VPC3_ADR)( BFWORD2BYTE(p_Vpc3[dev_num]->diag_buf_ptr[1]) << BLACKFIN_SEG_MULDIV)+((VPC3_ADR)VPC3_ASIC_ADDRESS(dev_num))))) = diag_state;
- }
- }
- switch( p_Vpc3[dev_num]->ctrl_reg.rd.new_diag_buf_cmd & 0x03 )
- {
- case 1: // use buffer 1
- {
- p_diagbuf = (VPC3_UNSIGNED8_PTR)(((VPC3_ADR)(( BFWORD2BYTE(p_Vpc3[dev_num]->diag_buf_ptr[0]) << BLACKFIN_SEG_MULDIV))+((VPC3_ADR)VPC3_ASIC_ADDRESS(dev_num))));
- break;
- }
- case 2: // use buffer 2
- {
- p_diagbuf = (VPC3_UNSIGNED8_PTR)(((VPC3_ADR)(( BFWORD2BYTE(p_Vpc3[dev_num]->diag_buf_ptr[1]) << BLACKFIN_SEG_MULDIV))+((VPC3_ADR)VPC3_ASIC_ADDRESS(dev_num))));
- break;
- }
- default:
- {
- // no buffer available
- p_diagbuf = NULL_PTR;
- break;
- }
- }
- return p_diagbuf;
- }
- /*---------------------------------------------------------------------------*/
- /* function: reset_diagnostic_buffer */
- /*---------------------------------------------------------------------------*/
- SECTION_DEF_CommuCode void reset_diagnostic_buffer(UBYTE dev_num)
- {
- VPC3_UNSIGNED8_PTR diag_ptr;
- do
- {
- //fetch new diagnosis buffer
- diag_ptr = vpc3_get_diagbufptr(dev_num);
- }
- while(diag_ptr == NULL_PTR );
- //clear diagnostic buffer
- vpc3_set_diag_update_all(dev_num, 0, 6 );
- }//void reset_diagnostic_buffer(UBYTE dev_num)
- /*--------------------------------------------------------------------------*/
- /* set_diagnose (called by DP, DPV1-ALARM) */
- /*--------------------------------------------------------------------------*/
- SECTION_DEF_CommuCode DP_ERROR_CODE set_diagnosis(UBYTE dev_num, VPC3_UNION_DIAG_PTR user_diag, UBYTE user_diag_len, UBYTE diag_control, UBYTE check_diag_flag )
- {
- VPC3_UNION_DIAG_PTR tmp_user_diag;
- DP_ERROR_CODE ret_value;
- UBYTE tmp_user_diag_len;
- UBYTE tmp_len;
- UBYTE dp_state;
- int nBlackfinLoop;
- uint16* pBlackfinAddr;
- //uint16* pSrcAddr;
- ret_value = DP_OK;
- //check available diag buffer
- if( dp_sys[dev_num].diag_buf_ptr.byte_ptr != NULL_PTR )
- {
- tmp_user_diag = user_diag;
- tmp_user_diag_len = user_diag_len;
- dp_state = VPC3_GET_DP_STATE(dev_num);
- if( (dp_state == DATA_EX) && (check_diag_flag == TRUE) )
- {
- if( VPC3_GET_DIAG_FLAG(dev_num) )
- {
- //old diagnosis not send
- ret_value = DP_DIAG_OLD_DIAG_NOT_SEND_ERROR;
- }//if( VPC3_GET_DIAG_FLAG(dev_num) )
- }//if( (dp_state == DATA_EX) && (check_diag_flag == TRUE) )
- // check user_diag_len
- if( user_diag_len > (dp_sys[dev_num].diag_bufsize-6) )
- {
- ret_value = DP_DIAG_BUFFER_LENGTH_ERROR;
- }//if( user_diag_len > (dp_sys[dev_num].diag_bufsize-6) )
- if( ret_value == DP_OK )
- {
- //check control byte
- switch(diag_control )
- {
- case EXT_DIAG_SET:
- {
- if( user_diag_len == 0 )
- {
- ret_value = DP_DIAG_CONTROL_BYTE_ERROR;
- }//if( user_diag_len == 0 )
- break;
- }//case EXT_DIAG_SET:
- default:
- {
- //do nothing
- break;
- }//default:
- }//switch( diag_control )
- //check user diag buffer contents
- while((0 < tmp_user_diag_len) && (DP_OK == ret_value) )
- {
- tmp_len = tmp_user_diag.struc_ptr->dev.sign_len;
- switch(DIAG_TYPE_MASK & tmp_user_diag.struc_ptr->dev.sign_len )
- {
- case DIAG_TYPE_DEV:
- {
- if( STATUS_DIAG_HEAD_SIZE > (tmp_len = (~DIAG_TYPE_MASK) & tmp_len) )
- {
- ret_value = DP_DIAG_BUFFER_ERROR;
- }//if( STATUS_DIAG_HEAD_SIZE > (tmp_len = (~DIAG_TYPE_MASK) & tmp_len) )
- break;
- }//case DIAG_TYPE_DEV:
- case DIAG_TYPE_KEN:
- {
- if ( 0 == (tmp_len = (~DIAG_TYPE_MASK) & tmp_len) )
- {
- ret_value = DP_DIAG_BUFFER_ERROR;
- }//if ( 0 == (tmp_len = (~DIAG_TYPE_MASK) & tmp_len) )
- break;
- }//case DIAG_TYPE_KEN:
- case DIAG_TYPE_CHN:
- {
- tmp_len = DIAG_TYPE_CHN_SIZE;
- break;
- }//case DIAG_TYPE_CHN:
- case DIAG_TYPE_REV:
- {
- tmp_len = DIAG_TYPE_REV_SIZE;
- if( dp_state != DATA_EX )
- {
- // only allowed in state DATA_EX
- ret_value = DP_DIAG_SEQUENCE_ERROR;
- }//if( dp_state != DATA_EX )
- break;
- }//case DIAG_TYPE_REV:
- default:
- {
- //not possible!
- ret_value = DP_DIAG_NOT_POSSIBLE_ERROR;
- break;
- }//default:
- }//switch(DIAG_TYPE_MASK & tmp_user_diag.struc_ptr->dev.sign_len )
- tmp_user_diag_len -= tmp_len;
- tmp_user_diag.byte_ptr += tmp_len;
- }//while( (0 < tmp_user_diag_len) && (DP_OK == ret_value) )
- if( ret_value == DP_OK )
- {
- //copy to diagnosis buffer
- //memcpy( dp_sys[dev_num].diag_buf_ptr.byte_ptr+DIAG_NORM_DIAG_SIZE, user_diag.byte_ptr, user_diag_len );
- pBlackfinAddr = (uint16*)dp_sys[dev_num].diag_buf_ptr.byte_ptr;
- pBlackfinAddr = pBlackfinAddr + DIAG_NORM_DIAG_SIZE;
- for (nBlackfinLoop=0; nBlackfinLoop<user_diag_len; nBlackfinLoop++)
- {
- pBlackfinAddr[nBlackfinLoop] = user_diag.byte_ptr[nBlackfinLoop];
- }
- dp_sys[dev_num].diag_buf_ptr.byte_ptr = vpc3_set_diag_update_all(dev_num, diag_control, (DIAG_NORM_DIAG_SIZE + user_diag_len) );
- }//if( ret_value == DP_OK )
- }//if( ret_value == DP_OK )
- }//if( dp_sys[dev_num].diag_buf_ptr.byte_ptr != NULL_PTR )
- else
- {
- // TRACE("set_diagnosis no diagnosis buffer...");
- //Fetch new diagnosis buffer
- dp_sys[dev_num].diag_buf_ptr.byte_ptr = vpc3_get_diagbufptr(dev_num);
- //wait for next free diag_buffer
- ret_value = DP_DIAG_NO_BUFFER_ERROR;
- }//else of if( dp_sys[dev_num].diag_buf_ptr.byte_ptr != NULL_PTR )
- return ret_value;
- }//DP_ERROR_CODE set_diagnosis(UBYTE dev_num, VPC3_UNION_DIAG_PTR user_diag, UBYTE user_diag_len, UBYTE diag_control, UBYTE check_diag_flag )
- /*-------------------------------------------------------------------*/
- /* function: vpc3_get_free_memory */
- /*-------------------------------------------------------------------*/
- SECTION_DEF_CommuCode VPC3_UNSIGNED8_PTR vpc3_get_free_memory(UBYTE dev_num, UWORD PTR_ATTR *mem_len )
- {
- //return the address and the number of bytes of unused SPC3-ram
- if( dp_sys[dev_num].vpc3_used_dp_buf_mem < ASIC_USER_RAM )
- {
- *mem_len = ASIC_USER_RAM - dp_sys[dev_num].vpc3_used_dp_buf_mem;
- return (VPC3_UNSIGNED8_PTR)((VPC3_ADR)(dp_sys[dev_num].vpc3_used_dp_buf_mem + SAP_LENGTH + DP_ORG_LENGTH)*BLACKFIN_MULTIPLER+(VPC3_ADR)VPC3_ASIC_ADDRESS(dev_num));;
- }
- else
- {
- *mem_len = 0;
- return NULL_PTR;
- }
- }//VPC3_UNSIGNED8_PTR vpc3_get_free_memory(UBYTE dev_num, UWORD PTR_ATTR *mem_len )
- /*-------------------------------------------------------------------*/
- /* function: set_alarm */
- /*-------------------------------------------------------------------*/
- SECTION_DEF_CommuCode UBYTE set_alarm(UBYTE dev_num, ALARM_STATUS_PDU_PTR user_alarm_ptr, UBYTE callback )
- {
- #ifdef DP_ALARM
- return set_alarm__(dev_num, user_alarm_ptr, callback );
- #else
- user_alarm_ptr = user_alarm_ptr; //avoid warning
- callback = callback; //avoid warning
- return SET_ALARM_AL_STATE_CLOSED;
- #endif
- }//UBYTE set_alarm(UBYTE dev_num, ALARM_STATUS_PDU_PTR user_alarm_ptr, UBYTE callback )
- /*-------------------------------------------------------------------*/
- /* function: dpv1 statemachines */
- /*-------------------------------------------------------------------*/
- SECTION_DEF_CommuCode void vpc3_dpv1_statemachine(UBYTE dev_num)
- {
- #ifdef DP_MSAC_C1
- msac_c1_process(dev_num); // state machine MSAC_C1
- #endif
- #ifdef DP_ALARM
- alarm_process(dev_num); // state machine ALARM
- #endif
- #ifdef DP_MSAC_C2
- msac_c2_process(dev_num); // state machine MSAC_C2
- #endif
- #ifdef DP_FDL
- fdl_cyclic_service(dev_num); // state machine FDL
- #endif
- }//void vpc3_dpv1_statemachine(UBYTE dev_num)
- /*****************************************************************************/
- /* Copyright (C) profichip GmbH 2004. Confidential. */
- /*****************************************************************************/