/*g(x)=x8+x5+x4+1 100110001 数据反转LSB first*/
unsigned char calcrc_1byte(unsigned char abyte)
{
unsigned char i,crc_1byte;
crc_1byte=0; /*设定crc_1byte初值为0*/
for(i = 0; i < 8; i++)
{
if(((crc_1byte^abyte)&0x01))
{
crc_1byte^=0x18;
crc_1byte>>=1;
crc_1byte|=0x80;
}
else
crc_1byte>>=1;
abyte>>=1;
}
return crc_1byte;
}
|