少说废话,上东西。
验证工具的链接地址
接下来是方法,好人做到底,送佛送上西。连typedef也给你写上,CV即可用。
typedef unsigned char uint8_t;
// CRC8校验算法
uint8_t crc8(uint8_t *data, int size)
{
uint8_t crc = 0x00;
uint8_t poly = 0x07;
int bit;
while (size--)
{
crc ^= *data++;
for (bit = 0; bit < 8; bit++)
{
if (crc & 0x80)
{
crc = (crc << 1) ^ poly;
}
else
{
crc <<= 1;
}
}
}
return crc;
}