📄 chcomp.cpp
字号:
#include "typedef.h"
#include "chcomp.h"
void chComp(Int16 *pChCompIn,
Uint16 chCompLength,
PhaseParam *pPhaseShift,
ChannelEstResult *pPreambleChEstRes,
Int16 *pChCompOut)
{
Int16 i;
Int16 freqOffsetCoarse;
double freqOffsetFine;
Int16 symbolCompIn[402];
Int16 symbolCompFirst[402];
Int16 symbolCompSecond[402];
Int16 sinValue;
Int16 cosValue;
Int16 modChannel;
Int16 compTap[2];
Int16 modWidth = 11;//(averagebitwidth-1)
Int16 bitWidth = 10;
Int16 shiftFixPhrase = 14;
Int16 shiftFreOffset = 15; // (16-1) mod of sine;
//for test only
for (i = 0; i < chCompLength - 55; i++)
{
pChCompOut[2*i] = pChCompIn[2*i+56];
pChCompOut[2*i+1] = pChCompIn[2*i+57];
}
/*
for (i = 0; i < chCompLength - 55; i++)
{
symbolCompIn[2*i] = pChCompIn[2*i+56];
symbolCompIn[2*i+1] = pChCompIn[2*i+57];
}
for (i = 0; i < PREAMBLE_FREQ_FULL_SIZE; i++)
{
if (i == 100)
{
compTap[0] = 0;
compTap[1] = 0;
}
else
{
modChannel = (pPreambleChEstRes[0].ChEstOut[2*i] * pPreambleChEstRes[0].ChEstOut[2*i]
+ pPreambleChEstRes[0].ChEstOut[2*i+1] * pPreambleChEstRes[0].ChEstOut[2*i+1])
>> modWidth;
compTap[0] = (pPreambleChEstRes[0].ChEstOut[2*i] << modWidth) / modChannel ;
compTap[1] = (pPreambleChEstRes[0].ChEstOut[2*i+1] << modWidth) / modChannel ;
}
pChCompOut[2*i] = (Int16)(((Int32)symbolCompIn[2*i] * compTap[0]
+ (Int32)symbolCompIn[2*i+1] * compTap[1]) >> bitWidth);
pChCompOut[2*i+1] = (Int16)(((Int32)symbolCompIn[2*i+1] * compTap[0]
- (Int32)symbolCompIn[2*i] * compTap[1]) >> bitWidth);
}
*/
//去处信道响应
/*
for (i = 0; i < PREAMBLE_FREQ_FULL_SIZE; i++)
{
symbolCompSecond[2*i] = (Int16)(((Int32)symbolCompFirst[2*i] * pPhaseShift[0].fixedPhase[0]
+ (Int32)symbolCompFirst[2*i+1] * pPhaseShift[0].fixedPhase[1])
>> shiftFixPhrase);
symbolCompSecond[2*i+1] = (Int16)(((Int32)symbolCompFirst[2*i+1] * pPhaseShift[0].fixedPhase[0]
- (Int32)symbolCompFirst[2*i] * pPhaseShift[0].fixedPhase[1])
>> shiftFixPhrase);
}
for (i = 0; i < PREAMBLE_FREQ_FULL_SIZE; i++)
{
pChCompOut[2*i] = symbolCompSecond[2*i];
pChCompOut[2*i+1] = symbolCompSecond[2*i+1];
}
*/
/*
for (i = 0; i < PREAMBLE_FREQ_FULL_SIZE/2; i++)
{
freqOffsetCoarse = pPhaseShift[0].freqIq * (100 - i) * 256 / (32767 * PI);
freqOffsetFine = pPhaseShift[0].freqIq * (100-i) * 256 / (32767 * PI);
if (freqOffsetCoarse == 0)
{
sinValue = freqOffsetFine * 32767 * PI / 256;
cosValue = 32767 - ((sinValue * sinValue) >> 16);//cosx=1-0.5*x^2
}
else
{
sinValue = (Int16)(g_sineTable[freqOffsetCoarse]
+ (freqOffsetFine - freqOffsetCoarse) * g_sineTable[128-freqOffsetCoarse]);
cosValue = (Int16)(g_sineTable[128-freqOffsetCoarse]
- (freqOffsetFine - freqOffsetCoarse) * g_sineTable[freqOffsetCoarse]);
}
pChCompOut[2*i] = (Int16)(((Int32)symbolCompSecond[2*i] * cosValue
- (Int32)symbolCompSecond[2*i+1] * sinValue)
>> shiftFreOffset);
pChCompOut[2*i+1] = (Int16)(((Int32)symbolCompSecond[2*i+1] * cosValue
+ (Int32)symbolCompSecond[2*i] * sinValue)
>> shiftFreOffset);
pChCompOut[2*(200-i)] = (Int16)(((Int32)symbolCompSecond[2*(200-i)] * cosValue
+ (Int32)symbolCompSecond[2*(200-i)+1] * sinValue)
>> shiftFreOffset);
pChCompOut[2*(200-i)+1] = (Int16)(((Int32)symbolCompSecond[2*(200-i)+1] * cosValue
- (Int32)symbolCompSecond[2*(200-i)] * sinValue)
>> shiftFreOffset);
}
//去处信道的角偏移.
pChCompOut[200] = symbolCompSecond[200];
pChCompOut[201] = symbolCompSecond[201];
*/
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -