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

📄 r2lchi.c

📁 phs 源代码 小灵通协议源代码 phs source code
💻 C
📖 第 1 页 / 共 2 页
字号:
/************************************************************************/
/** 		Copyright (c) 1998, UTStarcom, Inc. 			*/
/**			 All Rights Reserved. 				*/
/** 									*/
/** Subsystem: 		RT 						*/
/** File: 		rt2lchi.c 					*/
/** Created By: 	tara zhang					*/
/** Created On: 	08/02/2003					*/
/** 									*/
/** Purpose:								*/
/** 	This file handle indiction message when link channel establish .  */
/**									*/
/** Necessary Compilation Flags: FLAG_1, , FLAG_N 			*/
/**********************************************************************	*/
/** Modify by: 								*/
/** Modify purpose:							*/
/************************************************************************/
#ifndef PM_ONPC

#define __RTLCHI_C_

#ifdef __cplusplus
extern "C"{
#endif

#include "rt.h"



/**************************************************************************/

/********************************************************************************************************/
/*                                                                          							*/
/*		NUMBER		13                                                      							*/
/*		CALL		void rt_lch_assign			               											*/
/*		PARAM		rx_cac is link channel assignment message content									*/
/*		DISCRIPTION:	rx_cac[0]: message type															*/
/*				rx_cac[1]:lch type(bit 6-8) +  externsion lch ptotocol type(bit 1-3) 					*/
/*				rx_cac[2]:cc prorocol(bit 7,8) + relative slot number(bit 1-5)							*/
/*				rx_cac[3]:carrier number																*/
/*				rx_cac[4]:absolute slot number(bit 1,2)													*/
/*				Rtlchdat: if carrier number error,Rtlchdat show the link channel establish				*/
/*					  re-request message content.														*/
/*																										*/
/*		RETURN:																							*/
/********************************************************************************************************/
U1 rt_lch_assign(void)
{
	U1	abs_slot,
		slot;
#ifdef SIMU_ON_PC
	U2 buff[2];
#endif

#ifdef  _DEBUG_TC6_
		_SendStringToUart("rt_lchasg\n",sizeof("rt_lchasg\n"));
#endif

#ifdef  EXT_IO
        HisOut(0,0xda,0x05,0,0);
#endif

	rt_tm_stop( TR001ON );

	abs_slot = rx_cac[4] & 0x03; /* absolute alot number */
	if ( rt_carr_chk(rx_cac[3]) != OK ) /* check carrier number */
	{ /* carrier number is error */

		if ( Lchercnt < LCHERMAX )
		{
			switch ( Rtlchdat[0] )
			{
				case LCHRQ	:
					Rtlchdat[3] &= 0x07;  /* area information notification status number */

					if ( Sys_ccsinf[19] <= 0x02 )
					{
						Rtlchdat[3] |= 0x38; /* assigned channel non-corresponding PS(show that it is not the radio station
									that corresponds to the assigned channel)  */
					}
					else
					{
						Rtlchdat[3] |= 0x40; /* assigned carrier non-corresponding PS(show that it is not the radio station
									that corresponds to the assigned carrier) */
					}
					Rtlchdat[0]++;   /* link channel establish re-request message */
					break;
			}
			move_up_b( tx_cac, Rtlchdat, 5 );
#ifdef SIMU_ON_PC
			SendUart2L1(SIMTSKDTW,TXCAC, 0 , tx_cac , 5);
			ph_dt_req( L1_SCCH, DMY, OFF ,0);
#else
			ph_dt_req( L1_SCCH, DMY, OFF );
#endif

			Lchercnt++;
			if((Rt_sts == ST_LCH_REQ) || (Rt_sts == ST_LCH_RREQ))
			{
				Rt_sts = ST_LCH_RREQ;
			}
			else
			{ /* recall handover */
				Rt_sts = ST_RLCH_RREQ;
				rt_tm_start( TRCCHESTON );
			}
		}
		else
		{
			if((Rt_sts == ST_LCH_REQ) || (Rt_sts == ST_LCH_RREQ))
			{/* link channel establish failed */
				SYS_WORK->tsk_id = TASKMNG;
				OUT_LCHEVT->evt_cod = ERT;
				OUT_LCHEVT->pri_cod = PSLCHNG;
				OUT_LCHEVT->msg_dat[4] = 3;
				m_excreq( (WORD*)&SYS_WORK->tsk_id );
				Rt_sts = ST_WAIT;
			}
			else
				rt_recall_lch_send(); /* select another cs to link channel establish */
		}
		return (0);
	}
//	if (( Rt_sts == ST_LCH_REQ ) || ( Rt_sts == ST_LCH_RREQ ))
//	{
//		if(RadioFlag[0] && (abs_slot != SLTNO(0)))
//		{
//			Sys_bcch[0][0][6] = (abs_slot << 6)+ ( Sys_bcch[0][0][6] & 0x3f );
//		}
//		else if (abs_slot != SLTNO(0))
//		{
//			Sys_bcch[0][0][6] = (abs_slot << 6 )+ ( Sys_bcch[0][0][6] & 0x3f );
//
//		}
//	}
//	else
//	{
//		Sys_bcch[0][0][6] = (abs_slot << 6 )+ ( Sys_bcch[0][0][6] & 0x3f );
//
//	}
	Sys_bcch[0][0][6] = (abs_slot << 6 )+ ( Sys_bcch[0][0][6] & 0x3f );
	slot = rx_cac[2] & 0x1F;  /* relative slot number */
	if ( slot > 7 )
	{
		slot %= 8;
	}

	Rt_slot = (abs_slot + slot) % 4 + 1;   /* TDMA slot number of communications carrier */

	SYS_WORK->tsk_id = TASKMNG;
	OUT_LCHEVT->evt_cod = ERT;
	OUT_LCHEVT->pri_cod = PSLCHASG;
	move_up_b((U1*) OUT_LCHEVT->msg_dat, &rx_cac[1], 4 );

	m_excreq( (WORD*)&SYS_WORK->tsk_id );
	//rt_rdinf();
	Rt_radinf.slt_num = Rt_slot;  /* set current radio info*/
	Rt_radinf.car_num = rx_cac[3];
	Rt_radinf.abs_slot = rx_cac[4] & 0x03;
	move_up_b((U1*)Rt_radinf.cs_id, SYS_CSID_P, 6);

	//SYS_SLT_NUM = Rt_radinf.slt_num;
	//SYS_CAR_NUM = Rt_radinf.car_num;
	Sys_ccsinf[2] = Rt_slot;
	Sys_ccsinf[4] = rx_cac[3];

	rssi_req( (U1)(Rt_radinf.car_num-1), Rt_slot, (U1)(abs_slot+1) );

	switch ( Rt_sts )
	{
		case ST_LCH_REQ		:
		case ST_LCH_RREQ	:
			Rt_sts = ST_LCH_UREQ;
			break;
		case ST_RLCH_REQ	:
		case ST_RLCH_RREQ	:
			Rt_sts = ST_RLCH_UREQ;
			break;
	}

	return (0);
}

/********************************************************************************************************/
/*                                                                          				*/
/*		NUMBER		13                                                      		*/
/*		CALL		void rt_lch_reject			               			*/
/*		PARAM		rx_cac is link channel assignment reject message content		*/
/*		DISCRIPTION:	rx_cac[0]: message type							*/
/*						rx_cac[1]: reject reason				*/
/*						rx_cac[2]: reserved					*/
/*						rx_cac[3]: option					*/
/*						rx_cac[4]: option(bit 1,2)				*/
/*				Rtlchdat: if carrier number error,Rtlchdat show the link channel establish*/
/*					  re-request message content.					*/
/*													*/
/*		RETURN:											*/
/********************************************************************************************************/
U1 rt_lch_reject(void)
{
#ifdef  _DEBUG_TC6_
		_SendStringToUart("rt_lch_reject\n",sizeof("rt_lch_reject\n"));
#endif
	rt_tm_stop( TR001ON );		/* stop timer tr001p */

	SYS_WORK->tsk_id = TASKMNG;
	OUT_LCHEVT->evt_cod = ERT;
	OUT_LCHEVT->pri_cod = PSLCHREF;
	move_up_b((U1*) OUT_LCHEVT->msg_dat, &rx_cac[1], 4 );

	OUT_LCHEVT->msg_dat[5] = Lchercnt;
	m_excreq( (WORD*)&SYS_WORK->tsk_id );
	//Rt_sts = ST_WAIT;
	Rt_sts = (U1)rt_state_table->state;
	return (0);
}

/********************************************************************************************************/
/*                                                                          				*/
/*		NUMBER		                                                      			*/
/*		CALL		void rt_recall_lch_reject			               		*/
/*		PARAM											*/
/*		DISCRIPTION:	received lch reject message in recall switch state			*/
/*													*/
/*		RETURN:											*/
/********************************************************************************************************/
U1 rt_recall_lch_reject(void)
{
#ifdef  _DEBUG_TC6_
		_SendStringToUart("rt_recall_lch_reject\n",sizeof("rt_recall_lch_reject\n"));
#endif
	rt_tm_stop( TR001ON );
	rt_recall_lch_send();   /* select another csid to link channel establish */
	return (0);
}



/*************************************************************************/
/*                                                                        */
/*		NUMBER		                                          */
/*		CALL		void rt_phinf			          */
/*		PARAM							  */
/*		DISCRIPTION:	received  message from L1		  */
/*									  */
/*		RETURN:							  */
/**************************************************************************/
U1 rt_phinf(void)
{
#ifdef  _DEBUG_TC6_
		_SendStringToUart("rt_phinf\n",sizeof("rt_phinf\n"));
#endif

	rt_tm_start( TR001ON );	/* start timer tr001p,this timer used for waiting lch assign message */
	rt_tm_stop( TRCCHESTON );
	return (0);
}

U1 rt_lch_sync(void)
{
	rt_tm_stop( TR101ON );
	Lchercnt = 0;

#ifdef  EXT_IO
        HisOut(0,0xda,0x08,0,0);
#endif
	SYS_WORK->tsk_id = TASKMNG;
	OUT_LCHEVT->evt_cod = ERT;
	OUT_LCHEVT->pri_cod = PSSYNC;
	OUT_LCHEVT->msg_dat[5] = 0;
	OUT_LCHEVT->dmy[5] = IN_LCHEVT->msg_dat[0];
	m_excreq( (WORD*)&SYS_WORK->tsk_id );

	Tchre_id = 0;
	//Rt_sts = ST_TCH_ACT;
	Rt_sts = (U1)rt_state_table->state;

	return (0);
}

U1 rt_syn(void)
{
	U1	flg,
		reg;

	flg = 0;
	reg = 0;

	switch ( Rt_sts )
	{
		case ST_RLCH_ASG:
			rt_tm_stop( TR105ON );
			/* No break */
		case ST_LCH_ASG	:
			rt_tm_stop( TR101ON );
			Lchercnt = 0;
			break;
		case ST_TCH_REA	:
			rt_tm_stop( TR101ON );
			Tchrrcnt = 0;
			break;
		case ST_SYN_WAIT:
			rt_tm_stop( TR103ON );
			if ( Tchre_id == 0 )
				break;
			flg = 1;
			switch ( Tchre_id )
			{
				case PS_TCHRES:
				case PS_RESHND:
					Tchrrcnt = 0;
					/* No break */
				case CS_TCHRES:
					rt_tm_start( TR304ON );
					reg = BIT1;
					break;
				case PS_HNDLCH:
				case CS_HNDLCH:
					Lchercnt = 0;
					rt_tm_start( TR305ON );
					reg = BIT2;
					break;
			}
			break;
	}




	SYS_WORK->tsk_id = TASKMNG;
	OUT_LCHEVT->evt_cod = ERT;
	OUT_LCHEVT->pri_cod = PSSYNC;

⌨️ 快捷键说明

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