⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 detect_pre.c

📁 This model is just testing an idea of MIMO, which IEEE802.11n will have. But I havo not seen the s
💻 C
字号:
/*****************************************************************************//*   FIle Name : detect_pre.c                                                *//*   Description : WLAN detection of preamble                                *//*   author : miffie                                                         *//*   Date   : aug/18/05                                                      *//*   Copyright (c) 2005 miffie   All rights reserved.                        *//*****************************************************************************////////////////////////////////////////////////////////////////////////////////int detect_pre( struct complexset datain ) { // double  radius ;double  maxr, minr ;double  peak_radius ;double  bottom_radius ;double  accum_radius, accum_diff ;struct	complex tmp1 , tmp2 ;struct	complexset cset ;short   octet_cnt ;short   minimum_position ;int     RADIUS_THRESHOLD = 0.25 ;int	ii , jj ;int     detection ;double  drift_phase, drift_amount ; //Main   PRINTF("detect_pre size=%d \n", datain.size ) ;  //detect short sequence  ii=16 ;  detection = datain.size +1 ;  octet_cnt=0 ;  drift_phase=0 ;  drift_amount=0 ;  while(ii< (datain.size-16) ) { //loop    accum_radius=0 ;    peak_radius=0 ;    accum_diff=0 ;    accum_radius=0 ;    bottom_radius=1 ;    minimum_position=1 ;    cset = extract_complexset(datain , ii-16 , 24 ) ; //Short sequence    for(jj=0;jj<8;jj++) { //each sample      //calculate radius      tmp1 = cordic( datain.data[ii+jj] ) ;      tmp2 = cordic( datain.data[ii+jj-16] ) ;      radius = tmp1.realp ;      //calculate  difference from one of 16 cycles before      accum_diff += fabs(tmp1.realp-tmp2.realp) ;      accum_radius += radius ;      if ( radius > peak_radius ) peak_radius= radius ;      if ( radius < bottom_radius ) { //smallest           bottom_radius= radius ;           minimum_position = jj ;      } //smallest      //diff_phase = tmp1.image - tmp2.image ;      //cset = phase_drift(cset , &drift_phase , &drift_amount ) ;      //drift_amount =   detect_drift( cset , 16 ) ;      //calculate phase      // Aug/19/05 This idea did not work,       //if ADC phase shifted half cycle(50ns) against transmitter      //phase = fabs(datain.data[ii+jj-1].realp-datain.data[ii+jj+1].image) +      //        fabs(datain.data[ii+jj-1].image-datain.data[ii+jj+1].realp) +      //        fabs(datain.data[ii+jj-2].realp-datain.data[ii+jj+2].image) +      //        fabs(datain.data[ii+jj-2].image-datain.data[ii+jj+2].realp) +      //        fabs(datain.data[ii+jj-3].realp-datain.data[ii+jj+3].image) +      //        fabs(datain.data[ii+jj-3].image-datain.data[ii+jj+3].realp) ;      //PRINTF(" phase (%d) =%6.3f\n", ii+jj , phase ) ;      //if ( bottom_radius > phase ) {//smallest      //    bottom_radius = phase ;      //} //smallest    } //each sample    PRINTF("detect_pre(%d) accum_radius=%6.3f accum_diff=%6.3f octet_cnt=%d\n", ii,                            accum_radius, accum_diff , octet_cnt ) ;    PRINTF("bottom_radius(%d)=%6.3f\n", minimum_position, bottom_radius ) ;    //octet_cnt as count # of octets(8 samples) in short seq    if (((accum_radius/4.0) > accum_diff) & //if accum_diff is small enough        (accum_radius>RADIUS_THRESHOLD)) {  //if accum_radius is big enough        octet_cnt++ ;    } //detected    else { //not detected        if(octet_cnt>4)  { //start of longseq          detection = ii+160-128-8 ;          ii=datain.size ; //exit loop        } //start of longseq        octet_cnt=0 ;    } //not detected        //take peak_radius for AutoGainControl    if (octet_cnt>2) {//short seq detected      ii += 7+minimum_position ;    }//short seq detected    else { //     ii += 8 ;     } //  } //loop  PRINTF("detection =%d\n" , detection ) ;  return( detection ) ;} //detect_pre

⌨️ 快捷键说明

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