CRC explained in detail...

Short answer is that you need to know the polynomial, initial value, and bit order to be able to calculate the CRC. The actual math is simple.

`void crc_init(void)`

{

crc = 0xFFFF;

}

void crc_update(uint16_t *d, unsigned len)

{

while (len--) {

crc ^= *d++;

unsigned n = 16;

do crc = (crc & 0x8000) ? (crc << 1) ^ 0x1021 : crc << 1; while (--n);

}

}