beautypg.com

PNI CompassPoint Prime User Manual

Page 57

background image

Prime User Manual r08

Page 51

// Update the CRC for transmitted and received data using

// the CCITT 16bit algorithm (X^16 + X^12 + X^5 + 1).

UInt16 crc = 0;

while(len--)

{

crc = (unsigned char)(crc >> 8) | (crc << 8);

crc ^= dataPtr[index++];

crc ^= (unsigned char)(crc & 0xff) >> 4;

crc ^= (crc << 8) << 4;

crc ^= ((crc & 0xff) << 4) << 1;

}

return crc;

}