Initial commit

This commit is contained in:
2023-12-19 03:01:07 +01:00
commit 4fd5bc05c9
8 changed files with 172 additions and 0 deletions

26
src/crc8.cpp Normal file
View File

@ -0,0 +1,26 @@
#include "tinycrc.h"
/*
CRC8 (from https://devcoons.com/crc8/)
*/
uint8_t tinycrc_crc8(const uint8_t* data, uint16_t length)
{
char crc = 0x00;
char extract;
char sum;
for(int i=0;i<length;i++)
{
extract = *data;
for (char tempI = 8; tempI; tempI--)
{
sum = (crc ^ extract) & 0x01;
crc >>= 1;
if (sum)
crc ^= 0x8C;
extract >>= 1;
}
data++;
}
return crc;
}