Appendix B Communication Protocol
Shenzhen Hpmont Technology Co., Ltd.
- 84
-
HD3N-L Series User Manual V1.0
6.
CRC Checking
The code to calculate the CRC online is as follows:
unsigned int crc_check (unsigned char *data, unsigned char length)
{
int i;
unsigned crc_result=0xffff;
while (length--)
{
crc_result^=*data++;
for (i=0; i<8; i++)
{
If(crc_result&0x01)
crc_result=(crc_result>>1) ^0xa001;
else
crc_result=crc_result>>1;
}
}
return (crc_result=((crc_result&0xff) <<8) | (crc_result>>8) ) ;
}