proxmark3/common/crc16.c
bushing a99c6a1921 There's no painless way to do this, but it needs to be done --
the only reason any of the Windows code was in CPP files was
because the MS compiler doesn't support C99.  Switch to using
MinGW, and that problem goes away, so we can rename the files back.
2009-12-22 12:42:54 +00:00

12 lines
293 B
C

unsigned short update_crc16( unsigned short crc, unsigned char c ) {
unsigned short i, v, tcrc = 0;
v = (crc ^ c) & 0xff;
for (i = 0; i < 8; i++) {
tcrc = ( (tcrc ^ v) & 1 ) ? ( tcrc >> 1 ) ^ 0x8408 : tcrc >> 1;
v >>= 1;
}
return ((crc >> 8) ^ tcrc)&0xffff;
}