www.pudn.com > wimax_ofdm_implementation_code.rar > frameprefix.c


/*****************************************************************************/
/*   FIle Name : frameprefix.c                                               */
/*   Description : Wi-Max OFDM Frame Prefix Encoder                          */
/*   author : miffie                                                         */
/*   Date   : oct/13/05                                                      */
/*   Copyright (c) 2005 miffie   All rights reserved.                        */
/*****************************************************************************/
///////////////////////////////////////////////////////////////////////////////

struct 	binaryset frameprefix( struct DLFP_IE *dlfp ,
                               char BSID, char frame_number) {
struct  binaryset btop ;
char    *btmp1 ;
int	ii , nn ;
//DL
char  	Configuration_Change_Count  ;
//UL
char	Uplink_Channel_ID  ;
int	Allocation_Start_time ;



  //Make LONG PLCP Preamble 
   if ((btmp1 = (char *)malloc(10*sizeof(char))) == NULL) {
       PRINTF( " malloc failed in frameprefix\n") ;
   } //fail
   else { //allocated
      PRINTF("frameprefix\n" ) ;
      ii=0 ;
   //////////////////////////
   //DL-MAP
   //////////////////////////
    //Base_Station_ID
      btmp1[ ii ] = (BSID &0xf) <<4 ;
    //Frame_Number
      btmp1[ ii++ ] += frame_number &0xf ;
    //Configuration_Change_Count
      Configuration_Change_Count = 0xf ;
      btmp1[ ii++ ] = ((Configuration_Change_Count &0xf) <<4) ;

    //DL-MAP IE
      for(nn=0;nn<4;nn++) { //each IE
         if(nn==0) { //first
           //Rate_ID
           btmp1[ ii ] = (dlfp[nn].DIUC &0xf)<<4 ;
           //Preamble_present
           btmp1[ ii ] += (dlfp[nn].Preamble_present &0x1)<<3 ;
           //Length
           btmp1[ ii++ ] += (dlfp[nn].Length>>8) &0x7 ;
           btmp1[ ii++ ] = (dlfp[nn].Length) &0xff ;
         } else { //beyond
           //DIUC
           btmp1[ ii ] = (dlfp[nn].DIUC &0xf)<<4 ;
           if( dlfp[nn].DIUC >0 ) {
             //Preamble_present
             btmp1[ ii ] += (dlfp[nn].Preamble_present &0x1)<<3 ;
             //Length
             btmp1[ ii++ ] += (dlfp[nn].Length>>8)  &0x7 ;
             btmp1[ ii++ ] = (dlfp[nn].Length) &0xff ;
           } else {
             //Start Time
             btmp1[ ii++ ] += (dlfp[nn].Length>>8) &0xf ;
             btmp1[ ii++ ] = (dlfp[nn].Length) &0xff ;
           }
         }//beyond
      } //each IE
      btop.format = 1 ;
      btop.size = ii ;
      btop.data = btmp1 ;
      //HCS
      btop = cat_binaryset ( btop , hcs( btop ) ) ; 
   } //allocated
   return( btop ) ;
} //frameprefix