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

📄 rt0main.c

📁 phs 源代码 小灵通协议源代码 phs source code
💻 C
📖 第 1 页 / 共 2 页
字号:
/*			5.timer TR105P time out				*/
/*			6.timer TR306P time out				*/
/*		RETURN							*/
/*                                                                      */
/************************************************************************/
void rt_rdbak(void)
{
	Rt_slot = Rt_radbak.slt_num;   /* slot number in communication state */
	move_up_b((U1 *)&Rt_radinf, (U1 *)&Rt_radbak, sizeof(Rt_radinf));
	   /* setting the radio info in communication state */

	move_up_b( SYS_CSID_P, (U1*)Rt_radinf.cs_id, 6);  /* set csid value in communication state */
	SYS_SLT_NUM = Rt_radinf.slt_num;  /* slot number */
	SYS_CAR_NUM = Rt_radinf.car_num;  /* carrier number */
}


/************************************************************************/
/*                                                                      */
/*		NUMBER						        */
/*		CALL		void rt_copy_csinfo_to_ownbuffer(CCH_MON_INF *moni)      */
/*		PARAM		CCH_MON_INF *moni : camp cs list point	*/
/*		FUNC		this function copy the csinfo to own buffer*/
/*		RETURN		0					*/
/*		GLOBAL		Rt_mntcs[13]:	CS INFO:CS-ID,RSSI	*/
/*				Rt_mntcnt:	camp cs count		*/
/************************************************************************/
void rt_copy_csinfo_to_ownbuffer(CCH_MON_INF *moni)
{
	U1	n;
	RT_MNTCS	*mntcs;
	U1	rssi = 0xFF;
	U1	min = 0;

	for (n = 0, mntcs = Rt_mntcs; n < Rt_mntcnt; n++, mntcs++)
	{
		if (!cmp_up_b((U1*)mntcs->cs_id, (U1*)moni->Csid, 5)  /* check the same cs_id */
		  && (mntcs->cs_id[5] & 0x03) == (moni->Csid[5] & 0x03))
		{/* if cs_id is same */
			if ((moni->Rssi != 0xFF)   /* update the cs info */
				&& (mntcs->rssi < moni->Rssi || mntcs->rssi == 0xFF))
			{
				mntcs->rssi = moni->Rssi;
			}
			return;
		}
		if (rssi > mntcs->rssi)
		{
			rssi = mntcs->rssi;
			min = n;
		}
	}

	if ( Rt_mntcnt < HOCSMAX )
	{

		move_up_b( (U1*)mntcs->cs_id, (U1*)moni->Csid, 6);
		mntcs->rssi = moni->Rssi;
		Rt_mntcnt++;
	}
	else
	{/* update the cs of lowest rssi */
		if (moni->Rssi == 0xFF
			|| moni->Rssi <= rssi)
		{
			return;
		}

		mntcs = &Rt_mntcs[min];
		move_up_b( (U1*)mntcs->cs_id,(U1*) moni->Csid, 6);
		mntcs->rssi = moni->Rssi;
	}
}


void rt_monitor_sort(void)
{
//	I1			m;
	U1			i, j, k;
	RT_MNTCS	Work;

	for ( i = 0; i < Rt_mntcnt - 1; i++ )
	{
		move_up_b((U1*)&Work, (U1*)&Rt_mntcs[i], sizeof(RT_MNTCS));
		k = i;

		for ( j = i + 1; j < Rt_mntcnt; j++ )
		{
			if ( Rt_mntcs[j].rssi < Work.rssi )
			{
				move_up_b((U1*)&Work, (U1*)&Rt_mntcs[j], sizeof(RT_MNTCS));
				k = j;
			}
		}

		move_up_b((U1*)&Rt_mntcs[k], (U1*)&Rt_mntcs[i], sizeof(RT_MNTCS));
		move_up_b((U1*)&Rt_mntcs[i], (U1*)&Work, sizeof(RT_MNTCS));
	}
}

/************************************************************************/
/*									*/
/*		NUMBER							*/
/*		CALL		U1 rt_carr_chk( U1 num )		*/
/*		PARAM		U1 num		:	carrier number	*/
/*		FUNC		check carrier number in  range or out 	*/
/*		RETURN		OK(1):in range				*/
/*				NG(0):out range				*/
/*		GLOBAL		Sys_ccsinf:	cs infomation during communication*/
/*									*/
/************************************************************************/
U1 rt_carr_chk( U1 num )
{
	U1	sts = NG;

	if ( Sys_ccsinf[19] <= 0x02 )    /* ver 1 and ver2 has only one type	*/
	{
		if (( num >= 1 ) && ( num <= 77 ))
		{
			sts = OK;
		}
	}
	else  /* ver3 carrier has two type*/
	{
		if ((( num >=   1 ) && ( num <=  82 )) ||
			(( num >= 251 ) && ( num <= 255 )))
		{
			sts = OK;
		}
	}
	return ( sts );
}

/*--------------------------------------------------------------------------*/
/*                                                                          */
/*      CALL        Mn_LowCSPrefer_Sort(U1)                                 */
/*      PARAM       U1  reg_area_prefer                                     */
/*      FUNC        sort the CS use the algorithm from the seamless spec    */
/*      RETURN      the result in the global variable                       */
/*      GLOBAL                                                              */
/*                                                                          */
/*--------------------------------------------------------------------------*/
void rt_lowcsprefer_sort(void)
{
//	I1			m;
	U1			i, j, k;
	RT_MNTCS	Work;
	U2			current_rssi, ref_rssi;

	for ( i = 0; i < Rt_mntcnt - 1; i++ )
	{
		move_up_b((U1*)&Work, (U1*)&Rt_mntcs[i], sizeof(RT_MNTCS));
		k = i;
		/* This algorithm is to add a maximum value to prefered CS RSSI and */
		/* make it can be selected first*/
		current_rssi = Work.rssi;
		if(Mn_GetCSPowerBit((U1*)Work.cs_id))
			current_rssi+=256;

		for ( j = i + 1; j < Rt_mntcnt; j++ )
		{
			ref_rssi=Rt_mntcs[j].rssi;
			if(Mn_GetCSPowerBit((U1*)Rt_mntcs[j].cs_id))
				ref_rssi+=256;

			if ( ref_rssi < current_rssi )
			{
				move_up_b((U1*)&Work, (U1*)&Rt_mntcs[j], sizeof(RT_MNTCS));
				k = j;
			}
		}

		move_up_b((U1*)&Rt_mntcs[k], (U1*)&Rt_mntcs[i], sizeof(RT_MNTCS));
		move_up_b((U1*)&Rt_mntcs[i], (U1*)&Work, sizeof(RT_MNTCS));
	}
}

/*--------------------------------------------------------------------------*/
/*                                                                          */
/*      CALL        rt_recall_cch_moni2(void)                               */
/*      PARAM                                          			    */
/*      FUNC        arrang the cslist    			            */
/*      RETURN      the result in the global variable                       */
/*      GLOBAL                                                              */
/*                                                                          */
/*--------------------------------------------------------------------------*/
U1 rt_recall_cch_moni2(void)
{
	U1	cc;
	U2	i;
	CCH_MON_INF	moni;

	for(i = 0; i < CchMonCount; i++)
	{
		move_up_b((U1*)&moni, (U1*)&CList.CsInf[i], sizeof(CCH_MON_INF));
		for(cc = 0; cc < 6; cc++)
			moni.Csid[cc] = csid_mirr(moni.Csid[cc]);
		moni.Csid[5] = (moni.Csid[5] >> 6) & 0x03;

		if (( Rt_rcsid[6] )&&  /* compare tch switch indiction cs */
		    ( cmp_up_b(Rt_rcsid, (U1*)moni.Csid, 5)|| Rt_rcsid[5] != (moni.Csid[5] & 0x03)))
		{/* csid must same as Rt_rcsid */
			continue;
		}

		if(rt_page_area_compare((U1*)moni.Csid,SYS_CSID_P) )   /* compare paging area number */
		{
			if (!(Sys_rtfunc[4] & BIT3))   /* recall type connect function to other CS
											within paging area absent/present */
				continue;
		}
		else
		{
			if (!(Sys_rtfunc[4] & BIT5))  /* recall type connect function to other CS
											among paging area present/absent */
				continue;
			if(Call_Loc_NG)
				continue;
		}

		rt_copy_csinfo_to_ownbuffer(&moni);
	}

	if(Mn_GetFeature(FEATURE_SEAMLESS,FEATURE_LOW_CS_PREFER))
		rt_lowcsprefer_sort();
	else
		rt_monitor_sort();

#ifdef EXT_IO
	for(cc = 0; cc < Rt_mntcnt; cc++)
	{
		HisOut(sizeof(RT_MNTCS), 0x3f, 0, ECCH_MON, (U1 *)&Rt_mntcs[cc]);
	}
#endif

	return (0);
}


#ifdef SIMU_ON_PC
/*
void	cch_est_req(BYTE freq, BYTE *cs_id, BYTE gain)
{
	U1 temp_buff[3];

	temp_buff[0] = freq;
	temp_buff[1] = cs_id;
	temp_buff[2] = gain;
	SendUart2L1(SIMTSKL1,CCHESTREQ, 0xFF , temp_buff , 3);
}
*/
void	tch_est_req(BYTE kind, BYTE freq, BYTE slot)
{
	U1 temp_buff[3];

#ifdef  EXT_IO

        HisOut(0,0xda,0x07,0,0);
#endif
	temp_buff[0] = kind;
	temp_buff[1] = freq;
	temp_buff[2] = slot;
	SendUart2L1(SIMTSKL1,TCHESTREQ,0xFF , temp_buff , 3);
}

void	csid_set_req(BYTE *new_csid)
{
	SendUart2L1(SIMTSKL1,TCHESTREQ,0xFF , new_csid , 6);
}

void	rssi_req( BYTE freq, BYTE slot ,BYTE a_slot )
{
	U1 temp_buff[3];

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


	temp_buff[0] = freq;
	temp_buff[1] = slot;
	temp_buff[2] = a_slot;
	SendUart2L1(SIMTSKL1,RSSIREQ,0xFF , temp_buff,sizeof(temp_buff));
}

void	txstp_req(BYTE select)
{
	SendUart2L1(SIMTSKL1,TXSTP,0xFF , &select,1);
}

void	enc_req(void)
{
	SendUart2L1(SIMTSKL1,ENCREQ,0xFF,0,0);
}


void	cch_m_req(BYTE kind, BYTE freq, BYTE thresh, BYTE gain, BYTE flg)
{
	U1 temp_buff[5];

	temp_buff[0] = kind;
	temp_buff[1] = freq;
	temp_buff[2] = thresh;
	temp_buff[3] = gain;
	temp_buff[4] = flg;
	SendUart2L1(SIMTSKL1,CCHMREQ,0xFF ,temp_buff,sizeof(temp_buff));
}

void	ph_dt_req(BYTE l1_ch, BYTE target, BYTE dummy,void *ptr)
{
	U1 temp_buff[25];
    U1 *p =0 ;
    if(l1_ch == L1_SCCH)
    {
	    temp_buff[0] = l1_ch;
	    temp_buff[1] = target;
	    temp_buff[2] = dummy;
	    SendUart2L1(SIMTSKL1,PHDTREQ,0xFF , temp_buff,3);
    }
    else
    {   p = (U1*)ptr;
        temp_buff[0] = l1_ch;
	    temp_buff[1] = target;
	    temp_buff[2] = dummy;
            if(SACCH == l1_ch)
            {
                move_up_b(&temp_buff[3],p,4);
                SendUart2L1(SIMTSKL1,PHDTREQ,0xFF , temp_buff,3+4);
            }
            else
            {
                move_up_b(&temp_buff[3],p,20);
                SendUart2L1(SIMTSKL1,PHDTREQ,0xFF , temp_buff,3+20);
            }


    }
}

void	cch_m_stp(void)
{
	SendUart2L1(SIMTSKL1,CCHMSTP,0xFF,0,0);
}
#endif

#ifdef __cplusplus
}
#endif

#undef __RTMAIN_C_


#endif

⌨️ 快捷键说明

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