English
Language : 

AT42QT1244_14 Datasheet, PDF (54/61 Pages) ATMEL Corporation – 24-key QMatrix FMEA IEC/EN/UL60730 Touch Sensor
Appendix B. 16-bit CRC Software C Algorithm
// 16 bits crc calculation. Initial crc entry value must be 0.
// The message is not augmented with 'zero' bits.
// polynomial = X16 + X15 + X2 + 1
// data is an 8 bit number, unsigned
// crc is a 16 bit number, unsigned
// repeat this function for each data block byte, folding the result
// back into the call parameter crc
unsigned long sixteen_bit_crc(unsigned long crc, unsigned char data)
{
unsigned char index;// shift counter
crc ^= (unsigned long)(data) << 8;
index = 8;
do
{
if(crc & 0x8000)
{
crc= (crc << 1) ^ 0x1021;
}
else
{
crc= crc << 1;
}
} while(--index);
return crc;
}
// loop 8 times
A CRC calculator for Windows® is available free of charge from Atmel.
QT1244 [PRELIMINARY DATASHEET]
54
9631EX–AT42–12/13