AceCRC  0.4.1
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.
crc16ccitt_bit.hpp
Go to the documentation of this file.
1 
44 #ifndef ACE_CRC_CRC16CCITT_BIT_HPP
45 #define ACE_CRC_CRC16CCITT_BIT_HPP
46 
47 #include <stdlib.h>
48 #include <stdint.h>
49 
50 namespace ace_crc {
51 namespace crc16ccitt_bit {
52 
53 
60 const uint8_t CRC_ALGO_BIT_BY_BIT_FAST = 1;
61 
62 
68 typedef uint16_t crc_t;
69 
70 
76 inline crc_t crc_init(void)
77 {
78  return 0x1d0f;
79 }
80 
81 
90 crc_t crc_update(crc_t crc, const void *data, size_t data_len);
91 
92 
100 {
101  return crc;
102 }
103 
104 
112 inline crc_t crc_calculate(const void *data, size_t data_len) {
113  crc_t crc = crc_init();
114  crc = crc_update(crc, data, data_len);
115  return crc_finalize(crc);
116 }
117 
118 } // crc16ccitt_bit
119 } // ace_crc
120 
121 #endif /* ACE_CRC_CRC16CCITT_BIT_HPP */
ace_crc::crc16ccitt_bit::crc_calculate
crc_t crc_calculate(const void *data, size_t data_len)
Calculate the crc in one-shot.
Definition: crc16ccitt_bit.hpp:112
ace_crc::crc16ccitt_bit::crc_init
crc_t crc_init(void)
Calculate the initial crc value.
Definition: crc16ccitt_bit.hpp:76
ace_crc::crc16ccitt_bit::crc_finalize
crc_t crc_finalize(crc_t crc)
Calculate the final crc value.
Definition: crc16ccitt_bit.hpp:99
ace_crc::crc16ccitt_bit::crc_t
uint16_t crc_t
The type of the CRC values.
Definition: crc16ccitt_bit.hpp:68
ace_crc::crc16ccitt_bit::crc_update
crc_t crc_update(crc_t crc, const void *data, size_t data_len)
Update the crc value with new data.
Definition: crc16ccitt_bit.cpp:30
ace_crc::crc16ccitt_bit::CRC_ALGO_BIT_BY_BIT_FAST
const uint8_t CRC_ALGO_BIT_BY_BIT_FAST
The definition of the used algorithm.
Definition: crc16ccitt_bit.hpp:60