sd08616

    1. 我推荐一个简单的 unsigned int fcs_calc(unsigned char *pr)  /* CRC16.c */ { unsigned int number_of_databytes;   unsigned int calculate_or_check_crc;   unsigned int i, j;   unsigned int fcs;   number_of_databytes =UsbLength;   calculate_or_check_crc = CALC_CRC;   if(calculate_or_check_crc == CALC_CRC)   { number_of_databytes = UsbLength;  /* 数组长 */   }   else    /* check CRC */   { number_of_databytes = UsbLength + 2;   }   fcs = PRESET_VALUE;   for(i = 1; i < number_of_databytes; i++)   { fcs = fcs ^ ((unsigned int)(pr));     for (j = 0; j < 8; j++)     { if (fcs & 0x0001)       { fcs = (fcs >> 1) ^ POLYNOMIAL;       }       else       { fcs = (fcs >> 1);       }     } /* for j */   } /* for i */   fcs = ~fcs;   return(fcs); } /* fcs_calc */

最近访客

< 1/1 >

统计信息

已有45人来访过

  • 芯积分:--
  • 好友:--
  • 主题:--
  • 回复:1

留言

你需要登录后才可以留言 登录 | 注册


现在还没有留言