Untitled
public text v1 · immutableuint32_t calc_crc(unsigned char* buf, int n)
{
int i;
uint32_t crc;
crc = 0xffffffff;
for (i=0; i < n ; i++)
{
// Both of these lines produce the same output:
// crc = EDC_crctable[(crc ^ buf[i]) & 0xff] ^ (crc >> 8);
crc = ((crc >> 8) & 0xFFFFFF) ^ EDC_crctable[(crc & 0xff) ^ buf[i]];
}
crc ^= 0xffffffff;
return crc;
}