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

📄 copy of txmain.c

📁 MIMO 2x2接收端选择全系统仿真代码
💻 C
📖 第 1 页 / 共 2 页
字号:
			{
				pDataFrameBuff[n] = randomtestdata[n];
				n++;
			}
			// reset the filter states (used in upsampPulseShape() by the polyphase implementation)
			//050508_AS: removed "+FRAMEBUFFSIZE" for the length, since only the states have to be cleared
			memset(cplxFiltStat1.pIBuffer,0,(RRCLEN-1)*sizeof(float));
			memset(cplxFiltStat1.pQBuffer,0,(RRCLEN-1)*sizeof(float));
			memset(cplxFiltStat2.pIBuffer,0,(RRCLEN-1)*sizeof(float));
			memset(cplxFiltStat2.pQBuffer,0,(RRCLEN-1)*sizeof(float));
			// add the guard intervalls and training sequences
			uiOffset = initOverhead(&cplxBuffer1,CH1,eCOM_SYNCFRAME); // channel 1
			uiOffset = initOverhead(&cplxBuffer2,CH2,eCOM_SYNCFRAME); // channel 2
			// do the 16-QAM mapping for the data
			qamMapping(&pDataFrameBuff[0],&cplxBuffer1,uiOffset,(DATASYMBSYNC/2)); // channel 1
			qamMapping(&pDataFrameBuff[1],&cplxBuffer2,uiOffset,(DATASYMBSYNC/2)); // channel 2
			// upsample and pulseshaping
			upsampPulseShape(&cplxFiltStat1,&cplxTempOut1,(RRCLEN-1+FRAMEBUFFSIZE)); // channel 1
			upsampPulseShape(&cplxFiltStat2,&cplxTempOut2,(RRCLEN-1+FRAMEBUFFSIZE)); // channel 2
			// upconverstion to 10kHz
			// channel 1 goes into even numbered words ...
			// and channel 2 into odd numbered words in pBufferXmt
			UpConvert(&cplxTempOut1,&cplxTempOut2,pBufferXmt,BUFFSIZE,&uTimeIndex);
			// restore the last 70 (half the filter lenght) values from the pilot
			for (n = 0; n < (RRCLEN*OVERSAMPLING)/2; n++)
			{
				pBufferXmt[2*n] = pDelayBuffer[n];
				pBufferXmt[2*n+1] = pDelayBuffer[n];
			}
			// set control variable
			iSyncFrameCntrl = 0;
			if (TxStates.iSyncRep == 1)
			{
				// next frame will be a data frame
				TxStates.TxState = eTX_SYNCFRAME;
				#ifdef _DEBUGLOG
					LOG_printf(&trace,"change to state eTX_SYNCFRAME (line %d)",__LINE__);
				#endif
			}
			else
			{
				// next frame will be a data frame
				TxStates.TxState = eTX_DATAFRAMES;
				#ifdef _DEBUGLOG
					LOG_printf(&trace,"change to state eTX_DATAFRAMES (line %d)",__LINE__);
				#endif
			}
			break;
		case eTX_SYNCFRAME:
			#ifdef _DEBUGLOG
				LOG_printf(&trace,"state eTX_SYNCFRAME");
			#endif
			//uiFrameCounter++;
			TxStates.uFrameNbr++;
			// check if last frame will be sent
			//if (uiFrameCounter < TxStates.uNoOfBlocks)
			if (TxStates.uFrameNbr < TxStates.uNoOfBlocks)
			{
				// copy the data from SDRAM to the frame data buffer
				memcpy(pDataFrameBuff, &pDataBuff[uiDataOffset], DATASYMBSYNC);
				// update the offset
				uiDataOffset += DATASYMBSYNC;
				if (TxStates.iSyncRep != 1)
				{
					#ifdef _DEBUGLOG
						LOG_printf(&trace,"change to state eTX_DATAFRAMES (line %d)",__LINE__);
					#endif
					// change back to data frames
					TxStates.TxState = eTX_DATAFRAMES;
				}
			}
			else
			{
				// check if only a part of the frame will be filled with data
				if (uiFracFrame > 0)
				{
					// clear the unused part
					memset(&pDataFrameBuff[uiFracFrame],0,DATASYMBSYNC-uiFracFrame);
					// copy the data from SDRAM to the frame data buffer
					memcpy(pDataFrameBuff, &pDataBuff[uiDataOffset], DATASYMBSYNC-uiFracFrame);
					// update the offset
					uiDataOffset += DATASYMBSYNC-uiFracFrame;
				}
				else
				{
					// copy the data from SDRAM to the frame data buffer
					memcpy(pDataFrameBuff, &pDataBuff[uiDataOffset], DATASYMBSYNC);
					// update the offset
					uiDataOffset += DATASYMBSYNC;
				}
				// set state to finish the transmission
				TxStates.TxState = eTX_TERMINATION;
				#ifdef _DEBUGLOG
	    			LOG_printf(&trace,"transmission will be finished.\n    change to state eTX_TERMINATION (line %d)",__LINE__);
				#endif
			}
			// add the guard intervalls and training sequences
			uiOffset = initOverhead(&cplxBuffer1,CH1,eCOM_SYNCFRAME); // channel 1
			uiOffset = initOverhead(&cplxBuffer2,CH2,eCOM_SYNCFRAME); // channel 2
			// do the 16-QAM mapping for the data
			qamMapping(&pDataFrameBuff[0],&cplxBuffer1,uiOffset,(DATASYMBSYNC/2)); // channel 1
			qamMapping(&pDataFrameBuff[1],&cplxBuffer2,uiOffset,(DATASYMBSYNC/2)); // channel 2
			// upsample and pulseshaping
			upsampPulseShape(&cplxFiltStat1,&cplxTempOut1,(RRCLEN-1+FRAMEBUFFSIZE)); // channel 1
			upsampPulseShape(&cplxFiltStat2,&cplxTempOut2,(RRCLEN-1+FRAMEBUFFSIZE)); // channel 2
			// upconverstion to 10kHz
			// channel 1 goes into even numbered words ...
			// and channel 2 into odd numbered words in pBufferXmt
			UpConvert(&cplxTempOut1,&cplxTempOut2,pBufferXmt,BUFFSIZE,&uTimeIndex);
			#ifdef _DEBUGLOG
    			//LOG_printf(&trace,"frame no. %d sent (sync)",uiFrameCounter);
    			LOG_printf(&trace,"frame no. %d sent (sync)",TxStates.uFrameNbr);
			#endif
			HostCommState.cNewFrameReady = 1;
			SEM_post(&sem);	// to resume the host comm task
			break;
		case eTX_DATAFRAMES:
			// put together and process the data frames, one by one
			//uiFrameCounter++;
			TxStates.uFrameNbr++;
			iSyncFrameCntrl++;
			// check if last frame will be sent
			//if (uiFrameCounter < TxStates.uNoOfBlocks)
			if (TxStates.uFrameNbr < TxStates.uNoOfBlocks)
			{
				// copy the data from SDRAM to the frame data buffer
				memcpy(pDataFrameBuff, &pDataBuff[uiDataOffset], DATABUFFSIZE);
				// update the offset
				uiDataOffset += DATABUFFSIZE;
				if ((iSyncFrameCntrl >= TxStates.iSyncRep-1) && (TxStates.iSyncRep > 0))
				{
					#ifdef _DEBUGLOG
						LOG_printf(&trace,"change to state eTX_SYNCFRAME (line %d)",__LINE__);
					#endif
					// first frame will be sent, change to the next state to send the data frames
					TxStates.TxState = eTX_SYNCFRAME;
				}
			}
			else
			{
				// check if only a part of the frame will be filled with data
				if (uiFracFrame > 0)
				{
					// clear the unused part
					memset(&pDataFrameBuff[uiFracFrame],0,DATABUFFSIZE-uiFracFrame);
					// copy the data from SDRAM to the frame data buffer
					memcpy(pDataFrameBuff, &pDataBuff[uiDataOffset], DATABUFFSIZE-uiFracFrame);
					// update the offset
					uiDataOffset += DATABUFFSIZE-uiFracFrame;
				}
				else
				{
					// copy the data from SDRAM to the frame data buffer
					memcpy(pDataFrameBuff, &pDataBuff[uiDataOffset], DATABUFFSIZE);
					// update the offset
					uiDataOffset += DATABUFFSIZE;
				}
				// set state to finish the transmission
				TxStates.TxState = eTX_TERMINATION;
				#ifdef _DEBUGLOG
	    			LOG_printf(&trace,"transmission will be finished.\n    change to state eTX_TERMINATION (line %d)",__LINE__);
				#endif
			}
			// add the guard intervalls and training sequences
			uiOffset = initOverhead(&cplxBuffer1,CH1,eCOM_DATAFRAME); // channel 1
			uiOffset = initOverhead(&cplxBuffer2,CH2,eCOM_DATAFRAME); // channel 2
			// do the 16-QAM mapping for the data (also read out data)
			qamMapping(&pDataFrameBuff[0],&cplxBuffer1,uiOffset,(DATABUFFSIZE/2)); // channel 1
			qamMapping(&pDataFrameBuff[1],&cplxBuffer2,uiOffset,(DATABUFFSIZE/2)); // channel 2
			// upsample and pulseshaping
			upsampPulseShape(&cplxFiltStat1,&cplxTempOut1,(RRCLEN-1+FRAMEBUFFSIZE)); // channel 1 (goes into even numbered words in Temp)
			upsampPulseShape(&cplxFiltStat2,&cplxTempOut2,(RRCLEN-1+FRAMEBUFFSIZE)); // channel 1 (goes into odd numbered words in Temp)
			// upconverstion to 10kHz
			UpConvert(&cplxTempOut1,&cplxTempOut2,pBufferXmt,BUFFSIZE,&uTimeIndex);
    		#ifdef _DEBUGLOG	
    			//LOG_printf(&trace,"frame no. %d sent (data)",uiFrameCounter);
    			LOG_printf(&trace,"frame no. %d sent (data)",TxStates.uFrameNbr);
			#endif
			HostCommState.cNewFrameReady = 1;
			SEM_post(&sem);	// to resume the host comm task
			break;
      	case eTX_TERMINATION:
      		// clear buffer
			memset(cplxBuffer1.pIBuffer,0,FRAMEBUFFSIZE*sizeof(float));
			memset(cplxBuffer1.pQBuffer,0,FRAMEBUFFSIZE*sizeof(float));
			memset(cplxBuffer2.pIBuffer,0,FRAMEBUFFSIZE*sizeof(float));
			memset(cplxBuffer2.pQBuffer,0,FRAMEBUFFSIZE*sizeof(float));
			// let the filter run just to "empty" the states and send the last samples
			upsampPulseShape(&cplxFiltStat1,&cplxTempOut1,(RRCLEN-1+FRAMEBUFFSIZE)); // channel 1
			upsampPulseShape(&cplxFiltStat2,&cplxTempOut2,(RRCLEN-1+FRAMEBUFFSIZE)); // channel 2
			// upconverstion to 10kHz
			// channel 1 goes into even numbered words ...
			// and channel 2 into odd numbered words in pBufferXmt
			UpConvert(&cplxTempOut1,&cplxTempOut2,pBufferXmt,BUFFSIZE,&uTimeIndex);
			// change to the last state
			TxStates.TxState = eTX_CLEARBUFFER;
			#ifdef _DEBUGLOG
    			LOG_printf(&trace,"state eTX_TERMINATION");
			#endif
      		break;
      	case eTX_CLEARBUFFER:
      		// clear the buffer
			memset(pBufferXmt, 0, BUFFSIZE*sizeof(Int16));
			// change to the last state
			TxStates.TxState = eTX_DISABLETX;
			#ifdef _DEBUGLOG
    			LOG_printf(&trace,"state eTX_CLEARBUFFER");
			#endif
      		break;
      	case eTX_DISABLETX:
      		// set the second buffer to zero ...
			memset(pBufferXmt, 0, BUFFSIZE*sizeof(Int16));
			// ... and disable the EDMA interrupts
      		disableEdma();
			TxStates.TxState = eTX_IDLE;
    		// reset the variables
			//TxStates.uNoOfBlocks = 0;
			//TxStates.uFileSize = 0;
			#ifdef _DEBUGLOG
    			LOG_printf(&trace,"state eTX_DISABLETX: EDMA disabled.");
			#endif
      		break;
      	default:
			#ifdef _DEBUGLOG
    			LOG_printf(&trace,"Error occured on line %d in file %s.", __LINE__, __FILE__);
    			LOG_error("processMIMO: TxState = %d not allowed. No matching state found.", TxStates.TxState);
			#endif
			exit(EXIT_INVALID_TXSTATE);
      		break;
	}
/*	DEBUG: the following if statement can be used to make the transmitter sending continuously */
/*
	if (TxStates.TxState == eTX_DISABLETX)
		TxStates.TxState = eTX_STARTTX;
*/
}


/****************************************************************************
  Function    : processSISO()
 ****************************************************************************

  Description : State machine for the SISO transmission.

  Inputs      : pointer to the transmit buffer

  Outputs     : none

  By          : 2005-05-08 Adrian Schumacher

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

void processSISO(Int16 *pBufferXmt)
{
}


/* --- Threads ------------------------------------------------------------ */

/****************************************************************************
  Function    : processBuffer()
 ****************************************************************************

  Description : Process data and fill buffer to prepare for transmission.
  				The state machine for the transmitter is located here.

  Inputs      : none

  Outputs     : none

  By          : 2005-04-18 Adrian Schumacher

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

void processBuffer(void)
{
    Uint32 pingPong;
    Int16 *pBufferXmt;
    
    /* Get contents of mailbox posted by edmaHwi */
    pingPong =  SWI_getmbox();

    /* check which buffer has to be filled */
    if (pingPong == PING) {
    	/* PING */
    	pBufferXmt = gBufferXmtPing;
    } else {
    	/* PONG */
    	pBufferXmt = gBufferXmtPong;
    }

    /* Switch on LED #0 as a visual cue */
    DSK6713_LED_on(0);
    /* branch according to the transmission method to use */
	if (TxStates.TxMethod == eCOM_MIMO)
    	processMIMO(pBufferXmt);
    else if (TxStates.TxMethod == eCOM_SISO)
    	processSISO(pBufferXmt);
    else
    {
		#ifdef _DEBUGLOG
			LOG_printf(&trace,"Error occured on line %d in file %s.", __LINE__, __FILE__);
			LOG_error("processBuffer: TxMethod = %d not allowed.", TxStates.TxMethod);
		#endif
    }

    /* Switch off LED #0 as a visual cue */
    DSK6713_LED_off(0);
}


/****************************************************************************
  Function    : checkDIPswitch()
 ****************************************************************************

  Description : Checks the DIP switches to get their state.

  Inputs      : none

  Outputs     : none

  By          : 2005-04-19 Adrian Schumacher

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

void checkDIPswitch(void)
{
	#ifdef _DEBUGLOG
		LOG_printf(&trace,"status: state is %d",TxStates.TxState);
	#endif
    if (!DSK6713_DIP_get(0))
    {
    	// switch is in down position (pressed)
		DSK6713_LED_toggle(2);
    	if ((TxStates.TxState == eTX_IDLE) && (TxStates.uFileSize > 0))
    	{
    		// start the transmitter
    		TxStates.TxState = eTX_STARTTX;
    		// enable EDMA
			startEdma();   // Setup EDMA transfer
			#ifdef _DEBUGLOG
    			LOG_printf(&trace,"change state to eTX_STARTTX (line %d)",__LINE__);
			#endif
		}
    }
    else
    {
    	// switch is in up position
		DSK6713_LED_off(2);
    }
}


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

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

$Log: /MIMO/Transmitter/txmain.c $ 
 * 
 * 5     05-05-20 18:32 Adrian
 * fixed the filter initialization (after the pilot) and added the
 * functionality to start the transmission using dip switch 0 (and some
 * more minor modifications)
 * 
 * 4     05-05-17 16:36 Adrian
 * Error codes for exit() added.
 * 
 * 3     05-05-17 10:30 Adrian
 * Added semaphore synchronization for the host task (needs to be refined
 * and tested).
 * 
 * 2     05-05-16 19:12 Maxime
 * Initialization for host communication
 * 
 * 1     05-05-11 14:50 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 + -