Files
sunnypilot/panda/board/crc.h
T
github-actions[bot] e01ac7f80f sunnypilot v2026.003.000 release
date: 2026-08-19T09:43:43
master commit: ba29a38507
2026-08-19 09:43:44 +00:00

20 lines
362 B
C

#pragma once
uint8_t crc_checksum(const uint8_t *dat, int len, const uint8_t poly) {
uint8_t crc = 0xFFU;
int i;
int j;
for (i = len - 1; i >= 0; i--) {
crc ^= dat[i];
for (j = 0; j < 8; j++) {
if ((crc & 0x80U) != 0U) {
crc = (uint8_t)((crc << 1) ^ poly);
}
else {
crc <<= 1;
}
}
}
return crc;
}