hcs.c

来自「基于wimax中ofdm在vxworks的仿真代码」· C语言 代码 · 共 43 行

C
43
字号
/*****************************************************************************//*   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<datain.size;ii++) { //for        for (jj=0;jj<8;jj++) { //for          tmp1 =  (datain.data[ 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

⌨️ 快捷键说明

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