mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2024-11-30 07:06:12 +03:00
acc39a4bc0
* Api Symbols: replace asserts with checks * Api Symbols: replace asserts with checks part 2 * Update no args function signatures with void, to help compiler to track incorrect usage * More unavoidable void * Update PVS config and code to make it happy * Format sources * nfc: fix checks * dead code cleanup & include fixes Co-authored-by: gornekich <n.gorbadey@gmail.com> Co-authored-by: hedger <hedger@users.noreply.github.com> Co-authored-by: hedger <hedger@nanode.su>
20 lines
553 B
C
20 lines
553 B
C
#include "maxim_crc.h"
|
|
#include <furi.h>
|
|
|
|
uint8_t maxim_crc8(const uint8_t* data, const uint8_t data_size, const uint8_t crc_init) {
|
|
furi_check(data);
|
|
|
|
uint8_t crc = crc_init;
|
|
|
|
for(uint8_t index = 0; index < data_size; ++index) {
|
|
uint8_t input_byte = data[index];
|
|
for(uint8_t bit_position = 0; bit_position < 8; ++bit_position) {
|
|
const uint8_t mix = (crc ^ input_byte) & (uint8_t)(0x01);
|
|
crc >>= 1;
|
|
if(mix != 0) crc ^= 0x8C;
|
|
input_byte >>= 1;
|
|
}
|
|
}
|
|
return crc;
|
|
}
|