//-----------------------------------------------------------------------------
#include "crc.h"
#include "util.h"
-#include <stdio.h>
#include <stdint.h>
#include <stddef.h>
}
//credits to iceman
-uint32_t CRC8Maxim(uint8_t *buff, size_t size)
-{
+uint32_t CRC8Maxim(uint8_t *buff, size_t size) {
crc_t crc;
crc_init(&crc, 9, 0x8c, 0x00, 0x00);
crc_clear(&crc);
return crc_finish(&crc);
}
+//credits to iceman
uint32_t CRC8Legic(uint8_t *buff, size_t size) {
// Poly 0x63, reversed poly 0xC6, Init 0x55, Final 0x00
return SwapBits(crc_finish(&crc), 8);
}
-uint32_t SwapBits(uint32_t value, int nrbits) {
- uint32_t newvalue = 0;
- for(int i = 0; i < nrbits; i++) {
- newvalue ^= ((value >> i) & 1) << (nrbits - 1 - i);
- }
- return newvalue;
-}
+