📄 txfunctions.c
字号:
/*****************************************************************************
Module : External Functions
******************************************************************************
Function : External Functions used by the transmitter.
Procedures : createStartFrame()
initOverhead()
qamMapping()
upsampPulseShape()
UpConvert()
Old History: 2005-04-19 AS created
2005-04-27 AS version 0.2
Author : $Author: Adrian $
Revision : $Revision: 6 $
Modified : $Modtime: 05-05-27 8:45 $
File : $Workfile: txfunctions.c $
******************************************************************************
KTH, Royal Institute of Technology, S3, Stockholm
*****************************************************************************/
/*--- Include files --------------------------------------------------------*/
/* import */
#include <math.h>
#include <csl_stdinc.h>
#include <dspf_sp_fir_gen.h>
#include <dspf_sp_blk_move.h>
#include "../common/commondef.h"
#include "../common/crc16.h"
#include "txmain.h"
/* export */
#include "txfunctions.h"
/*=== End of include files =================================================*/
/*--- Global variables definition ------------------------------------------*/
/*=== End of global variables definition ===================================*/
/*--- Global constants definition ------------------------------------------*/
/* Gray mapping:
0010 0110 1110 1010
2 6 14 10
0011 0111 1111 1011
3 7 15 11
0001 0101 1101 1001
1 5 13 9
0000 0100 1100 1000
0 4 12 8
*/
const Int16 c16QAM_I[16]={-3,-3,-3,-3,-1,-1,-1,-1, 3, 3, 3, 3, 1, 1, 1, 1};
const Int16 c16QAM_Q[16]={-3,-1, 3, 1,-3,-1, 3, 1,-3,-1, 3, 1,-3,-1, 3, 1};
/*=== End of global constants definition ===================================*/
/*--- Local defines --------------------------------------------------------*/
#define PHASEINC (2.0f*PI*((float)INTERFREQ/SAMPFREQ))
#define TIDXMOD ((10*SAMPFREQ)/INTERFREQ)
/*=== End of local defines =================================================*/
/*--- Local types declaration ----------------------------------------------*/
/*=== End of local types declaration =======================================*/
/*--- Local variables definition -------------------------------------------*/
extern const Int16 TRAININGSEQ[2][TRAINLEN];
extern const Int16 SYNCSEQUENCE_I[SYNCLEN];
extern const Int16 SYNCSEQUENCE_Q[SYNCLEN];
extern const Int16 GUARDSYMB[GUARDSYMBOLS];
#pragma DATA_ALIGN(respoly,32);
static float respoly[10][FRAMESYMBLENGTH];
// RRCLEN is defined in "../common/commondef.h"
#pragma DATA_ALIGN(rrc0,8);
static const float rrc0[RRCLEN]={
1.682437309784e-04f, -3.475706109604e-03f, 8.560998439072e-03f, -1.552379037950e-02f, 2.510971402739e-02f,
-4.292696016243e-02f, 3.288960816721e-01f, 1.516744324445e-02f, 2.763018660282e-03f, -6.530498290477e-03f,
6.270281420428e-03f, -4.403363320430e-03f, 2.149553981274e-03f, -2.500815923207e-04f
};
#pragma DATA_ALIGN(rrc1,8);
static const float rrc1[RRCLEN]={
-8.929988748545e-04f, -2.260941528883e-03f, 7.915673205096e-03f, -1.674415963467e-02f, 3.057277541973e-02f,
-5.867256335808e-02f, 3.103185589064e-01f, 5.564860708042e-02f, -1.253335896622e-02f, 6.827876599095e-04f,
3.311193660683e-03f, -3.833444411629e-03f, 2.744859693484e-03f, -1.174377707284e-03f
};
#pragma DATA_ALIGN(rrc2,8);
static const float rrc2[RRCLEN]={
-1.786690067082e-03f, -8.290255140403e-04f, 6.337474753516e-03f, -1.587012564507e-02f, 3.197654640544e-02f,
-6.554982151897e-02f, 2.808025543624e-01f, 1.013221966660e-01f, -2.876700524936e-02f, 8.873440131166e-03f,
-5.875735794527e-04f, -2.535570364449e-03f, 2.907676424505e-03f, -1.951213872302e-03f
};
#pragma DATA_ALIGN(rrc3,8);
static const float rrc3[RRCLEN]={
-2.387521244848e-03f, 5.866477955410e-04f, 4.148406382298e-03f, -1.326317299913e-02f, 2.968828760708e-02f,
-6.441869232707e-02f, 2.423875467836e-01f, 1.496390292044e-01f, -4.414351803653e-02f, 1.713318251174e-02f,
-5.017824016041e-03f, -6.159323511204e-04f, 2.579950705884e-03f, -2.461185360790e-03f
};
#pragma DATA_ALIGN(rrc4,8);
static const float rrc4[RRCLEN]={
-2.618921108680e-03f, 1.776090728264e-03f, 1.712337061363e-03f, -9.444696653980e-03f, 2.442381052974e-02f,
-5.668707693111e-02f, 1.976809832637e-01f, 1.976809832637e-01f, -5.668707693111e-02f, 2.442381052974e-02f,
-9.444696653980e-03f, 1.712337061363e-03f, 1.776090728264e-03f, -2.618921108680e-03f
};
#pragma DATA_ALIGN(rrc5,8);
static const float rrc5[RRCLEN]={
-2.461185360790e-03f, 2.579950705884e-03f, -6.159323511204e-04f, -5.017824016041e-03f, 1.713318251174e-02f,
-4.414351803653e-02f, 1.496390292044e-01f, 2.423875467836e-01f, -6.441869232707e-02f, 2.968828760708e-02f,
-1.326317299913e-02f, 4.148406382298e-03f, 5.866477955410e-04f, -2.387521244848e-03f
};
#pragma DATA_ALIGN(rrc6,8);
static const float rrc6[RRCLEN]={
-1.951213872302e-03f, 2.907676424505e-03f, -2.535570364449e-03f, -5.875735794527e-04f, 8.873440131166e-03f,
-2.876700524936e-02f, 1.013221966660e-01f, 2.808025543624e-01f, -6.554982151897e-02f, 3.197654640544e-02f,
-1.587012564507e-02f, 6.337474753516e-03f, -8.290255140403e-04f, -1.786690067082e-03f
};
#pragma DATA_ALIGN(rrc7,8);
static const float rrc7[RRCLEN]={
-1.174377707284e-03f, 2.744859693484e-03f, -3.833444411629e-03f, 3.311193660683e-03f, 6.827876599095e-04f,
-1.253335896622e-02f, 5.564860708042e-02f, 3.103185589064e-01f, -5.867256335808e-02f, 3.057277541973e-02f,
-1.674415963467e-02f, 7.915673205096e-03f, -2.260941528883e-03f, -8.929988748545e-04f
};
#pragma DATA_ALIGN(rrc8,8);
static const float rrc8[RRCLEN]={
-2.500815923207e-04f, 2.149553981274e-03f, -4.403363320430e-03f, 6.270281420428e-03f, -6.530498290477e-03f,
2.763018660282e-03f, 1.516744324445e-02f, 3.288960816721e-01f, -4.292696016243e-02f, 2.510971402739e-02f,
-1.552379037950e-02f, 8.560998439072e-03f, -3.475706109604e-03f, 1.682437309784e-04f
};
#pragma DATA_ALIGN(rrc9,8);
static const float rrc9[RRCLEN]={
6.866400968881e-04f, 1.238854869175e-03f, -4.249618490782e-03f, 8.043858422023e-03f, -1.207384207562e-02f,
1.565580495773e-02f, -1.812729001269e-02f, 3.352370707970e-01f, -1.812729001269e-02f, 1.565580495773e-02f,
-1.207384207562e-02f, 8.043858422023e-03f, -4.249618490782e-03f, 1.238854869175e-03f
};
/*=== End of local variables definition ====================================*/
/*--- Local constants definition -------------------------------------------*/
/*=== End of local constants definition ====================================*/
/*--- Local functions definition -------------------------------------------*/
/*=== End of local functions definition ====================================*/
/*--- Global functions definition ------------------------------------------*/
/****************************************************************************
Function : createStartFrame()
****************************************************************************
Description : Fill the data buffer with the data to send in the first
frame.
Inputs : pointer to the data buffer
buffersize
transmitter states (information to send)
Outputs : -
By : 2005-04-19 Adrian Schumacher
****************************************************************************/
void createStartFrame(Uint8 *pDataBuffer, const unsigned int bufsize,
typTX_TRANSMITSTATE *pTxStates)
{
int i, offset;
Uint16 tmp16;
int tmp32;
// clear frame
memset(pDataBuffer, 0, bufsize);
offset = 0;
// write the information to the frame
tmp32 = pTxStates->iSyncRep; // 1 byte
pDataBuffer[offset++] = (Uint8)(0x000000FF & tmp32);
tmp32 = pTxStates->TxMethod; // 1 byte
pDataBuffer[offset++] = (Uint8)(0x000000FF & tmp32);
tmp32 = pTxStates->uFileSize; // 4 bytes
pDataBuffer[offset++] = (Uint8)(0x000000FF & (tmp32 >> 24));
pDataBuffer[offset++] = (Uint8)(0x000000FF & (tmp32 >> 16));
pDataBuffer[offset++] = (Uint8)(0x000000FF & (tmp32 >> 8));
pDataBuffer[offset++] = (Uint8)(0x000000FF & tmp32);
tmp32 = pTxStates->uNoOfBlocks; // 4 bytes
pDataBuffer[offset++] = (Uint8)(0x000000FF & (tmp32 >> 24));
pDataBuffer[offset++] = (Uint8)(0x000000FF & (tmp32 >> 16));
pDataBuffer[offset++] = (Uint8)(0x000000FF & (tmp32 >> 8));
pDataBuffer[offset++] = (Uint8)(0x000000FF & tmp32);
// total 1+1+4+4 = 10 bytes to include in the CRC calculation
// -> NOOFINFOBYTES = 10 is declared in commondef.h and also used in rxfunctions.c
tmp16 = calc_crc(pDataBuffer,NOOFINFOBYTES); // 2 bytes
pDataBuffer[offset++] = (Uint8)(0x000000FF & (tmp16 >> 8));
pDataBuffer[offset++] = (Uint8)(0x000000FF & tmp16);
// fill the remaining bytes in the frame with copies of these infos
tmp16 = offset;
tmp32 = bufsize / offset;
for (i=0;i < tmp32-1;i++)
{
memcpy(&pDataBuffer[(i+1)*offset],&pDataBuffer[0],tmp16);
}
}
/****************************************************************************
Function : createPilot()
****************************************************************************
Description : in the buffer.
Inputs : pointer to the ounput buffer
its buffersize
Outputs : start index for the upconversion computations
By : 2005-05-07 Adrian Schumacher
****************************************************************************/
unsigned int createPilot(typCOM_fCPLXBUFF *pInBuffer1, typCOM_fCPLXBUFF *pInBuffer2,
Int16 *restrict pOutBuffer, const unsigned int bufsize)
{
unsigned int idx, n;
// compute start of pilot in buffer
n = bufsize - IFSYNCSAMP;
idx = n/TIDXMOD;
idx = n - idx*TIDXMOD;
idx = TIDXMOD - idx;
for (n=bufsize-IFSYNCSAMP; n < bufsize; n++)
{
pInBuffer1->pIBuffer[n] = 0.0f;
pInBuffer1->pQBuffer[n] = -3.0f*QAMSCALING;
pInBuffer2->pIBuffer[n] = 0.0f;
pInBuffer2->pQBuffer[n] = -3.0f*QAMSCALING;
}
return idx;
}
/****************************************************************************
Function : initOverhead()
****************************************************************************
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -