Skip to content

Instantly share code, notes, and snippets.

@rkrishnasanka
Created May 9, 2014 09:27
Show Gist options
  • Save rkrishnasanka/56c9f5d138c72cf0fce6 to your computer and use it in GitHub Desktop.
Save rkrishnasanka/56c9f5d138c72cf0fce6 to your computer and use it in GitHub Desktop.
CRC Implementation for the Reaction Wheels
#define POLY 0x8408 /* bits reversed for LSB-first */
unsigned short crc = 0xffff;
while (len-- > 0) {
unsigned char ch = *bufp++;
for (i = 0; i < 8; i++) {
crc = (crc >> 1) ˆ ( ((ch ˆ crc) & 0x01) ? POLY : 0 );
ch >>= 1;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment