MCPcopy Create free account
hub / github.com/RobTillaart/Arduino / crc64

Function crc64

libraries/CRC/CRC.cpp:208–235  ·  view source on GitHub ↗

CRC-CCITT POLYNOME = x64 + ..... + 1 CRC_ECMA64 = 0x42F0E1EBA9EA3693

Source from the content-addressed store, hash-verified

206// CRC-CCITT POLYNOME = x64 + ..... + 1
207// CRC_ECMA64 = 0x42F0E1EBA9EA3693
208uint64_t crc64(const uint8_t *array, uint16_t length, const uint64_t polynome,
209 const uint64_t startmask, const uint64_t endmask,
210 const bool reverseIn, const bool reverseOut)
211{
212 uint64_t crc = startmask;
213 while (length--)
214 {
215 if ((length & 0xFF) == 0) yield(); // RTOS
216 uint8_t data = *array++;
217 if (reverseIn) data = reverse8(data);
218 crc ^= ((uint64_t) data) << 56;
219 for (uint8_t i = 8; i; i--)
220 {
221 if (crc & (1ULL << 63))
222 {
223 crc <<= 1;
224 crc ^= polynome;
225 }
226 else
227 {
228 crc <<= 1;
229 }
230 }
231 }
232 crc ^= endmask;
233 if (reverseOut) crc = reverse64(crc);
234 return crc;
235}
236
237
238// -- END OF FILE

Callers

nothing calls this directly

Calls 2

reverse8Function · 0.85
reverse64Function · 0.85

Tested by

no test coverage detected