📄 rxswitchmgr.c
字号:
/*****************************************************************************
Module : Switch Manager
******************************************************************************
Function :
Procedures : none
Author : $Author: Jinfeng $
Revision : $Revision: 15 $
Modified : $Modtime: 05-05-29 22:34 $
File : $Workfile: rxswitchmgr.c $
******************************************************************************
KTH, Royal Institute of Technology, S3, Stockholm
*****************************************************************************/
/*--- Include files --------------------------------------------------------*/
/* import */
/* export */
#include "rxswitchmgr.h"
/*=== End of include files =================================================*/
/*--- Global variables definition ------------------------------------------*/
typRX_SWITCHSTATE SwitchState;
extern float pH_pre_r[4][2];
extern float pH_pre_i[4][2];//introduced from rxchannelest.c
extern float Sig_Nois_Ratio; //introduced from rxfunctions.c
//extern float Sig_Nois_dB;//not convinent to use in dB
/*=== End of global variables definition ===================================*/
/*--- Global constants definition ------------------------------------------*/
/*=== End of global constants definition ===================================*/
/*--- Local defines --------------------------------------------------------*/
#define RECTLEN 4 // number of samples for half a period for the rectangular
#define CHANNEL1 0 //channel 1 = switch 1
#define CHANNEL2 1 //channel 2 = switch 2
/*=== End of local defines =================================================*/
/*--- Local types declaration ----------------------------------------------*/
/*=== End of local types declaration =======================================*/
/*--- Local variables definition -------------------------------------------*/
const char Delta_S_Setr[2][DELTA_S_SET_LEN] = {
{-6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6,
-6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6,
-6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6,
-6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6,
-6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6,
-6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6,
-6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6,
-6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6,
-6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6,
-6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6,
-6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6,
-6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6,
-4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4,
-4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4,
-4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4,
-4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4,
-4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4,
-2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
-2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
-2, -2, -2, -2, -2, -2, -2, -2, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2,
4, 4, 6, 6
},
{6, -6, -6, -6, -6, -6, -6, -6, -4, -4, -4, -4, -4, -4, -4, -2, -2, -2, -2, -2,
-2, -2, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 4, 4, 4, 4, 4,
4, 4, 6, 6, 6, 6, 6, 6, -6, -6, -6, -6, -6, -6, -4, -4, -4, -4, -4, -4,
-2, -2, -2, -2, -2, -2, -2, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2,
4, 4, 4, 4, 4, 4, 6, 6, 6, 6, 6, 6, -6, -6, -6, -6, -6, -6, -4, -4,
-4, -4, -4, -4, -2, -2, -2, -2, -2, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2,
4, 4, 4, 4, 4, 4, 6, 6, 6, 6, 6, 6, -6, -6, -6, -6, -6, -6, -4, -4,
-4, -4, -2, -2, 2, 2, 4, 4, 4, 4, 6, 6, 6, 6, 6, 6, -6, -6, -6, -6,
-6, -6, -4, -4, -4, -4, -4, -4, -2, -2, -2, -2, -2, 0, 0, 0, 0, 0, 0, 2,
2, 2, 2, 2, 4, 4, 4, 4, 4, 4, 6, 6, 6, 6, 6, 6, -6, -6, -6, -6,
-6, -6, -4, -4, -4, -4, -4, -4, -2, -2, -2, -2, -2, -2, -2, 0, 0, 0, 0, 0,
0, 2, 2, 2, 2, 2, 2, 2, 4, 4, 4, 4, 4, 4, 6, 6, 6, 6, 6, 6,
-6, -6, -6, -6, -6, -6, -6, -4, -4, -4, -4, -2, -2, -2, -2, -2, -2, -2, 0, 0,
0, 0, 2, 2, 2, 2, 2, 2, 2, 4, 4, 4, 4, 6, 6, 6, 6, 6, 6, 6,
-6, -6, -6, -6, -6, -4, -4, -4, -4, -2, 2, 4, 4, 4, 4, 6, 6, 6, 6, 6,
-6, -6, -6, -6, -6, -6, -4, -4, -2, -2, 2, 2, 4, 4, 6, 6, 6, 6, 6, 6,
-6, -6, -6, -6, -6, -4, -4, -4, -4, -2, 2, 4, 4, 4, 4, 6, 6, 6, 6, 6,
-6, -6, -6, -6, -6, -6, -4, -4, -4, -4, -2, -2, 2, 2, 4, 4, 4, 4, 6, 6,
6, 6, 6, 6, -6, -6, -6, -6, -6, -6, -4, -4, -4, -4, -2, -2, 2, 2, 4, 4,
4, 4, 6, 6, 6, 6, 6, 6, 2, 2, 2, 2, 4, 4, 6, 6, 0, 0, 0, 0,
0, 0, 0, 0
}
}; //real part of the delta S
const char Delta_S_Seti[2][DELTA_S_SET_LEN] = {
{-6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6,
-6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6, -6,
-6, -6, -6, -6, -6, -6, -6, -6, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4,
-4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4,
-4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -2, -2, -2, -2, -2, -2, -2, -2,
-2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
-2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
-4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4,
-4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4,
-2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
-2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
-2, -2, -2, -2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 4, 6,
2, 6, 2, 4
},
{6, -6, -4, -2, 0, 2, 4, 6, -6, -4, -2, 0, 2, 4, 6, -6, -4, -2, 0, 2,
4, 6, -6, -4, -2, 2, 4, 6, -6, -4, -2, 0, 2, 4, 6, -6, -4, -2, 0, 2,
4, 6, -6, -4, -2, 0, 2, 4, -6, -2, 0, 2, 4, 6, -6, -4, -2, 0, 2, 4,
-6, -4, -2, 0, 2, 4, 6, -6, -4, -2, 2, 4, 6, -6, -4, -2, 0, 2, 4, 6,
-4, -2, 0, 2, 4, 6, -6, -4, -2, 0, 2, 6, -6, -4, 0, 2, 4, 6, -6, -4,
-2, 0, 4, 6, -6, -2, 0, 2, 4, -6, -4, -2, 2, 4, 6, -4, -2, 0, 2, 6,
-6, -4, 0, 2, 4, 6, -6, -4, -2, 0, 4, 6, -6, -4, -2, 2, 4, 6, -6, -4,
4, 6, -6, 6, -6, 6, -6, -4, 4, 6, -6, -4, -2, 2, 4, 6, -6, -4, -2, 0,
4, 6, -6, -4, 0, 2, 4, 6, -4, -2, 0, 2, 6, -6, -4, -2, 2, 4, 6, -6,
-2, 0, 2, 4, -6, -4, -2, 0, 4, 6, -6, -4, 0, 2, 4, 6, -6, -4, -2, 0,
2, 6, -4, -2, 0, 2, 4, 6, -6, -4, -2, 0, 2, 4, 6, -6, -4, -2, 2, 4,
6, -6, -4, -2, 0, 2, 4, 6, -6, -4, -2, 0, 2, 4, -6, -2, 0, 2, 4, 6,
-6, -4, -2, 0, 2, 4, 6, -6, -2, 2, 6, -6, -4, -2, 0, 2, 4, 6, -6, -2,
2, 6, -6, -4, -2, 0, 2, 4, 6, -6, -2, 2, 6, -6, -4, -2, 0, 2, 4, 6,
-6, -4, -2, 4, 6, -6, -4, 4, 6, 6, -6, -6, -4, 4, 6, -6, -4, 2, 4, 6,
-6, -4, -2, 2, 4, 6, -6, 6, -6, 6, -6, 6, -6, 6, -6, -4, -2, 2, 4, 6,
-6, -4, 2, 4, 6, -6, -4, 4, 6, -6, 6, -6, -4, 4, 6, -6, -4, -2, 4, 6,
-6, -4, -2, 2, 4, 6, -6, -4, 4, 6, -6, 6, -6, 6, -6, -4, 4, 6, -6, -4,
-2, 2, 4, 6, -6, -4, -2, 2, 4, 6, -6, -4, 4, 6, -6, 6, -6, 6, -6, -4,
4, 6, -6, -4, -2, 2, 4, 6, 0, 2, 4, 6, 2, 6, 2, 4, 0, 0, 0, 0,
0, 0, 0, 0
}
}; //imaginary part of the delta S
/*=== End of local variables definition ====================================*/
/*--- Local constants definition -------------------------------------------*/
/*=== End of local constants definition ====================================*/
/*--- Local functions definition -------------------------------------------*/
/****************************************************************************
Function : create_rect
****************************************************************************
Description : creates a rectangular signal in order to control the switch
Inputs : pointer to the output buffer
length of the output buffer (two interleaved channels)
start index for the chosen channel
stop index for the chosen channel
channel to modify
Outputs : -
By : 2005-05-10 Adrian Schumacher, created
2005-05-13 Adrian Schumacher, changed interface
****************************************************************************/
static void create_rect(Int16 *pOutBuff, const unsigned int uiBuffSize,
const unsigned int uiStartIdx, const unsigned int uiStopIdx,
const char ChIdx)
{
unsigned int n, maxn;
unsigned int k;
Int16 sign;
k = 0;
sign = 1;
n = uiStartIdx;
maxn = (uiStopIdx < uiBuffSize/2 ? uiStopIdx : uiBuffSize/2);
if (ChIdx == CHANNEL1)
{
// channel 1
while (n < maxn)
{
pOutBuff[n*2] = sign*3*QAMSCALING;
if (k++ >= RECTLEN-1)
{
k = 0;
sign = -sign;
}
n++;
}
}
else if (ChIdx == CHANNEL2)
{
// channel 2
while (n < maxn)
{
pOutBuff[n*2+1] = sign*3*QAMSCALING;
if (k++ >= RECTLEN-1)
{
k = 0;
sign = -sign;
}
n++;
}
}
}
/****************************************************************************
Function : set_switches
****************************************************************************
Description : Controls and sets the output buffer in order to have the
required switch positions
Inputs : pointer to the output buffer
length of one channel in the output buffer
pointer to the structure containing the switch states
Outputs : -
By : 2005-05-12 Adrian Schumacher
****************************************************************************/
static void set_switches(Int16 *pOutBuff, const unsigned int uiBuffLen,
typRX_SWITCHSTATE *pSwitchState)
{
unsigned int uiStart, uiStop;
int iBuffLen = (int)uiBuffLen;
unsigned int uiBuffSize = uiBuffLen*2;
int iPos1Sw1 = pSwitchState->iPos1Sw1;
int iPos1Sw2 = pSwitchState->iPos1Sw2;
int iPos2Sw1 = pSwitchState->iPos2Sw1;
int iPos2Sw2 = pSwitchState->iPos2Sw2;
/* 4 cases: (current buffer ---, next buffer ..., changes 1/2)
case a: ------.1..2.
case b: ----1-.2....
case c: -1--2-......
case d: -2----....1.
*/
uiStart = uiStop = 0;
// clear buffer
memset(pOutBuff,0,uiBuffLen*2*sizeof(Int16));
// tests for switch 1
if ((iPos1Sw1 > iBuffLen-1) && (iPos2Sw1 > iBuffLen-1))
{ // case a
// no changes, keep the old positions over the whole buffer
uiStart = 0;
if (pSwitchState->uiPosSwitch1 == eSWITCH1)
uiStop = uiStart;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -