short Max11046DataAvr(int16 data[],uint8 length,uint16 zero_channel)
{
uint8 i,j,len;
short temp_val,min_index;
int32 sum_val;
int16 AD_val;
int16 data_tmp[SAMP_COUNT_ALL]; //120
len = length;
for (i=0; i<len; i++)
{
data_tmp = data;
}
for (i=0; i<len-1; i++)
{
min_index = i;
for (j=i+1; j<len; j++)
{
if (data_tmp[j]<data_tmp[min_index])
{
min_index = j;
}
}
if(min_index != i)
{
temp_val = data_tmp;
data_tmp = data_tmp[min_index];
data_tmp[min_index] = temp_val;
}
}
sum_val = 0;
for (i=(len-COUNTSAMPINDEX)/2; i<(len+COUNTSAMPINDEX)/2; i++)
{
if (data_tmp>=zero_channel)
{
data_tmp = data_tmp - zero_channel;
sum_val += data_tmp;
}
else
{
data_tmp = zero_channel - data_tmp;
sum_val -= data_tmp;
}
}
AD_val = sum_val / COUNTSAMPINDEX;
return AD_val;
}
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
谢谢,还是看不懂这个程序的意思
一周热门 更多>