⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qmc__ext.c

📁 基于vxworks操作系统的电话语音平台系统
💻 C
字号:
/************************************************************************/
/*                                                              		*/
/*                                                              		*/
/* (C) Copyright Bangyan Information Technology Ltd, 2000/9.            */
/*  All right reserved                                          		*/
/*                                                              		*/
/* Author: Zhuguosheng 	                                  				*/
/*                                                              		*/
/* Description:                                                 		*/
/*     Driver Set - QMC hdlc specific routines.            				*/
/*                                                              		*/
/* Routines                                                     		*/
/*                                                              		*/
/************************************************************************/

#include "PUB\PUB_INCL.H"
#include "PUB\CONFIG.H"
#include "DRVS\DRV860\PUB\NETCOMM.H"
#include "DRVS\DRV860\PUB\D860_PUB.H"
#include "DRVS\DRV860\PUB\MPC860.H"
#include "DRVS\DRV860\PUB\MASKS860.h"
#include "DRVS\DRV860\QMC\QMC.H"


EXTERN UC TheBrdNum;
EXTERN UC HasConfigComplete;

EXTERN UC LedSwitchOnOrOff( UC action, UC led );
EXTERN BOOL SendLetterToMail(UC sender,UC receiver,UC msg_type,UI port_num,UI len,VOID *data);
EXTERN UC QmcIsReinitiating;



/*Extern function from file COMM\COM_PROC.C*/
EXTERN VOID CommHdlcRecvMsuHdl(UI hdlc,UI len,VOID*data);




EXTERN VOID InitQmcScc(VOID);
EXTERN SI hdlc_qmc_tx(SI channel_num, VOID *buf, SI length, SI int_ena);
EXTERN VOID qmc_mgr_interrupt(SI scc_num);
EXTERN QMC_TABLE        qmc_table;


BOOL DrvQmcInitiate( VOID );
BOOL DrvQmcSendMsu( SI channel_num, VOID *buf, SI length );
VOID DrvRecvMsu( SI channel_num, VOID *buf, SI length );


BOOL DrvQmcInitiate( VOID )
{
	UC i;

	for( i=0; i<NUM_OF_CHANNELS; i++ )
	{
		qmc_table[i].init_flag = 0;
	}
	scc_init( GLB_SCC_2, 0, 0 );
	scc_init( GLB_SCC_3, 0, 0 );

	InitQmcScc();


#ifdef QMC_HDLC_LOOPBACK
	BYPrintf("QMC_HDLC_LOOPBACK!!!");
	scc_loopback(GLB_SCC_2);
	scc_loopback(GLB_SCC_3);
#endif

	scc_start(GLB_SCC_2);
	scc_start(GLB_SCC_3);

	return TRUE;
}

BOOL DrvQmcSendMsu( SI channel_num, VOID *buf, SI length )
{
	UI i, j;
	UC* SMsg;

	char temp_str[30];
	char msg_str[300] = "QMC Send:";

	if( QmcIsReinitiating==0 )
	{
/*		#ifdef _VXWORKS_RTOS
		semTake(SemQMCHdlcSend_ID,WAIT_FOREVER);
		#endif
*/
		SMsg=(UC*)buf;
		#ifdef DEBUG_PRINT_ENABLE_SEND_PACKET
		if(HasConfigComplete==1 && length>4 && (channel_num!=0))
		{
			j = length;
			if(j > 25)
				j = 25;

			DEBUGPrintf("Send len=%2d To   cnl %d  data= ",length,channel_num);
			for(i=0;i<j;i++)
				DEBUGPrintf(" %2x", SMsg[i]);
			DEBUGPrintf("\n");
		}
		#endif

		#if 0
		if(length<300)
		{
			sprintf(temp_str, " chan%d [len=%d]", channel_num, length);
			strcat(msg_str, temp_str);
			for(i=0; i<20 && i<length; i++)
			{
				sprintf(temp_str, " %02X", SMsg[i]);
				strcat(msg_str, temp_str);
			}
			NOWPrintf(msg_str); /* Modified by weng on 2005-9-5 14:35 */
		}
		#endif

		LedSwitchOnOrOff(1,1);

		hdlc_qmc_tx(channel_num, buf, length, 1);

/*
		#ifdef _VXWORKS_RTOS
		semGive(SemQMCHdlcSend_ID);
		#endif
*/
	}
}


UC StartTest=0;

VOID DrvRecvMsu( SI channel_num, VOID *buf, SI length )
{
	STATIC UL msu_num=0;
	UI i, j;
	UC* RMsg;

	UC test[20];

	char temp_str[30];
	char msg_str[300] = "QMC Recv:";
	UC* pbuf;

	#if 0
	if(length<300)
	{
		pbuf=(UC*)buf;
		sprintf(temp_str, " chan%d [len=%d]", channel_num, length);
		strcat(msg_str, temp_str);
		for(i=0; i<20 && i<length; i++)
		{
			sprintf(temp_str, " %02X", pbuf[i]);
			strcat(msg_str, temp_str);
		}
		NOWPrintf(msg_str); /* Modified by weng on 2005-9-5 14:35 */
	}
	#endif

	#if 0
	pbuf=(UC*)buf;
	if(StartTest==0) 
	{
		if((pbuf[4]==0x01) && (pbuf[9]==0x0F))
		{
			BYPrintf("模拟下载开始");
			StartTest = 1;
		}
	}
	if(StartTest>0)
	{
		if(length>4)
		{
			BYPrintf("模拟下载%d", pbuf[11]);

			test[0] = 0xFC;
			test[1] = 0xFF;
			test[2] = 0x01;
			test[3] = pbuf[2] +2;
			DrvQmcSendMsu(channel_num, test, 4);

			memcpy(test, pbuf, 12);
			test[2] = pbuf[3];
			test[3] = pbuf[2] +2;
			test[7] = 0x0;
			test[8] = 0x04;
			test[10] += 1;
			test[12] = 0x01;
			DrvQmcSendMsu(channel_num, test, 13);
		}

		return;
	}
	#endif

	if( QmcIsReinitiating==0 )
	{
		LedSwitchOnOrOff(1,1);

		CommHdlcRecvMsuHdl(channel_num,length,buf);
		RMsg=(UC*)buf;

		#ifdef DEBUG_PRINT_ENABLE_RECV_PACKET
		if(HasConfigComplete==1 && length>4 && (channel_num!=0))
		{
			j = length;
			if(j > 25)
				j = 25;

			DEBUGPrintf("Recv len=%2d From cnl %d  data= ",length,channel_num);
			for(i=0;i<j;i++)
				DEBUGPrintf(" %2x", RMsg[i]);
			DEBUGPrintf("\n");
		}
		#endif
	}
}

VOID QmcPollingEvtHdl(VOID)
{
	if( QmcIsReinitiating==0 )
	{
		qmc_mgr_interrupt(GLB_SCC_2);
		qmc_mgr_interrupt(GLB_SCC_3);
	}
}

UI GetShortPacketNumber( UI hdlc )
{
	return 0;
}

UI GetCrcErrorNumber( UI hdlc )
{
	return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -