AceCRC
1.1.0
Cyclic Redundancy Check (CRC) algorithms (e.g. crc16ccitt, crc32) programmatically converted from C99 code generated by pycrc (https://pycrc.org) to Arduino C++ using namespaces and PROGMEM flash memory.
src
ace_crc
crc32_bit.cpp
Go to the documentation of this file.
1
20
#include "
crc32_bit.hpp
"
// header file converted by AceCRC
21
#include <stdlib.h>
22
#include <stdint.h>
23
#include <stdbool.h>
24
25
namespace
ace_crc {
26
namespace
crc32_bit {
27
28
29
30
crc_t
crc_reflect(
crc_t
data,
size_t
data_len)
31
{
32
unsigned
int
i;
33
crc_t
ret;
34
35
ret = data & 0x01;
36
for
(i = 1; i < data_len; i++) {
37
data >>= 1;
38
ret = (ret << 1) | (data & 0x01);
39
}
40
return
ret;
41
}
42
43
44
crc_t
crc_update(
crc_t
crc,
const
void
*data,
size_t
data_len)
45
{
46
const
unsigned
char
*d = (
const
unsigned
char
*)data;
47
uint8_t i;
48
crc_t
bit;
49
unsigned
char
c;
50
51
while
(data_len--) {
52
c = *d++;
53
for
(i = 0x01; i & 0xff; i <<= 1) {
54
bit = (crc & 0x80000000) ^ ((c & i) ? 0x80000000 : 0);
55
crc <<= 1;
56
if
(bit) {
57
crc ^= 0x04c11db7;
58
}
59
}
60
crc &= 0xffffffff;
61
}
62
return
crc & 0xffffffff;
63
}
64
65
}
// crc32_bit
66
}
// ace_crc
crc32_bit.hpp
Functions and types for CRC checks.
ace_crc::crc32_bit::crc_t
uint32_t crc_t
The type of the CRC values.
Definition:
crc32_bit.hpp:68
Generated by
1.9.1