AceCRC  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.
crc8_nibblem.cpp
Go to the documentation of this file.
1 
20 #include "crc8_nibblem.hpp" // header file converted by AceCRC
21 #include <stdlib.h>
22 #include <stdint.h>
23 
24 namespace ace_crc {
25 namespace crc8_nibblem {
26 
27 
28 
32 static const crc_t crc_table[16] = {
33  0x00, 0x07, 0x0e, 0x09, 0x1c, 0x1b, 0x12, 0x15, 0x38, 0x3f, 0x36, 0x31, 0x24, 0x23, 0x2a, 0x2d
34 };
35 
36 
37 crc_t crc_update(crc_t crc, const void *data, size_t data_len)
38 {
39  const unsigned char *d = (const unsigned char *)data;
40  uint8_t tbl_idx;
41 
42  while (data_len--) {
43  tbl_idx = (crc >> 4) ^ (*d >> 4);
44  crc = crc_table[tbl_idx & 0x0f] ^ (crc << 4);
45  tbl_idx = (crc >> 4) ^ (*d >> 0);
46  crc = crc_table[tbl_idx & 0x0f] ^ (crc << 4);
47  d++;
48  }
49  return crc & 0xff;
50 }
51 
52 } // crc8_nibblem
53 } // ace_crc
crc8_nibblem.hpp
ace_crc::crc16ccitt_bit::crc_t
uint16_t crc_t
The type of the CRC values.
Definition: crc16ccitt_bit.hpp:68
ace_crc::crc8_nibblem::crc_t
uint8_t crc_t
The type of the CRC values.
Definition: crc8_nibblem.hpp:68