build_ramp.cpp

来自「这是一个手机校准程序」· C++ 代码 · 共 44 行

CPP
44
字号
// build_ramp.cpp
// n steffen
// 9/16/99
// Copyright Mobilink Telecom 1999
//
// builds a raised-cosine ramp based on min DAC up/down and peak Dac values
//


#include "caltypes.h"
#define RAMP_LENGTH 32


void build_ramp(UInt16 min_up_dac, UInt16 min_down_dac, UInt16 peak_dac, UInt16 ramp[RAMP_LENGTH])
{
static const double CosSquar[17] =
{1.000000,  0.990393,  0.961940,  0.915735,  0.853554,  0.777785,  0.691342,  0.597546,
0.500001,  0.402456,  0.308659,  0.222216,  0.146447,  0.084266,  0.038061,  0.009608, 0};
UInt16 D26_D25;
UInt16 D27_D25;
UInt16 Step;
UInt16 i;
float RampPoint;

D26_D25 = min_up_dac;
D27_D25 = min_down_dac;
		
//Generate one RAMP UP line	
i=0;
for(Step = 1; Step < 17; Step++)
  {
  RampPoint = (float)(peak_dac - D26_D25*CosSquar[Step]);
  ramp[i++]=(UInt16)RampPoint;
  }

//Generate one RAMP DOWN line
for(Step = 1; Step < 17; Step++)
  {
  RampPoint = (float)(peak_dac - D27_D25*(1 - CosSquar[Step]));
  ramp[i++]=(UInt16)RampPoint;
  }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?