KP310V1.0 Controller Operation Manual
- 30 -
Appendix 2 CRC16-CCITT
/*******************************************************************
Function:
generate CRC16CCITT code
Input:
p
= mouse cursor points to first byte
DataLen
=data
length
Output: CRC16CCITT
*******************************************************************/
Unsigned int CRC16CCITT (unsigned char *p, unsigned int DataLen)
{
Unsigned int crc16=0;
Unsigned int i;
Unsigned char b;
for (i=0;i<DataLen;i++)
{
b=(unsigned char)(crc16>>8);
crc16<<=8;
crc16^= CRC16CCITT [b^*p];
p++;
}
return crc16;
}