/*******************************************************************/
/*******************************************************************/
/* This program implements the function of finding out the largest */
/* and the second largest values of the sequence of "in_buffer[10]"*/
/*******************************************************************/
/*******************************************************************/
/**********************************************************/
/** 几句废话,消除warning:data_max was set but never used **/
data_max=data_max+0;
data_max2=data_max2+0;
// i_max=i_max+0;
// i_max2=i_max2+0;
f_max=f_max+0;
f_max2=f_max2+0;
/**********************************************************/
dataIN(); /* read data into memory */
/************************************************/
/** find out the greatest value of "in_buffer" **/
for(i=0;i<=POINT_ALL-2;i++)
{
if (in_buffer[i+1]>in_buffer[i])
{data_max=in_buffer[i+1]; i_max=i+1;}
else {data_max=in_buffer[i]; i_max=i;}
}
f_max=FS*i_max/POINT_ALL; /* calculate the value of carrier frequency */
/*****************************************************/
/* find out the second greatest value of "in_buffer" */
in_buffer[i_max]=0; /* set 0 to "in_buffer[i_max]"*/
for(p=1;p<=POINT_ALL/2;p++)
{
for(q=0;q<=POINT_ALL/2-2;q++)
{
if (in_buffer[q+1]>in_buffer[q])
{data_max2=in_buffer[q+1]; i_max2=q+1;}
else {data_max2=in_buffer[q]; i_max2=q;}
}
/* determines the availability of i_max2 through
estimating the distance of i_max between i_max2 */
if (abs(i_max-i_max2)<=GAP) in_buffer[i_max2]=0;
else break;
}
f_max2=FS*i_max2/POINT_ALL; /* calculate the value of carrier frequency2 */