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


/*****************************************************************************/
/*   FIle Name : hcs.c                                                       */
/*   Description : WiMax OFDM HCS CRC8 Encoder                               */
/*           S(x) = x^8 + x^2 + x + 1                                        */
/*   author : miffie                                                         */
/*   Date   : Nov/02/05                                                      */
/*   Copyright (c) 2005 miffie   All rights reserved.                        */
/*****************************************************************************/
///////////////////////////////////////////////////////////////////////////////

struct 	binaryset hcs(struct binaryset datain ) { // 
struct  binaryset bcrc ;
char	shifter ;
char  	*btmp1  ;
char	tmp1 ;
int	ii , jj ;


  //Make LONG PLCP Preamble 
    if ((btmp1 = (char *)malloc(1*sizeof(char))) == NULL) {
        PRINTF( " malloc failed in hcs\n") ;
    } //fail
    else { //allocated
      PRINTF(" hcs size=0x%x\n", datain.size ) ;
      shifter = 0x00 ;
      for (ii=0;ii>(7-jj)) &0x1 ;
          tmp1 = ((shifter &0x80) >> 7) ^ tmp1 ;
          shifter = (tmp1) ? shifter ^ 0x03 : shifter ;
          shifter = (shifter<<1) + tmp1 ;
          //printf("crc8 shifter=%x\n" , shifter ) ;
        } //for
      } //for
      bcrc.format = 1 ;
      bcrc.data = btmp1 ;
      bcrc.size = 1 ;
      btmp1[ 0 ] =  shifter  ;
    } //allocated

    return( bcrc ) ;
} //hcs