mirror of
https://github.com/Ralim/IronOS.git
synced 2025-02-26 07:53:55 +00:00
tip measurement
This commit is contained in:
19
source/Core/Drivers/crc16.cpp
Normal file
19
source/Core/Drivers/crc16.cpp
Normal file
@@ -0,0 +1,19 @@
|
||||
|
||||
#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;
|
||||
}
|
||||
Reference in New Issue
Block a user