#define CRC_POLY 0x8408
unsigned int cal_crc(unsigned char *ptr, unsigned int len)
{
unsigned int crc=0xffff;
unsigned char i;
while(len--)
{
crc^=*ptr++;
for(i=0;i<8;i++)
{
If (crc&0x0001)
{
crc >>= 1;
crc^= CRC_POLY;
}
else
{
crc >>= 1;
}
}
}
crc ^= 0xffff;
return crc;
}