mirror of
https://github.com/openshwprojects/OpenBK7231T_App.git
synced 2026-02-05 15:15:46 +00:00
26 lines
323 B
C
26 lines
323 B
C
|
|
|
|
char Tiny_CRC8(const char *data,int length)
|
|
{
|
|
char crc = 0x00;
|
|
char extract;
|
|
char sum;
|
|
int i;
|
|
char tempI;
|
|
|
|
for(i=0;i<length;i++)
|
|
{
|
|
extract = *data;
|
|
for (tempI = 8; tempI; tempI--)
|
|
{
|
|
sum = (crc ^ extract) & 0x01;
|
|
crc >>= 1;
|
|
if (sum)
|
|
crc ^= 0x8C;
|
|
extract >>= 1;
|
|
}
|
|
data++;
|
|
}
|
|
return crc;
|
|
}
|