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

📄 rxsync.c

📁 MIMO 2x2接收端选择全系统仿真代码
💻 C
字号:
/*****************************************************************************
  Module     : Frame Synchronization
******************************************************************************

  Function   : Frame synchronization based on symbols.

  Procedures : none

  Author     : $Author: Adrian $

  Revision   : $Revision: 7 $

  Modified   : $Modtime: 05-05-25 13:49 $

  File       : $Workfile: rxsync.c $

******************************************************************************
 KTH, Royal Institute of Technology, S3, Stockholm
*****************************************************************************/

/*--- Include files --------------------------------------------------------*/

/* import */

/* export */
#include "rxsync.h"

/*=== End of include files =================================================*/


/*--- Global variables definition ------------------------------------------*/

typRX_SYNCSTATE SyncState;

/*=== End of global variables definition ===================================*/


/*--- Global constants definition ------------------------------------------*/
/*=== End of global constants definition ===================================*/


/*--- Local defines --------------------------------------------------------*/

#define SYNCWINDOWLEN 90 // window length for the synchronization, must be a multiple of 3

/*=== End of local defines =================================================*/


/*--- Local types declaration ----------------------------------------------*/
/*=== End of local types declaration =======================================*/


/*--- Local variables definition -------------------------------------------*/
/*=== End of local variables definition ====================================*/


/*--- Local constants definition -------------------------------------------*/

//#pragma DATA_ALIGN(pfCorrelI,8); // must be double word aligned
static float fCorrelI; // for the correlation on both Inphase paths
//#pragma DATA_ALIGN(pfCorrelQ,8); // must be double word aligned
static float fCorrelQ; // for the correlation on both Quadrature paths
static float pfSync[SYNCWINDOWLEN];

extern const Int16 SYNCSEQUENCE_I[SYNCLEN];
extern const Int16 SYNCSEQUENCE_Q[SYNCLEN];

/*=== End of local constants definition ====================================*/


/*--- Local functions definition -------------------------------------------*/
/*=== End of local functions definition ====================================*/


/*--- Global functions definition ------------------------------------------*/

/****************************************************************************
  Function   : synchronization
 ****************************************************************************

  Description : Frame Synchronization

  Inputs      : Recieved Training SEQ.

  Outputs     : Synchronization Index

  By          : 2005-04-28 Created First Rev. by Loghman Andimeh
  				2005-05-10 Modified(Loghman)

 ****************************************************************************/
void synchronization(typRX_SYNCSTATE *pSyncState)
{

	int i, k;
	int start_time = 0;
	int sync_index = 0;
	float sync_max = 0.0f;

	for (i = 0; i<SYNCWINDOWLEN; i++) {
		fCorrelI=0;
		fCorrelQ=0;
		for(k =0; k<SYNCLEN ; k++){
			
			fCorrelI += pSyncState->pfRcv1I[i+k*(OVERSAMPLING)+start_time]*SYNCSEQUENCE_I[k]+
			 				pSyncState->pfRcv2I[i+k*(OVERSAMPLING)+start_time]*SYNCSEQUENCE_I[k];
			fCorrelQ += pSyncState->pfRcv1Q[i+k*(OVERSAMPLING)+start_time]*SYNCSEQUENCE_Q[k]+
							pSyncState->pfRcv2Q[i+k*(OVERSAMPLING)+start_time]*SYNCSEQUENCE_Q[k];
							
		}
		
		pfSync[i] = fCorrelI*fCorrelI + fCorrelQ*fCorrelQ;
		
		if(pfSync[i] > sync_max){
			sync_max = pfSync[i];
			sync_index = i;
		}
	}
	pSyncState->iSyncIndex = sync_index;	
}




/*=== End of global functions definition ===================================*/

/*--- AUTOMATICALLY GENERATED VERSION HISTORY --------------------------------

$Log: /MIMO/Receiver/rxsync.c $ 
 * 
 * 7     05-05-25 13:51 Adrian
 * changed SYNCWINDOWLEN from 30 to 90, type of sync_max from int to float
 * and replaced the arrays pfCorrelI and pfCorrelQ with just variables
 * 
 * 6     05-05-19 12:34 Loghman
 * Changeing back the cofficent for Training SEQ to 1.
 * 
 * 5     05-05-17 12:06 Loghman
 * Changeing the cofficent for Training SEQ. ( 3*SYNCSEQUENCE_I[k] )
 * 
 * 4     05-05-13 15:15 Jinfeng
 * 1.initiaize pfCorrelI[i]=0, and pfCorrelQ[i]=0 outside the 'k' loop 
 * 2.replace the item  k*(OVERSAMPLING-1) inside the 'k' loop by
 * k*(OVERSAMPLING), 
 * 3. After verification with MATLAB and DSP, this function works well
 * now, with 2 samples shift caused by the hardware system.
 * 
 * 2     05-05-11 18:05 Loghman
 * 
 * 1     05-05-11 17:00 Adrian
 * created and added to VSS

===== END OF AUTOMATICALLY GENERATED VERSION HISTORY =======================*/

/**** End of file ***********************************************************/

⌨️ 快捷键说明

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