AceCRC  0.1
Cyclic Redundancy Check (CRC) algorithms (e.g. crc32(), crc16ccitt()) are progammatically converted from pycrc to Arduino C++, including variants (e.g. 4-bit versus 8-bit tables) that trade space and time.
crc32_bit.hpp
Go to the documentation of this file.
1 
44 #ifndef ACE_CRC_CRC32_BIT_HPP
45 #define ACE_CRC_CRC32_BIT_HPP
46 
47 #include <stdlib.h>
48 #include <stdint.h>
49 
50 namespace ace_crc {
51 namespace crc32_bit {
52 
53 
60 static const uint8_t CRC_ALGO_BIT_BY_BIT_FAST = 1;
61 
62 
68 typedef uint_fast32_t crc_t;
69 
70 
78 crc_t crc_reflect(crc_t data, size_t data_len);
79 
80 
86 static inline crc_t crc_init(void)
87 {
88  return 0xffffffff;
89 }
90 
91 
100 crc_t crc_update(crc_t crc, const void *data, size_t data_len);
101 
102 
109 static inline crc_t crc_finalize(crc_t crc)
110 {
111  return crc_reflect(crc, 32) ^ 0xffffffff;
112 }
113 
114 
115 } // crc32_bit
116 } // ace_crc
117 
118 #endif /* ACE_CRC_CRC32_BIT_HPP */
ace_crc::crc32_bit::crc_t
uint_fast32_t crc_t
The type of the CRC values.
Definition: crc32_bit.hpp:68
ace_crc::crc32_bit::crc_reflect
crc_t crc_reflect(crc_t data, size_t data_len)
Reflect all bits of a data word of data_len bytes.
Definition: crc32_bit.cpp:30