I am trying to calculate a USB compatible CRC16.
After some debugging and comparison with online calculators i found an initialization error in your crc16_generate_key function:
unsigned int i, j, b, mask, key16=~0;
For 16-bit CRC the initial value(e.g. 0xFFFF) should be 16-bit wide, but with unsigned int it initializes to 0xFFFFFFFF.
After correcting the init value the resulting key is correct.
Hello!
I am trying to calculate a USB compatible CRC16. After some debugging and comparison with online calculators i found an initialization error in your crc16_generate_key function:
unsigned int i, j, b, mask, key16=~0;
For 16-bit CRC the initial value(e.g. 0xFFFF) should be 16-bit wide, but with unsigned int it initializes to 0xFFFFFFFF. After correcting the init value the resulting key is correct.