Skip to content

Instantly share code, notes, and snippets.

View viniciuushr's full-sized avatar
🎯
Focusing

Vinicius Henrique Ribeiro viniciuushr

🎯
Focusing
  • IT Consol
  • Itapetininga
View GitHub Profile
@viniciuushr
viniciuushr / crc16.c
Created September 9, 2021 11:55 — forked from tijnkooijmans/crc16.c
CRC-16/CCITT-FALSE
uint16_t crc16(char* pData, int length)
{
uint8_t i;
uint16_t wCrc = 0xffff;
while (length--) {
wCrc ^= *(unsigned char *)pData++ << 8;
for (i=0; i < 8; i++)
wCrc = wCrc & 0x8000 ? (wCrc << 1) ^ 0x1021 : wCrc << 1;
}
return wCrc & 0xffff;