EasyManua.ls Logo

Kipor KP310V1.0 - Appendix 2 CRC16-CCITT

Kipor KP310V1.0
36 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
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;
}