|
extern __farflash unsigned char CRC16[];
unsigned int modbusCRC16(unsigned char *buff,int size) {
unsigned char bytehi,bytelo;
unsigned int index;
bytehi = bytelo = 0xFF;
while(size--) {
bytehi = bytelo ^ CRC16[(index = bytehi ^ *buff++) + 100];
bytelo = CRC16[index];
}
// Reverse and return
return ((bytelo << 8) | bytehi);
}
E-mail: info@telesys.ru