dp_fdl.c
资源名称:Profibus.rar [点击查看]
上传用户:hualang
上传日期:2022-04-11
资源大小:104k
文件大小:51k
源码类别:
能源行业(电力石油煤炭)
开发平台:
C/C++
- /*********************** Filename: dp_fdl[dev_num].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+ (DPV1 services) */
- /* */
- /* ------------------------------------------------------------------------- */
- /* */
- /* 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 "E5_Inc.h"
- #include "..dp_incplatform.h"
- #include "..dp_incdp_inc.h"
- #if defined (DP_FDL) //compile only, if fdl-application is selected
- /*---------------------------------------------------------------------------*/
- /* function prototypes */
- /*---------------------------------------------------------------------------*/
- /*---------------------------------------------------------------------------*/
- /* global fdl definitions */
- /*---------------------------------------------------------------------------*/
- SECTION_DEF_CommuData static FDL_STRUC fdl[MAX_DEV_NUM];
- /*---------------------------------------------------------------------------*/
- /* */
- /* DP_ERROR_CODE fdl_init (UBYTE dev_num) */
- /* */
- /* function: Initializing FDL-Interface. */
- /* */
- /* parameter: none */
- /* return value: DP_OK : Buffer length OK */
- /* ERROR : defined in dp_error.h */
- /* */
- /*---------------------------------------------------------------------------*/
- SECTION_DEF_CommuCode DP_ERROR_CODE fdl_init(UBYTE dev_num)
- {
- DP_ERROR_CODE error; // system error code
- BLACKFIN_WORDPTR vpc3_ptr; // pointer to VPC3, 礐ontroller formatted
- UBYTE vpc3_seg_adr; // segment address in VPC3-ASIC
- UWORD resp_buf_len; // response buffer
- UWORD ind_buf_len; // first indication buffer
- UWORD sec_buf_len; // secind indication buffer
- UWORD fdl_used_mem = 0; // memory used by fdl
- UBYTE i;
- FDL_SAP_HEADER_PTR fdl_h_ptr = &fdl[dev_num].sap_header[0];
- error = DP_OK;
- memset(&fdl[dev_num], 0, sizeof(fdl[dev_num]));
- memset(&fdl[dev_num].search_key[0], 0xFF, sizeof(fdl[dev_num].search_key));
- //on error: empty sap-list - first byte of sap-list becomes end-criterion
- p_Vpc3[dev_num]->sap_ctrl_list[0] = 0xFF;
- fdl[dev_num].rm_state = RM_LOCKED;
- fdl[dev_num].dpv2_open = FALSE;
- fdl[dev_num].reset_ctr = 0;
- //Adresse 17: sap_list_ptr vpc3.sap_list / 8
- p_Vpc3[dev_num]->fdl_sap_list_ptr = VPC3_SAP_CTRL_LIST_START(dev_num);
- //pointer mc formatted
- vpc3_ptr = &p_Vpc3[dev_num]->dpbuffer[dp_sys[dev_num].vpc3_used_dp_buf_mem ];//已经是word变量不需要×2
- //pointer vpc3 formatted
- vpc3_seg_adr = (UBYTE)(((VPC3_ADR)vpc3_ptr-(VPC3_ADR)VPC3_ASIC_ADDRESS(dev_num)) >> BLACKFIN_SEG_MULDIV );
- #ifdef DP_MSAC_C2
- //describe the MSAC_C2-space
- fdl_h_ptr->sap_nr = 49;
- fdl_h_ptr->req_ssap = SAP_ALL;
- fdl_h_ptr->sap_type = FDL_RM_SAP;
- fdl_h_ptr->ind_buf_len = 0; //ind-pointer with no length - only buf-header
- fdl_h_ptr->resp_buf_len = FDL_RM_BUF_LENGTH;
- fdl_h_ptr->serv_sup = SS_SRD_LH;
- fdl_h_ptr->req_sa = VPC3_GET_STATION_ADDRESS(dev_num); //lock saps for all masters by setting own address
- fdl_h_ptr++;
- for(i = 0; i < DP_C2_NUM_SAPS; i++)
- {
- fdl_h_ptr->sap_nr = MSAC_C2_SAP_NR_HIGH - i;
- fdl_h_ptr->req_ssap = SAP_ALL;
- fdl_h_ptr->sap_type = FDL_MSAC_C2_SAP;
- fdl_h_ptr->ind_buf_len = DP_C2_LEN;
- fdl_h_ptr->resp_buf_len = DP_C2_LEN;
- fdl_h_ptr->serv_sup = SS_SRD_LH;
- fdl_h_ptr->req_sa = VPC3_GET_STATION_ADDRESS(dev_num);
- fdl_h_ptr++;
- }//for(i = 0; i < DP_C2_NUM_SAPS; i++)
- #endif//#ifdef DP_MSAC_C2
- #ifdef DP_MSAC_C1
- #if(DP_C1_SAPS & DP_C1_USE_ALARM_SAP)
- fdl_h_ptr->sap_nr = DP_C1_ALARM_SAP_NR;
- fdl_h_ptr->req_ssap = SAP_ALL;
- fdl_h_ptr->sap_type = FDL_MSAC_C1_SAP;
- fdl_h_ptr->ind_buf_len = 4;
- fdl_h_ptr->resp_buf_len = 4;
- fdl_h_ptr->serv_sup = SS_SRD_LH;
- fdl_h_ptr->req_sa = (UBYTE) VPC3_GET_STATION_ADDRESS(dev_num); //lock saps for all masters by setting own address
- fdl_h_ptr++;
- #endif//#if(DP_C1_SAPS & DP_C1_USE_ALARM_SAP)
- #if(DP_C1_SAPS & DP_C1_USE_RD_WR_SAP)
- fdl_h_ptr->sap_nr = DP_C1_RD_WR_SAP_NR;
- fdl_h_ptr->req_ssap = SAP_ALL;
- fdl_h_ptr->sap_type = FDL_MSAC_C1_SAP;
- fdl_h_ptr->ind_buf_len = DP_C1_LEN;
- fdl_h_ptr->resp_buf_len = DP_C1_LEN;
- fdl_h_ptr->serv_sup = SS_SRD_LH;
- fdl_h_ptr->req_sa = (UBYTE) VPC3_GET_STATION_ADDRESS(dev_num); //lock saps for all masters by setting own address
- fdl_h_ptr++;
- #endif//#if(DP_C1_SAPS & DP_C1_USE_RD_WR_SAP)
- #endif//#ifdef DP_MSAC_C1
- fdl_h_ptr = &fdl[dev_num].sap_header[0];
- for(i = 0; i < FDL_SAP_MAX; i++)
- {
- fdl[dev_num].search_key[fdl_h_ptr->sap_nr] = i;
- sec_buf_len = 0;
- fdl_h_ptr->state = DISABLED;
- switch(BFWORD2BYTE(fdl_h_ptr->sap_type))
- {
- case FDL_RM_SAP:
- {
- //the rm-sap has an ind-buffer with length #0
- ind_buf_len = ((UWORD) 0 + sizeof_FDL_BUF_HEAD + SEG_OFFSET) & SEG_ADDWORD;
- //one response-buffer
- resp_buf_len = ((UWORD) FDL_RM_BUF_LENGTH + sizeof_FDL_BUF_HEAD + SEG_OFFSET) & SEG_ADDWORD;
- break;
- }//case FDL_RM_SAP:
- case FDL_MSAC_C1_SAP:
- case FDL_MSAC_C2_SAP:
- {
- //one indication/response-buffer
- if(BFWORD2BYTE(fdl_h_ptr->ind_buf_len) > BFWORD2BYTE(fdl_h_ptr->resp_buf_len))
- {
- ind_buf_len = ((UWORD)BFWORD2BYTE(fdl_h_ptr->ind_buf_len) + sizeof_FDL_BUF_HEAD + SEG_OFFSET) & SEG_ADDWORD;
- }
- else
- {
- ind_buf_len = ((UWORD)BFWORD2BYTE(fdl_h_ptr->resp_buf_len) + sizeof_FDL_BUF_HEAD + SEG_OFFSET) & SEG_ADDWORD;
- }
- resp_buf_len = 0;
- if (BFWORD2BYTE(fdl_h_ptr->sap_type) == FDL_MSAC_C2_SAP )
- {
- sec_buf_len = ((UWORD)FDL_DPV2_SEC_BUF_LENGTH + sizeof_FDL_BUF_HEAD + SEG_OFFSET) & SEG_ADDWORD;
- }
- break;
- }//case FDL_MSAC_C1_SAP:
- default:
- {
- break;
- }//default:
- }//switch(fdl_h_ptr->sap_type)
- fdl_used_mem += ind_buf_len + resp_buf_len + sec_buf_len;
- if( (dp_sys[dev_num].vpc3_used_dp_buf_mem + fdl_used_mem) > ASIC_USER_RAM )
- {
- memset(&fdl[dev_num].search_key[0], 0xFF, sizeof(fdl[dev_num].search_key));
- //on error: empty sap-list - first byte of sap-list becomes end-criterion
- p_Vpc3[dev_num]->sap_ctrl_list[0] = 0xFF;
- return DP_LESS_MEM_FDL_ERROR;
- }//if( (dp_sys[dev_num].vpc3_used_dp_buf_mem + fdl_used_mem) > ASIC_USER_RAM )
- fdl_h_ptr->sap_ptr = (FDL_SAP_CNTRL PTR_ATTR *) &( p_Vpc3[dev_num]->sap_ctrl_list[7*i] );//不需要×2
- fdl_h_ptr->sap.resp_s__sap_nr = BFWORD2BYTE(fdl_h_ptr->sap_nr);
- fdl_h_ptr->sap.req_sa = BFWORD2BYTE(fdl_h_ptr->req_sa);
- // req_ssap any sap but not default-sap or ALL_SSAP
- if( (fdl_h_ptr->req_ssap&0xff) < DEFAULT_SAP )//2009.11.7
- {
- fdl_h_ptr->sap.req_sa |= 0x80;
- }//if( fdl_h_ptr->req_ssap < DEFAULT_SAP )
- fdl_h_ptr->sap.access__req_ssap = fdl_h_ptr->req_ssap;
- fdl_h_ptr->sap.event__serv_sup = fdl_h_ptr->serv_sup;
- fdl_h_ptr->sap.ind_ptr[0] = fdl_h_ptr->sap.ind_ptr[1] = vpc3_seg_adr;
- fdl_h_ptr->sap.resp_ptr = vpc3_seg_adr;
- fdl_h_ptr->vpc3_ind_ptr[0] = fdl_h_ptr->vpc3_ind_ptr[1] = vpc3_seg_adr;
- _INIT_FDL_BUF_HEAD((FDL_BUF_HEAD_PTR) vpc3_ptr, fdl_h_ptr->ind_buf_len);
- fdl_h_ptr->ind_ptr[0] = fdl_h_ptr->ind_ptr[1] = (FDL_BUF_HEAD_PTR) vpc3_ptr;
- fdl_h_ptr->resp_ptr = (FDL_BUF_HEAD_PTR) vpc3_ptr;
- incr_vpc3_up_ptr__(ind_buf_len);
- //dpv2-saps with wait-buffer
- if( sec_buf_len )
- {
- fdl_h_ptr->ind_ptr[1] = (FDL_BUF_HEAD_PTR) vpc3_ptr;
- fdl_h_ptr->vpc3_ind_ptr[1] = vpc3_seg_adr;
- fdl_h_ptr->sap.ind_ptr[1] = vpc3_seg_adr;
- _INIT_FDL_BUF_HEAD((FDL_BUF_HEAD_PTR) vpc3_ptr, FDL_DPV2_SEC_BUF_LENGTH);
- incr_vpc3_up_ptr__(sec_buf_len);
- }//if( sec_buf_len )
- //rm-sap with response-buffer
- if(resp_buf_len)
- {
- fdl_h_ptr->sap.resp_ptr = vpc3_seg_adr;
- fdl_h_ptr->resp_ptr = (FDL_BUF_HEAD_PTR) vpc3_ptr;
- //the rm-sap has one response-buffer that will be initialized now
- ((FDL_BUF_HEAD_PTR) vpc3_ptr)->cntrl = 0;
- ((FDL_BUF_HEAD_PTR) vpc3_ptr)->len = FDL_RM_BUF_LENGTH;
- ((FDL_BUF_HEAD_PTR) vpc3_ptr)->fc = FC_RESP_L;
- ((FDL_BUF_HEAD_PTR) vpc3_ptr)->max_len = FDL_RM_BUF_LENGTH;
- fdl[dev_num].rm_buffer = (rm_answer PTR_ATTR *) &vpc3_ptr[sizeof_FDL_BUF_HEAD]; //WORD型指针,不需要×2
- fdl[dev_num].rm_buffer->opcode = 0x56; //dpv2 opcode for rm
- fdl[dev_num].rm_buffer->poll_to_high = (MSAC_C2_TIMEOUT_1_5MBAUD >> 8) & 0x00ff;
- fdl[dev_num].rm_buffer->poll_to_low = MSAC_C2_TIMEOUT_1_5MBAUD & 0x00ff;
- incr_vpc3_up_ptr__(resp_buf_len);
- }//if(resp_buf_len)
- //sap-parameters are copied in vpc3
- copy_sap_parameter__(fdl_h_ptr->sap_ptr, & fdl_h_ptr->sap);
- fdl_h_ptr++;
- }//for(i = 0; i < FDL_SAP_MAX; i++)
- //initialisation o.k. set sap-list-end-criterion and determine the new vpc3-space left
- p_Vpc3[dev_num]->sap_ctrl_list[7*FDL_SAP_MAX] = 0xFF;//已经是word不需要乘BLACKFIN_MULTIPLER
- dp_sys[dev_num].vpc3_used_dp_buf_mem += fdl_used_mem;
- return error;
- }//DP_ERROR_CODE fdl_init(UBYTE dev_num)
- /*---------------------------------------------------------------------------*/
- /* function: fdl_set_poll_timeout */
- /*---------------------------------------------------------------------------*/
- SECTION_DEF_CommuCode void fdl_set_poll_timeout(UBYTE dev_num, UWORD poll_timeout )
- {
- fdl[dev_num].rm_buffer->poll_to_high = (poll_timeout >> 8) & 0x00ff;
- fdl[dev_num].rm_buffer->poll_to_low = poll_timeout & 0x00ff;
- }//void fdl_set_poll_timeout(UBYTE dev_num, UWORD poll_timeout )
- /*---------------------------------------------------------------------------*/
- /* */
- /* void fdl_mac_indication (UBYTE dev_num) */
- /* */
- /* function: fdl-state-machine - treat an mac-indication - REQ-PDU-IND */
- /* */
- /*---------------------------------------------------------------------------*/
- SECTION_DEF_CommuCode void fdl_mac_indication(UBYTE dev_num)//总FDL结构有n个sap header每个header里包括了sap list指针和内容
- {
- FDL_SAP_HEADER_PTR fdl_h_ptr;
- UBYTE sap_ctr;
- UBYTE help_byte;
- fdl_h_ptr = &fdl[dev_num].sap_header[0];//判断sap缓冲区内哪一个sap被调用
- for(sap_ctr = 0; sap_ctr < FDL_SAP_MAX; sap_ctr++)
- {
- if( ((fdl_h_ptr->ind_ptr[0]->cntrl & PCNTRL_IND) || (fdl_h_ptr->ind_ptr[1]->cntrl & PCNTRL_IND))
- && (BFWORD2BYTE(fdl_h_ptr->state) == ENABLED) )
- {
- //logMsg("fdl_mac_indication-----step1,dev_num=%d,sap_type=%d!n",dev_num,fdl_h_ptr->sap_type,0,0,0,0);
- if( BFWORD2BYTE(fdl_h_ptr->sap_type) == FDL_RM_SAP )//masc2
- {
- #ifdef DP_MSAC_C2
- FDL_SAP_HEADER_PTR fdl_h_ptr_rm;
- // set the dpv2-sap to it's new master
- fdl_h_ptr_rm = fdl_get_sap_header_ptr(dev_num,(UBYTE) fdl[dev_num].rm_buffer->sap_nr);
- // allow access to the sap from the detected master and it's source-sap
- fdl_set_sa_ssap (dev_num,fdl_h_ptr_rm->sap_nr, (UBYTE) (fdl_h_ptr->sap_ptr->req_sa),
- (UBYTE) (fdl_h_ptr->sap_ptr->access__req_ssap & 0x7f) );
- //try to reload the rm-sap
- fdl[dev_num].rm_state = RM_LOADABLE;
- //reset several control-values of sap 49 in vpc3-sap_list
- fdl_h_ptr->sap_ptr->resp_s__sap_nr = 49;
- fdl_h_ptr->sap_ptr->req_sa = SA_ALL;
- fdl_h_ptr->sap_ptr->access__req_ssap = SAP_ALL;
- //preset the rm-sap with it's own ind-pointer (length == 0)
- //fdl_h_ptr->sap_ptr->ind_ptr[1] = fdl_h_ptr->sap_ptr->ind_ptr[0] = fdl_h_ptr->sap.ind_ptr[0];
- //preset the rm-sap to cause RS mm, 24-Feb-1998
- fdl_h_ptr->sap_ptr->ind_ptr[0] = 0;
- //dpv2-saps start from index #1 (index #0 is always the rm-sap)
- fdl_h_ptr_rm = & fdl[dev_num].sap_header[1];
- help_byte = DP_C2_NUM_SAPS;
- while(help_byte--)
- {
- //if ( fdl_h_ptr_rm->state == DISABLED_FOR_RM )
- if( (BFWORD2BYTE(fdl_h_ptr_rm->state) == DISABLED_FOR_RM ) || ( BFWORD2BYTE(fdl_h_ptr_rm->state) == DISABLED ))
- {
- fdl[dev_num].rm_state = RM_LOADED;
- fdl_h_ptr_rm->state = DISABLED_IN_RM;
- //force rs of rm-sap by storing #0 in vpc3-sap-list
- fdl_h_ptr->sap_ptr->ind_ptr[0] = 0;
- //store the uP-addresses of the ind-buffers of the desired dpv2-sap
- fdl_h_ptr->ind_ptr[0] = fdl_h_ptr->ind_ptr[1] = fdl_h_ptr_rm->ind_ptr[0];
- //reset the control-byte of the ind-buffer of the desired dpv2-sap
- fdl_h_ptr_rm->ind_ptr[0]->cntrl = 0;
- fdl_h_ptr_rm->ind_ptr[1]->cntrl = 0;
- fdl_h_ptr_rm->resp_ptr->cntrl = 0;
- //take the vpc3-address of the ind-buffer of the desired dpv2-sap
- help_byte = fdl_h_ptr_rm->vpc3_ind_ptr[0];
- //store the new sap-number in the immediate-response-buffer
- fdl[dev_num].rm_buffer->sap_nr = fdl_h_ptr_rm->sap_nr;
- msac_c2_open_channel_sap(dev_num,fdl[dev_num].rm_buffer->sap_nr);
- //preset the control-byte of the immediate-response-buffer for sending
- fdl_h_ptr->resp_ptr->cntrl = PCNTRL_RESP + PCNTRL_USER;
- //store the vpc3-address the ind-buffer of the desired dpv2-sap in vpc3-sap-list (ind_ptr 1)
- fdl_h_ptr->sap_ptr->ind_ptr[1] = help_byte;
- //do the same in vpc3-sap-list with ind_ptr 0 that means: sap 49 is enabled now
- fdl_h_ptr->sap_ptr->ind_ptr[0] = help_byte;
- break;
- }//if( (fdl_h_ptr_rm->state == DISABLED_FOR_RM ) || (fdl_h_ptr_rm->state == DISABLED ))
- else
- {
- fdl_h_ptr_rm++;
- }//else of if( ( fdl_h_ptr_rm->state == DISABLED_FOR_RM ) || ( fdl_h_ptr_rm->state == DISABLED ))
- }//while(help_byte--)
- #endif//#ifdef DP_MSAC_C2
- }//if( fdl_h_ptr->sap_type == FDL_RM_SAP )
- else
- {
- //logMsg("fdl_mac_indication-----step2!n",dev_num,0,0,0,0,0);
- help_byte = ( fdl_h_ptr->ind_ptr[0]->cntrl & PCNTRL_IND ) ? 0 : 1;
- if( BFWORD2BYTE(fdl_h_ptr-> state) == ENABLED )
- {
- //indication-buffer for user
- fdl_h_ptr->ind_ptr[help_byte]->cntrl &= ~PCNTRL_IND;
- //fdl_h_ptr->ind_ptr[help_byte]->cntrl |= PCNTRL_USER;
- switch(BFWORD2BYTE(fdl_h_ptr->sap_type))
- {
- #ifdef DP_MSAC_C1
- case FDL_MSAC_C1_SAP:
- {
- //logMsg("fdl_mac_indication-----step3!n",dev_num,0,0,0,0,0);
- msac_c1_pdu_received(dev_num, fdl_h_ptr->sap_nr,
- (IND_RESP_BUF_PTR) &(fdl_h_ptr->ind_ptr[help_byte]->len) ,
- (fdl_h_ptr->sap_ptr->req_sa & 0x7F) );//req_sa请求的原地址
- break;
- }//case FDL_MSAC_C1_SAP:
- #endif//#ifdef DP_MSAC_C1
- #ifdef DP_MSAC_C2
- case FDL_MSAC_C2_SAP:
- {
- msac_c2_input_queue(dev_num, (MSAC_C2_DATA_BUF_PTR) &(fdl_h_ptr->ind_ptr[help_byte]->len) , FDL_OK,fdl_h_ptr->sap_nr, MSAC_C2_IND_RECV);
- break;
- }//case FDL_MSAC_C2_SAP:
- #endif//#ifdef DP_MSAC_C2
- default:
- {
- break;
- }//default:
- }//switch(fdl_h_ptr->sap_type)
- }//if( fdl_h_ptr-> state == ENABLED )
- }//else of if( fdl_h_ptr->sap_type == FDL_RM_SAP )
- }//if( ((fdl_h_ptr->ind_ptr[0]->cntrl & PCNTRL_IND) || ....
- fdl_h_ptr++;
- }//for(sap_ctr = 0; sap_ctr < FDL_SAP_MAX; sap_ctr++)
- }//void fdl_mac_indication(UBYTE dev_num)
- /*---------------------------------------------------------------------------*/
- /* */
- /* void fdl_flc_indication (UBYTE dev_num) */
- /* */
- /* function: fdl-state-machine - treat a flc-indication - POLL-END-IND */
- /* */
- /*---------------------------------------------------------------------------*/
- SECTION_DEF_CommuCode void fdl_flc_indication(UBYTE dev_num)
- {
- FDL_SAP_HEADER_PTR fdl_h_ptr = &fdl[dev_num].sap_header[0];
- UBYTE sap_ctr;
- for(sap_ctr = 0; sap_ctr < FDL_SAP_MAX; sap_ctr++)
- {
- if( fdl_h_ptr->sap_ptr->resp_s__sap_nr & 0x80 )
- {
- //fdl_h_ptr->sap_ptr->resp_s__sap_nr &= 0x7f;
- if( BFWORD2BYTE(fdl_h_ptr-> state) == ENABLED )
- {
- switch(BFWORD2BYTE(fdl_h_ptr->sap_type))
- {
- #ifdef DP_MSAC_C2
- case FDL_RM_SAP:
- {
- // do nothing here
- break;
- }
- case FDL_MSAC_C2_SAP:
- {
- msac_c2_input_queue(dev_num,NULL_PTR, FDL_OK, fdl_h_ptr->sap_nr, MSAC_C2_RESP_SENT);
- break;
- }
- #endif//#ifdef DP_MSAC_C2
- default:
- {
- break;
- }//default:
- }//switch(fdl_h_ptr->sap_type)
- }//if( fdl_h_ptr-> state == ENABLED )
- }//if( fdl_h_ptr->sap_ptr->resp_s__sap_nr & 0x80 )
- fdl_h_ptr++;
- }//for(sap_ctr = 0; sap_ctr < FDL_SAP_MAX; sap_ctr++)
- }//void fdl_flc_indication(UBYTE dev_num)
- /*---------------------------------------------------------------------------*/
- /* */
- /* void fdl_cyclic_service (UBYTE dev_num) */
- /* */
- /* function: fdl-state-machine - treat a sap to be reset but actually in use */
- /* */
- /*---------------------------------------------------------------------------*/
- SECTION_DEF_CommuCode void fdl_cyclic_service (UBYTE dev_num)
- {
- #ifdef NOTUSED
- FDL_SAP_HEADER_PTR fdl_h_ptr;
- UBYTE ctr;
- if( fdl[dev_num].reset_ctr )
- {
- fdl_h_ptr = & fdl[dev_num].sap_header[0];
- ctr = FDL_SAP_MAX;
- while(ctr--)
- {
- if( BFWORD2BYTE(fdl_h_ptr->state) == DIS_RUNNING )
- {
- if( !(fdl_h_ptr->ind_ptr[0]->cntrl & PCNTRL_INUSE)
- && !(fdl_h_ptr->ind_ptr[1]->cntrl & PCNTRL_INUSE)
- && !(fdl_h_ptr->resp_ptr->cntrl & PCNTRL_INUSE)
- )
- {
- fdl_h_ptr->state = DISABLED;
- fdl[dev_num].reset_ctr--;
- //perform sap-reset
- //set indication-buffer to vpc3
- copy_sap_parameter__(fdl_h_ptr->sap_ptr, &fdl_h_ptr->sap);
- fdl_h_ptr->ind_ptr[0]->cntrl = 0;
- //fdl_h_ptr->ind_ptr[1]->cntrl = 0;
- fdl_h_ptr->resp_ptr->cntrl = 0;
- switch( fdl_h_ptr->sap_type )
- {
- #ifdef DP_MSAC_C2
- case FDL_MSAC_C2_SAP:
- {
- msac_c2_input_queue(dev_num,NULL_PTR, FDL_OK, fdl_h_ptr->sap_nr, MSAC_C2_IND_DISABLE_DONE );
- break;
- }
- #endif//#ifdef DP_MSAC_C2
- #ifdef DP_MSAC_C1
- case FDL_MSAC_C1_SAP:
- {
- msac_c1_ind_disable_done(dev_num,fdl_h_ptr->sap_nr, FDL_OK );
- break;
- }
- #endif//#ifdef DP_MSAC_C1
- }
- }
- }
- fdl_h_ptr++;
- }
- }
- #endif
- }
- /*---------------------------------------------------------------------------*/
- /* */
- /* void fdl_set_sa_ssap(UBYTE dev_num,UBYTE sap_nr, UBYTE req_sa, UBYTE req_ssap) */
- /* */
- /* function: This function sets temporary sa and ssap of the desired sap. */
- /* */
- /*---------------------------------------------------------------------------*/
- SECTION_DEF_CommuCode void fdl_set_sa_ssap(UBYTE dev_num, UBYTE sap_nr, UBYTE req_sa, UBYTE req_ssap )
- {
- FDL_SAP_HEADER_PTR fdl_h_ptr = fdl_get_sap_header_ptr(dev_num,sap_nr);
- UBYTE req_sa_loc = req_sa & 0x7f;
- //perform service only, if req_ssap is in a valid range
- if( ( (req_ssap&0xff) <= DEFAULT_SAP) || ( (req_ssap&0xff) == SAP_ALL) )////2009.11.7
- {
- if( (sap_nr&0xff) != DEFAULT_SAP)//2009.11.7
- {
- if ( (req_sa&0xff) != SA_ALL )//2009.11.7
- {
- req_sa_loc |= 0x80;
- }//if ( req_sa != SA_ALL )
- }//if(sap_nr != DEFAULT_SAP)
- fdl_h_ptr->state = ENABLED;
- //set sap-parameters
- fdl_h_ptr->sap_ptr->access__req_ssap = req_ssap;
- fdl_h_ptr->sap_ptr->req_sa = req_sa_loc;
- }//if( (req_ssap <= DEFAULT_SAP) || (req_ssap == SAP_ALL) )
- }//void fdl_set_sa_ssap(UBYTE dev_num, UBYTE sap_nr, UBYTE req_sa, UBYTE req_ssap )
- /*---------------------------------------------------------------------------*/
- /* */
- /* FDL_SAP_HEADER_PTR fdl_get_sap_header_ptr(UBYTE dev_num, UBYTE sap ) */
- /* */
- /* function: return 0 or the pointer to the desired fdl-sap-structure */
- /* */
- /*---------------------------------------------------------------------------*/
- SECTION_DEF_CommuCode FDL_SAP_HEADER_PTR fdl_get_sap_header_ptr(UBYTE dev_num, UBYTE sap )
- {
- UBYTE index;
- if( ( (sap&0xff) >= sizeof(fdl[dev_num].search_key) ) || ((index = fdl[dev_num].search_key[sap&0xff]) == 0xFF ) )//2009.11.7
- {
- // error function
- }//if( (sap >= sizeof(fdl[dev_num].search_key) ) || ((index = fdl[dev_num].search_key[sap]) == 0xFF ) )
- return (&fdl[dev_num].sap_header[index]);
- }//FDL_SAP_HEADER_PTR fdl_get_sap_header_ptr(UBYTE dev_num, UBYTE sap )
- /*---------------------------------------------------------------------------*/
- /* */
- /* void fdl_ind_provide (UBYTE dev_num,UBYTE sap_nr, IND_RESP_BUF_PTR ind_ptr) */
- /* */
- /* function: The function prepares the indication-provide of a desired SAP */
- /* */
- /*---------------------------------------------------------------------------*/
- SECTION_DEF_CommuCode void fdl_ind_provide(UBYTE dev_num, UBYTE sap_nr, IND_RESP_BUF_PTR ind_ptr )
- {
- FDL_SAP_HEADER_PTR fdl_h_ptr = fdl_get_sap_header_ptr(dev_num,sap_nr);
- UBYTE ret_value = FDL_OK;
- UBYTE i;
- DP_LOCK_IND(dev_num);
- i = (fdl_h_ptr->sap_type == FDL_MSAC_C2_SAP) ? 0 : 1;
- for(; i < 2; i++)
- {
- //search for pointer
- if( ind_ptr == (IND_RESP_BUF_PTR) &(fdl_h_ptr->ind_ptr[i]->len) )
- {
- //pointer belongs to sap
- if( fdl_h_ptr->ind_ptr[i]->cntrl & PCNTRL_USER )
- {
- //indication-buffer belongs to user, return to vpc3
- fdl_h_ptr->ind_ptr[i]->cntrl = 0;
- ret_value = FDL_OK;
- break;
- }//if( fdl_h_ptr->ind_ptr[i]->cntrl & PCNTRL_USER )
- else
- {
- //buffer not occupied by user
- ret_value = FDL_NUIB;
- break;
- }//else of if( fdl_h_ptr->ind_ptr[i]->cntrl & PCNTRL_USER )
- }//if( ind_ptr == (IND_RESP_BUF_PTR) &(fdl_h_ptr->ind_ptr[i]->len) )
- else
- {
- //no buffer was found */
- ret_value = FDL_FPTR;
- }//else of if( ind_ptr == (IND_RESP_BUF_PTR) &(fdl_h_ptr->ind_ptr[i]->len) )
- }//for(; i < 2; i++)
- DP_UNLOCK_IND(dev_num);
- }//void fdl_ind_provide(UBYTE dev_num, UBYTE sap_nr, IND_RESP_BUF_PTR ind_ptr )
- /*---------------------------------------------------------------------------*/
- /* */
- /* void fdl_resp_provide (UBYTE dev_num,UBYTE sap_nr, UBYTE prim_sec) */
- /* */
- /* function: The function prepares the response-provide of a desired SAP */
- /* */
- /*---------------------------------------------------------------------------*/
- SECTION_DEF_CommuCode void fdl_resp_provide(UBYTE dev_num, UBYTE sap_nr, UBYTE prim_sec )
- {
- int i,j;
- FDL_SAP_HEADER_PTR fdl_h_ptr = fdl_get_sap_header_ptr(dev_num,sap_nr);
- IND_RESP_BUF_PTR usr_ptr;
- FDL_BUF_HEAD_PTR resp_ptr;
- UBYTE ret_value = FDL_OK;
- UBYTE help_byte;
- DP_LOCK_IND(dev_num);
- if( (BFWORD2BYTE(fdl_h_ptr->sap_type) != FDL_MSAC_C2_SAP) && (prim_sec == FDL_SECONDARY_BUF) )
- {
- //no buffer available
- ret_value = FDL_NURB;
- }//if( (fdl_h_ptr->sap_type != FDL_MSAC_C2_SAP) && (prim_sec == FDL_SECONDARY_BUF) )
- if( ret_value == FDL_OK )
- {
- switch( prim_sec )
- {
- case FDL_PRIMARY_BUF:
- {
- resp_ptr = fdl_h_ptr->resp_ptr;
- help_byte = fdl_h_ptr->resp_buf_len;
- break;
- }//case FDL_PRIMARY_BUF:
- case FDL_SECONDARY_BUF:
- {
- resp_ptr = fdl_h_ptr->ind_ptr[1];
- help_byte = FDL_DPV2_SEC_BUF_LENGTH;
- break;
- }//case FDL_SECONDARY_BUF:
- default:
- {
- resp_ptr = (FDL_BUF_HEAD_PTR)0;// NIL;
- help_byte = 0;
- break;
- }//default:
- }//switch( prim_sec )
- if( !(resp_ptr) || (resp_ptr->cntrl & PCNTRL_RESP) )
- {
- //no buffer available
- ret_value = FDL_NURB;
- }//if( !(resp_ptr) || (resp_ptr->cntrl & PCNTRL_RESP) )
- else
- {
- usr_ptr = (IND_RESP_BUF_PTR) &resp_ptr->len;
- if( BFWORD2BYTE(usr_ptr->data_len) <= help_byte )
- {
- //length fits into buffer
- help_byte = BFWORD2BYTE(usr_ptr->fc);
- if( (help_byte == FC_RESP_L) || (help_byte == FC_RESP_H) )
- {
- if( (BFWORD2BYTE(fdl_h_ptr->sap_type) == FDL_MSAC_C1_SAP) || ( BFWORD2BYTE(fdl_h_ptr->sap_type) == FDL_MSAC_C2_SAP))
- {
- help_byte = (prim_sec == FDL_PRIMARY_BUF) ? fdl_h_ptr->vpc3_ind_ptr[0] : fdl_h_ptr->vpc3_ind_ptr[1];
- fdl_h_ptr->sap_ptr->ind_ptr[0] = (UBYTE) help_byte;
- //changed V301, profichip 19.09.2002
- //the VPC3+ can receive the ABORT message over indication buffer 2
- //fdl_h_ptr->sap_ptr->ind_ptr[1] = (UBYTE) help_byte;
- fdl_h_ptr->sap_ptr->resp_ptr = (UBYTE) help_byte;
- }
- resp_ptr->cntrl &= ~PCNTRL_RESP;
- //taskDelay( 1 );
- for(i=0 ;i<300 ;i++)//硬延时一段时间 100000
- {
- j=0;
- }
- resp_ptr->cntrl |= PCNTRL_RESP;
- }//if( (help_byte == FC_RESP_L) || (help_byte == FC_RESP_H) )
- else
- {
- ret_value = FDL_IVP;
- }//else of if( (help_byte == FC_RESP_L) || (help_byte == FC_RESP_H) )
- }//if( usr_ptr->data_len <= help_byte )
- else
- {
- //length exceeds buffer
- ret_value = FDL_RLEN;
- }//else of if( usr_ptr->data_len <= help_byte )
- }//else of if( !(resp_ptr) || (resp_ptr->cntrl & PCNTRL_RESP) )
- }//if( ret_value == FDL_OK )
- DP_UNLOCK_IND(dev_num);
- if( ret_value != FDL_OK )
- {
- switch( BFWORD2BYTE(fdl_h_ptr->sap_type) )
- {
- #ifdef DP_MSAC_C2
- case FDL_MSAC_C2_SAP:
- {
- msac_c2_input_queue(dev_num,NULL_PTR, ret_value, fdl_h_ptr->sap_nr, MSAC_C2_RESP_SENT);
- break;
- }//case FDL_MSAC_C2_SAP:
- #endif//#ifdef DP_MSAC_C2
- default:
- {
- break;
- }//default:
- }//switch( fdl_h_ptr->sap_type )
- }//if( ret_value != FDL_OK )
- }//void fdl_resp_provide(UBYTE dev_num, UBYTE sap_nr, UBYTE prim_sec )
- /*---------------------------------------------------------------------------*/
- /* */
- /* void fdl_reset_pcntrl_resp_bit (UBYTE dev_num,UBYTE sap_nr, UBYTE prim_sec) */
- /* */
- /* function: The function reset the PCNTRL_RESP bit in the buffer */
- /* */
- /*---------------------------------------------------------------------------*/
- SECTION_DEF_CommuCode void fdl_reset_pcntrl_resp_bit(UBYTE dev_num, UBYTE sap_nr, UBYTE prim_sec )
- {
- FDL_SAP_HEADER_PTR fdl_h_ptr = fdl_get_sap_header_ptr(dev_num,sap_nr);
- FDL_BUF_HEAD_PTR resp_ptr;
- UBYTE ret_value = FDL_OK;
- DP_LOCK_IND(dev_num);
- if( (BFWORD2BYTE(fdl_h_ptr->sap_type) != FDL_MSAC_C2_SAP) && (prim_sec == FDL_SECONDARY_BUF) )
- {
- //no buffer available
- ret_value = FDL_NURB;
- }//if( (fdl_h_ptr->sap_type != FDL_MSAC_C2_SAP) && (prim_sec == FDL_SECONDARY_BUF) )
- if( ret_value == FDL_OK )
- {
- switch( prim_sec )
- {
- case FDL_PRIMARY_BUF:
- {
- resp_ptr = fdl_h_ptr->resp_ptr;
- break;
- }//case FDL_PRIMARY_BUF:
- case FDL_SECONDARY_BUF:
- {
- resp_ptr = fdl_h_ptr->ind_ptr[1];
- break;
- }//case FDL_SECONDARY_BUF:
- default:
- {
- resp_ptr = (FDL_BUF_HEAD_PTR)0;// NIL;
- break;
- }//default:
- }//switch( prim_sec )
- if( resp_ptr )
- {
- resp_ptr->cntrl &= ~PCNTRL_RESP;
- }//if( resp_ptr )
- }//if( ret_value == FDL_OK )
- DP_UNLOCK_IND(dev_num);
- }//void fdl_reset_pcntrl_resp_bit(UBYTE dev_num, UBYTE sap_nr, UBYTE prim_sec )
- /*---------------------------------------------------------------------------*/
- /* */
- /* void fdl_ind_disable(UBYTE dev_num,UBYTE sap_nr) */
- /* */
- /* function: The function resets the sap to its initial value */
- /* */
- /*---------------------------------------------------------------------------*/
- SECTION_DEF_CommuCode void fdl_ind_disable(UBYTE dev_num, UBYTE sap_nr )
- {
- FDL_SAP_HEADER_PTR fdl_h_ptr = fdl_get_sap_header_ptr(dev_num,sap_nr);
- DP_LOCK_IND(dev_num);
- //DP_UNLOCK_IND(dev_num) done in following function
- fdl_perform_ind_disable(dev_num,fdl_h_ptr);
- }//void fdl_ind_disable(UBYTE dev_num, UBYTE sap_nr )
- /*---------------------------------------------------------------------------*/
- /* */
- /* void fdl_ind_disable(UBYTE dev_num,UBYTE sap_nr) */
- /* */
- /* function: The function resets the sap to its initial value */
- /* */
- /*---------------------------------------------------------------------------*/
- SECTION_DEF_CommuCode void fdl_ind_disable_SAP50(UBYTE dev_num)
- {
- FDL_SAP_HEADER_PTR fdl_h_ptr = fdl_get_sap_header_ptr(dev_num,DP_C1_ALARM_SAP_NR);
- DP_LOCK_IND(dev_num);
- //DP_UNLOCK_IND(dev_num) done in following function
- fdl_perform_ind_disable_SAP50(dev_num,fdl_h_ptr);
- }//void fdl_ind_disable_SAP50(UBYTE dev_num)
- /*---------------------------------------------------------------------------*/
- /* */
- /* UBYTE fdl_ind_await(UBYTE dev_num,UBYTE sap_nr) */
- /* */
- /* function: The function the rm for a connection at the desired sap s */
- /* */
- /*---------------------------------------------------------------------------*/
- SECTION_DEF_CommuCode UBYTE fdl_ind_await(UBYTE dev_num, UBYTE sap_nr )
- {
- FDL_SAP_HEADER_PTR fdl_h_ptr = fdl_get_sap_header_ptr(dev_num,sap_nr);
- UBYTE ret_value = FDL_OK;
- #ifdef DP_MSAC_C2
- UBYTE help_byte;
- #endif//#ifdef DP_MSAC_C2
- DP_LOCK_IND(dev_num);
- switch( BFWORD2BYTE(fdl_h_ptr->sap_type) )
- {
- #ifdef DP_MSAC_C1
- case FDL_MSAC_C1_SAP:
- {
- fdl_set_sa_ssap(dev_num,sap_nr, SA_ALL, SAP_ALL);
- break;
- }//case FDL_MSAC_C1_SAP:
- #endif//#ifdef DP_MSAC_C1
- #ifdef DP_MSAC_C2
- case FDL_MSAC_C2_SAP:
- {
- if( fdl[dev_num].dpv2_open != FALSE )
- {
- if( fdl_h_ptr->state == DISABLED )
- {
- fdl_h_ptr->state = DISABLED_FOR_RM;
- if( fdl[dev_num].rm_state == RM_LOADABLE )
- {
- fdl[dev_num].rm_state = RM_LOADED;
- fdl_h_ptr->state = DISABLED_IN_RM;
- //force rs of rm-sap by storing #0 in vpc3-sap-list
- fdl[dev_num].sap_header[0].sap_ptr->ind_ptr[0] = 0;
- //store the uP-addresses of the ind-buffers of the desired dpv2-sap
- fdl[dev_num].sap_header[0].ind_ptr[0] = fdl[dev_num].sap_header[0].ind_ptr[1] = fdl_h_ptr->ind_ptr[0];
- //reset several control-values of sap 49 in vpc3-sap_list/
- fdl[dev_num].sap_header[0].sap_ptr->resp_s__sap_nr = 49;
- fdl[dev_num].sap_header[0].sap_ptr->req_sa = SA_ALL;
- fdl[dev_num].sap_header[0].sap_ptr->access__req_ssap = SAP_ALL;
- //reset the control-byte of the ind-buffer of the desired dpv2-sap
- fdl_h_ptr->ind_ptr[0]->cntrl = 0;
- fdl_h_ptr->ind_ptr[1]->cntrl = 0;
- fdl_h_ptr->resp_ptr->cntrl = 0;
- //take the vpc3-address of the ind-buffer of the desired dpv2-sap
- help_byte = fdl_h_ptr->vpc3_ind_ptr[0];
- //store the new sap-number in the immediate-response-buffer
- fdl[dev_num].rm_buffer->sap_nr = fdl_h_ptr->sap_nr;
- //preset the control-byte of the immediate-response-buffer for sending
- fdl[dev_num].sap_header[0].resp_ptr->cntrl = PCNTRL_RESP + PCNTRL_USER;
- //store the vpc3-address the ind-buffer of the desired dpv2-sap in vpc3-sap-list (ind_ptr 1)
- fdl[dev_num].sap_header[0].sap_ptr->ind_ptr[1] = help_byte;
- //do the same in vpc3-sap-list with ind_ptr 0 that means: sap 49 is enabled now
- fdl[dev_num].sap_header[0].sap_ptr->ind_ptr[0] = help_byte;
- }//if( fdl[dev_num].rm_state == RM_LOADABLE )
- }//if( fdl_h_ptr->state == DISABLED )
- else
- {
- ret_value = FDL_IUSE;
- }//else of if( fdl_h_ptr->state == DISABLED )
- }//if( fdl[dev_num].dpv2_open != FALSE )
- else
- {
- ret_value = FDL_OPEN_ERR;
- }//else of if( fdl[dev_num].dpv2_open != FALSE )
- break;
- }//case FDL_MSAC_C2_SAP:
- #endif//#ifdef DP_MSAC_C2
- default:
- {
- break;
- }
- }//switch( fdl_h_ptr->sap_type )
- DP_UNLOCK_IND(dev_num);
- return(ret_value );
- }//UBYTE fdl_ind_await(UBYTE dev_num, UBYTE sap_nr )
- /*---------------------------------------------------------------------------*/
- /* */
- /* void fdl_perform_ind_disable(UBYTE dev_num,FDL_SAP_HEADER_PTR fdl_h_ptr) */
- /* */
- /* function: The function resets the sap to its initial value, unlocks */
- /* interrupt and if due: performs the user-callback-function */
- /* */
- /*---------------------------------------------------------------------------*/
- SECTION_DEF_CommuCode void fdl_perform_ind_disable(UBYTE dev_num, FDL_SAP_HEADER_PTR fdl_h_ptr )
- {
- UBYTE ret_value;
- ret_value = FDL_OPEN_ERR;
- if( (fdl_h_ptr->state&0xff) == ENABLED )//2009.11.7
- {
- fdl_h_ptr->state = DISABLED;
- fdl_h_ptr->sap_ptr->ind_ptr[0] = 0;
- if( (fdl_h_ptr->ind_ptr[0]->cntrl & PCNTRL_INUSE)
- || (fdl_h_ptr->ind_ptr[1]->cntrl & PCNTRL_INUSE)
- || (fdl_h_ptr->resp_ptr->cntrl & PCNTRL_INUSE)
- )
- {
- fdl_h_ptr->state = DIS_RUNNING;
- fdl[dev_num].reset_ctr++;
- }//if( (fdl_h_ptr->ind_ptr[0]->cntrl & PCNTRL_INUSE) ...
- else
- {
- //perform sap-reset
- //set indication-buffer to vpc3
- copy_sap_parameter__(fdl_h_ptr->sap_ptr, & fdl_h_ptr->sap);
- fdl_h_ptr->ind_ptr[0]->cntrl = 0;
- fdl_h_ptr->ind_ptr[1]->cntrl = 0;
- fdl_h_ptr->resp_ptr->cntrl = 0;
- ret_value = FDL_OK;
- }//else of if( (fdl_h_ptr->ind_ptr[0]->cntrl & PCNTRL_INUSE) ...
- }//if(fdl_h_ptr->state == ENABLED )
- else
- {
- ret_value = FDL_IUSE;
- }//else of if(fdl_h_ptr->state == ENABLED )
- DP_UNLOCK_IND(dev_num);
- if( ret_value != FDL_OPEN_ERR )
- {
- switch( fdl_h_ptr->sap_type&0xff )//2009.11.7
- {
- #ifdef DP_MSAC_C2
- case FDL_MSAC_C2_SAP:
- {
- msac_c2_input_queue(dev_num,NULL_PTR, ret_value, fdl_h_ptr->sap_nr, MSAC_C2_IND_DISABLE_DONE );
- break;
- }//case FDL_MSAC_C2_SAP:
- #endif//#ifdef DP_MSAC_C2
- #ifdef DP_MSAC_C1
- case FDL_MSAC_C1_SAP:
- {
- msac_c1_ind_disable_done(dev_num,fdl_h_ptr->sap_nr, ret_value);
- break;
- }//case FDL_MSAC_C1_SAP:
- #endif//#ifdef DP_MSAC_C1
- default:
- {
- break;
- }//default:
- }//switch( fdl_h_ptr->sap_type )
- }//if( ret_value != FDL_OPEN_ERR )
- }//void fdl_perform_ind_disable(UBYTE dev_num, FDL_SAP_HEADER_PTR fdl_h_ptr )
- /*---------------------------------------------------------------------------*/
- /* */
- /* void fdl_perform_ind_disable_SAP50(UBYTE dev_num,FDL_SAP_HEADER_PTR fdl_h_ptr) */
- /* */
- /* function: The function resets the sap 50 to its initial value, unlocks */
- /* interrupt and if due: performs the user-callback-function */
- /* */
- /*---------------------------------------------------------------------------*/
- SECTION_DEF_CommuCode void fdl_perform_ind_disable_SAP50(UBYTE dev_num, FDL_SAP_HEADER_PTR fdl_h_ptr )
- {
- UBYTE ret_value = FDL_OPEN_ERR; //preset with non-generated return-value
- fdl_h_ptr->state = DISABLED;
- fdl_h_ptr->sap_ptr->ind_ptr[0] = 0;
- if( (fdl_h_ptr->ind_ptr[0]->cntrl & PCNTRL_INUSE)
- || (fdl_h_ptr->ind_ptr[1]->cntrl & PCNTRL_INUSE)
- || (fdl_h_ptr->resp_ptr->cntrl & PCNTRL_INUSE)
- )
- {
- fdl_h_ptr->state = DIS_RUNNING;
- fdl[dev_num].reset_ctr++;
- }//if( (fdl_h_ptr->ind_ptr[0]->cntrl & PCNTRL_INUSE) ...
- else
- {
- //perform sap-reset
- //set indication-buffer to vpc3
- copy_sap_parameter__(fdl_h_ptr->sap_ptr, & fdl_h_ptr->sap);
- fdl_h_ptr->ind_ptr[0]->cntrl = 0;
- fdl_h_ptr->ind_ptr[1]->cntrl = 0;
- fdl_h_ptr->resp_ptr->cntrl = 0;
- ret_value = FDL_OK;
- }//else of if( (fdl_h_ptr->ind_ptr[0]->cntrl & PCNTRL_INUSE) ...
- DP_UNLOCK_IND(dev_num);
- }//void fdl_perform_ind_disable_SAP50(UBYTE dev_num, FDL_SAP_HEADER_PTR fdl_h_ptr )
- /*---------------------------------------------------------------------------*/
- /* */
- /* void fdl_open_channel (UBYTE dev_num) */
- /* */
- /* function: open channel */
- /* */
- /*---------------------------------------------------------------------------*/
- #ifdef DP_MSAC_C2
- SECTION_DEF_CommuCode UBYTE fdl_open_channel(UBYTE dev_num)
- {
- UBYTE ret_value;
- DP_LOCK_IND(dev_num);
- if( fdl[dev_num].dpv2_open == FALSE )
- {
- fdl[dev_num].dpv2_open = TRUE;
- fdl[dev_num].rm_state = RM_LOADABLE;
- fdl_set_sa_ssap (dev_num,49, SA_ALL, SAP_ALL);
- ret_value = FDL_OK;
- }//if( fdl[dev_num].dpv2_open == FALSE )
- else
- {
- ret_value = FDL_OPEN_ERR;
- }//else of if( fdl[dev_num].dpv2_open == FALSE )
- DP_UNLOCK_IND(dev_num);
- return ret_value;
- }//UBYTE fdl_open_channel(UBYTE dev_num)
- #endif //#ifdef DP_MSAC_C2
- /*---------------------------------------------------------------------------*/
- /* */
- /* void fdl_close_channel (UBYTE dev_num,UBYTE chan_ident) */
- /* */
- /* function: close channel */
- /* */
- /*---------------------------------------------------------------------------*/
- #ifdef DP_MSAC_C2
- SECTION_DEF_CommuCode void fdl_close_channel(UBYTE dev_num, UBYTE chan_ident )
- {
- FDL_SAP_HEADER_PTR fdl_h_ptr;
- UBYTE ret_value;
- DP_LOCK_IND(dev_num);
- switch( chan_ident )
- {
- case FDL_MSAC_C2_SAP:
- {
- if( fdl[dev_num].dpv2_open != FALSE )
- {
- // force rs but do not touch the pointers yet
- fdl[dev_num].sap_header[0].sap_ptr->req_sa = (UBYTE) VPC3_GET_STATION_ADDRESS(dev_num);
- fdl[dev_num].dpv2_open = FALSE;
- fdl[dev_num].rm_state = RM_LOCKED;
- // set all msac_c2-saps DISABLED
- fdl_h_ptr = &fdl[dev_num].sap_header[1]; // MSAC_C2-saps start at index #1
- ret_value = DP_C2_NUM_SAPS;
- while( ret_value-- )
- {
- switch( fdl_h_ptr->state )
- {
- case ENABLED:
- case DIS_RUNNING:
- {
- //let old connections run
- break;
- }//case ENABLED:
- case DISABLED:
- {
- break;
- }//case DISABLED:
- case DISABLED_FOR_RM:
- case DISABLED_IN_RM:
- {
- fdl_h_ptr->state = DISABLED;
- break;
- }//case DISABLED_FOR_RM:
- default:
- {
- break;
- }//default:
- }//switch( fdl_h_ptr->state )
- }//while( ret_value-- )
- fdl_perform_ind_disable(dev_num, &fdl[dev_num].sap_header[0] );
- }//if( fdl[dev_num].dpv2_open != FALSE )
- else
- {
- DP_UNLOCK_IND(dev_num);
- }
- break;
- }//case FDL_MSAC_C2_SAP:
- default:
- {
- break;
- }//default
- }//switch( chan_ident )
- }//void fdl_close_channel(UBYTE dev_num, UBYTE chan_ident )
- #endif //#ifdef DP_MSAC_C2
- #endif//#if defined (DP_FDL) // compile only, if fdl-application is selected
- /*****************************************************************************/
- /* Copyright (C) profichip GmbH 2004. Confidential. */
- /*****************************************************************************/