How is the USB data CRC value calculated?
Here are two examples. Example 1, from Ron Hemphill. Example 2, from Barry Twycross: This is not suitable for use as production code; it is very inefficient: UInt16 CRC16(void *buffer, UInt32 count) { UInt8 *bp; UInt32 poly, a, b, newBit, lostBit; int i; poly = 0x8005; a = 0xffff; bp = buffer; while(count–) { b = *(bp++); for(i = 0; i<8; i++) { a <<= 1; newBit = (b & 1); b >>= 1; lostBit = a >> 16; if(newBit !