发表于:2005-09-21 11:31:00
1楼
可以参考c语言的来编写:
//CRC check create
unsigned char * data; //ptr of data buffer
unsigned char length; //length of data
unsigned int crc_check(unsigned char * data, unsigned char length)
{
int i;
unsigned int reg_crc=0xffff;
while(length--)
{
reg_crc^=*data++;
for(i=0;i<8;i++)
{
if(reg_crc & 0x01) // LSB(bit0=1)
{
reg_crc=(reg_crc>>1)^0xa001;
}
else
{
reg_crc=reg_crc>>1;
}
}
}
return reg_crc;
}