mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-12 11:08:36 -07:00
updated protoview and fixed array count issue
arrays start at 0 and citroen_tpms was trying to read 0-10 meaning 11 full bytes rather than actually 10 (0-9).
This commit is contained in:
20
applications/plugins/protoview/crc.c
Normal file
20
applications/plugins/protoview/crc.c
Normal file
@@ -0,0 +1,20 @@
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
/* CRC8 with the specified initialization value 'init' and
|
||||
* polynomial 'poly'. */
|
||||
uint8_t crc8(const uint8_t *data, size_t len, uint8_t init, uint8_t poly)
|
||||
{
|
||||
uint8_t crc = init;
|
||||
size_t i, j;
|
||||
for (i = 0; i < len; i++) {
|
||||
crc ^= data[i];
|
||||
for (j = 0; j < 8; j++) {
|
||||
if ((crc & 0x80) != 0)
|
||||
crc = (uint8_t)((crc << 1) ^ poly);
|
||||
else
|
||||
crc <<= 1;
|
||||
}
|
||||
}
|
||||
return crc;
|
||||
}
|
||||
Reference in New Issue
Block a user