This commit is contained in:
Ben V. Brown
2022-06-21 20:51:47 +10:00
parent 9fb063ba29
commit 51ad2f71c7
3 changed files with 29 additions and 25 deletions

View File

@@ -1,19 +0,0 @@
#include "crc16.hpp"
#define POLYNOM 0x8005
unsigned int crc16(unsigned int crcValue, unsigned char newByte) {
unsigned char i;
for (i = 0; i < 8; i++) {
if (((crcValue & 0x8000) >> 8) ^ (newByte & 0x80)) {
crcValue = (crcValue << 1) ^ POLYNOM;
} else {
crcValue = (crcValue << 1);
}
newByte <<= 1;
}
return crcValue;
}

View File

@@ -1,6 +0,0 @@
#ifndef DRIVERS_CRC16_H_
#define DRIVERS_CRC16_H_
unsigned int crc16(unsigned int crcValue, unsigned char newByte);
#endif