📄 txfunctions.c
字号:
Description : Insert and initialize the guard intervalls and training
sequences in the buffer.
Inputs : pointer to the buffer where the header is placed
channel number (to determine the training sequence order)
Outputs : number of occupied elements in the buffer
By : 2005-04-19 Adrian Schumacher
****************************************************************************/
unsigned int initOverhead(typCOM_fCPLXBUFF *pComplexFrameBuffer, const Uint8 Channel,
const typCOM_eFrameFormat FrameFormat)
{
int i, n;
float *pFrameBufferI = pComplexFrameBuffer->pIBuffer;
float *pFrameBufferQ = pComplexFrameBuffer->pQBuffer;
// compute the number of symbols occupied by the header
// n = 2*GUARDSYMBOLS+2*TRAINLEN;
// if (FrameFormat == eCOM_SYNCFRAME)
// n += SYNCLEN;
n = 0;
// first guard interval
for(i=0;i<GUARDSYMBOLS;i++)
pFrameBufferI[n+i] = (float)(3*QAMSCALING*GUARDSYMB[i]); // I part
for(i=0;i<GUARDSYMBOLS;i++)
pFrameBufferQ[n+i] = (float)(3*QAMSCALING*GUARDSYMB[i]); // Q part
n += GUARDSYMBOLS;
if (FrameFormat == eCOM_SYNCFRAME)
{
// insert synchronization sequence
for(i=0;i<SYNCLEN;i++)
pFrameBufferI[n+i] = (float)(3*QAMSCALING*SYNCSEQUENCE_I[i]); // I part
for(i=0;i<SYNCLEN;i++)
pFrameBufferQ[n+i] = (float)(3*QAMSCALING*SYNCSEQUENCE_Q[i]); // Q part
n += SYNCLEN;
}
// first training sequence
for(i=0;i<TRAINLEN;i++)
pFrameBufferI[n+i] = (float)(3*QAMSCALING*TRAININGSEQ[Channel][i]); // I part
for(i=0;i<TRAINLEN;i++)
pFrameBufferQ[n+i] = (float)(3*QAMSCALING*TRAININGSEQ[Channel][i]); // Q part
n += TRAINLEN;
// second guard interval
for(i=0;i<GUARDSYMBOLS;i++)
pFrameBufferI[n+i] = (float)(3*QAMSCALING*GUARDSYMB[i]); // I part
for(i=0;i<GUARDSYMBOLS;i++)
pFrameBufferQ[n+i] = (float)(3*QAMSCALING*GUARDSYMB[i]); // Q part
n += GUARDSYMBOLS;
// second training sequence
for(i=0;i<TRAINLEN;i++)
pFrameBufferI[n+i] = (float)(3*QAMSCALING*TRAININGSEQ[Channel][i]); // I part
for(i=0;i<TRAINLEN;i++)
pFrameBufferQ[n+i] = (float)(3*QAMSCALING*TRAININGSEQ[Channel][i]); // Q part
n += TRAINLEN;
return n;
}
/****************************************************************************
Function : qamMapping()
****************************************************************************
Description : Do the 16-QAM mapping for the data in the data buffer and
place it in the output buffer.
Inputs : pointer to the data buffer
pointer to the complex output buffer
offset used in the output buffer (to skip the header)
data size of data buffer
Outputs : -
By : 2005-04-19 Adrian Schumacher
****************************************************************************/
void qamMapping(Uint8 *pDataBuffer, typCOM_fCPLXBUFF *pComplexBuffer,
const unsigned int uiOffset, const unsigned int datasize)
{
int i;
Uint8 tmp;
//Int16 iTemp;
for(i=0;i<datasize;i++)
{
// always skip a byte (demultiplexing for the two channels)
tmp = pDataBuffer[2*i] & 0x0F; //mask the lower 4 bits to map to one 16-QAM symbol
//iTemp = (*pComplexBuffer).pIBuffer[uiOffset+2*i];
pComplexBuffer->pIBuffer[uiOffset+2*i] = (float)QAMSCALING*c16QAM_I[tmp];
pComplexBuffer->pQBuffer[uiOffset+2*i] = (float)QAMSCALING*c16QAM_Q[tmp];
// always skip a byte (demultiplexing for the two channels)
tmp = (pDataBuffer[2*i] & 0xF0) >> 4;//mask the upper 4 bits to map to one 16-QAM symbol
pComplexBuffer->pIBuffer[uiOffset+2*i+1] = (float)QAMSCALING*c16QAM_I[tmp];
pComplexBuffer->pQBuffer[uiOffset+2*i+1] = (float)QAMSCALING*c16QAM_Q[tmp];
}
}
/****************************************************************************
Function : upsampPulseShape()
****************************************************************************
Description : Upsample the frame and perform the pulseshapeing.
Inputs : pointer to the complex input frame buffer
pointer to the complex output frame buffer
buffersize
Outputs : -
By : 2005-04-19 Adrian Schumacher
****************************************************************************/
void upsampPulseShape(typCOM_fCPLXBUFF *pFiltStat, typCOM_fCPLXBUFF *restrict pOutBuffer,
const unsigned int bufsize)
{
int i, j, len, count;
//len = sizeof(respoly[0])/sizeof(respoly[0][0]);
len = bufsize - RRCLEN + 1;
//memset(respoly,0x55,10*len*sizeof(respoly[0][0]));
//for(i=0;i<10;i++)
// memset(&respoly[i],0,len*sizeof(respoly[0][0]));
// filter Inphase part
DSPF_sp_fir_gen(pFiltStat->pIBuffer, rrc0, respoly[0], RRCLEN, len);
DSPF_sp_fir_gen(pFiltStat->pIBuffer, rrc1, respoly[1], RRCLEN, len);
DSPF_sp_fir_gen(pFiltStat->pIBuffer, rrc2, respoly[2], RRCLEN, len);
DSPF_sp_fir_gen(pFiltStat->pIBuffer, rrc3, respoly[3], RRCLEN, len);
DSPF_sp_fir_gen(pFiltStat->pIBuffer, rrc4, respoly[4], RRCLEN, len);
DSPF_sp_fir_gen(pFiltStat->pIBuffer, rrc5, respoly[5], RRCLEN, len);
DSPF_sp_fir_gen(pFiltStat->pIBuffer, rrc6, respoly[6], RRCLEN, len);
DSPF_sp_fir_gen(pFiltStat->pIBuffer, rrc7, respoly[7], RRCLEN, len);
DSPF_sp_fir_gen(pFiltStat->pIBuffer, rrc8, respoly[8], RRCLEN, len);
DSPF_sp_fir_gen(pFiltStat->pIBuffer, rrc9, respoly[9], RRCLEN, len);
// assemble samples to output signal
count = 0;
for(i=0;i<len;i++)
{
for(j=0;j<10;j++)
{
pOutBuffer->pIBuffer[count++] = respoly[j][i];
}
}
// overlap-save:
// save last input samples for next filtering
//memmove(&pFiltStat->pIBuffer[0], &pFiltStat->pIBuffer[bufsize-RRCLEN-1], (RRCLEN-1)*sizeof(float));
for(i=0;i<(RRCLEN-1);i++)
{
pFiltStat->pIBuffer[i] = pFiltStat->pIBuffer[bufsize-RRCLEN-1+i];
}
// filter Quadrature part
DSPF_sp_fir_gen(pFiltStat->pQBuffer, rrc0, respoly[0], RRCLEN, len);
DSPF_sp_fir_gen(pFiltStat->pQBuffer, rrc1, respoly[1], RRCLEN, len);
DSPF_sp_fir_gen(pFiltStat->pQBuffer, rrc2, respoly[2], RRCLEN, len);
DSPF_sp_fir_gen(pFiltStat->pQBuffer, rrc3, respoly[3], RRCLEN, len);
DSPF_sp_fir_gen(pFiltStat->pQBuffer, rrc4, respoly[4], RRCLEN, len);
DSPF_sp_fir_gen(pFiltStat->pQBuffer, rrc5, respoly[5], RRCLEN, len);
DSPF_sp_fir_gen(pFiltStat->pQBuffer, rrc6, respoly[6], RRCLEN, len);
DSPF_sp_fir_gen(pFiltStat->pQBuffer, rrc7, respoly[7], RRCLEN, len);
DSPF_sp_fir_gen(pFiltStat->pQBuffer, rrc8, respoly[8], RRCLEN, len);
DSPF_sp_fir_gen(pFiltStat->pQBuffer, rrc9, respoly[9], RRCLEN, len);
// assemble samples to output signal
count = 0;
for(i=0;i<len;i++)
{
for(j=0;j<10;j++)
{
pOutBuffer->pQBuffer[count++] = respoly[j][i];
}
}
// overlap-save:
// save last input samples for next filtering
//memmove(&pFiltStat->pQBuffer[0], &pFiltStat->pQBuffer[bufsize-RRCLEN-1], (RRCLEN-1)*sizeof(float));
for(i=0;i<(RRCLEN-1);i++)
{
pFiltStat->pQBuffer[i] = pFiltStat->pQBuffer[bufsize-RRCLEN-1+i];
}
}
/****************************************************************************
Function : UpConvert()
****************************************************************************
Description : Upconvert the baseband signal to the first intermediate
frequency.
Inputs : pointer to the complex buffer for channel 1
pointer to the complex buffer for channel 2
pointer to the DMA (ping pong) buffer for the output data
buffersize of output buffer
time index (to ensure continuous cos & sin functions)
Outputs : -
By : 2005-04-19 Adrian Schumacher
****************************************************************************/
void UpConvert(typCOM_fCPLXBUFF *pInBuffer1, typCOM_fCPLXBUFF *pInBuffer2,
Int16 *restrict pOutBuffer, const unsigned int bufsize, unsigned int *uTimeIndex)
{
unsigned int n = *uTimeIndex;
unsigned int i, cnt;
float fcosf, fsinf;
cnt = 0;
for(i=0;i<(bufsize>>1);i++)
{
fcosf = cosf(PHASEINC*n);
fsinf = sinf(PHASEINC*n);
pOutBuffer[cnt++] = (Int16)(pInBuffer1->pIBuffer[i] * fcosf - pInBuffer1->pQBuffer[i] * fsinf);
pOutBuffer[cnt++] = (Int16)(pInBuffer2->pIBuffer[i] * fcosf - pInBuffer2->pQBuffer[i] * fsinf);
n = (++n >= TIDXMOD ? 0 : n);
}
*uTimeIndex = n;
}
/*=== End of global functions definition ===================================*/
/*--- AUTOMATICALLY GENERATED VERSION HISTORY --------------------------------
$Log: /MIMO/Transmitter/txfunctions.c $
*
* 6 05-05-27 10:34 Adrian
* aligned the filter coefficients
*
* 5 05-05-26 11:58 Adrian
* changed initOverhead so that the trainingsequence is now also written
* to the Q part
*
* 4 05-05-20 18:30 Adrian
* removed the memset to clear the buffers in createPilot() since it will
* be done in rxmain.c
*
* 3 05-05-20 12:02 Adrian
* clear the output buffers in the function createPilot() before the pilot
* sequence
*
* 2 05-05-20 9:14 Adrian
* replaced the number 10 with NOOFINFOBYTES (defined in commondef.h, also
* used in rxfunctions.c)
*
* 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 + -