57 const uint8_t table_[256]
PROGMEM = { 0, 7, 14, 9, 28, 27, 18, 21,
58 56, 63, 54, 49, 36, 35, 42, 45,
59 112, 119, 126, 121, 108, 107, 98, 101,
60 72, 79, 70, 65, 84, 83, 90, 93,
61 224, 231, 238, 233, 252, 251, 242, 245,
62 216, 223, 214, 209, 196, 195, 202, 205,
63 144, 151, 158, 153, 140, 139, 130, 133,
64 168, 175, 166, 161, 180, 179, 186, 189,
65 199, 192, 201, 206, 219, 220, 213, 210,
66 255, 248, 241, 246, 227, 228, 237, 234,
67 183, 176, 185, 190, 171, 172, 165, 162,
68 143, 136, 129, 134, 147, 148, 157, 154,
69 39, 32, 41, 46, 59, 60, 53, 50,
70 31, 24, 17, 22, 3, 4, 13, 10,
71 87, 80, 89, 94, 75, 76, 69, 66,
72 111, 104, 97, 102, 115, 116, 125, 122,
73 137, 142, 135, 128, 149, 146, 155, 156,
74 177, 182, 191, 184, 173, 170, 163, 164,
75 249, 254, 247, 240, 229, 226, 235, 236,
76 193, 198, 207, 200, 221, 218, 211, 212,
77 105, 110, 103, 96, 117, 114, 123, 124,
78 81, 86, 95, 88, 77, 74, 67, 68,
79 25, 30, 23, 16, 5, 2, 11, 12,
80 33, 38, 47, 40, 61, 58, 51, 52,
81 78, 73, 64, 71, 82, 85, 92, 91,
82 118, 113, 120, 127, 106, 109, 100, 99,
83 62, 57, 48, 55, 34, 37, 44, 43,
84 6, 1, 8, 15, 26, 29, 20, 19,
85 174, 169, 160, 167, 178, 181, 188, 187,
86 150, 145, 152, 159, 138, 141, 132, 131,
87 222, 217, 208, 215, 194, 197, 204, 203,
88 230, 225, 232, 239, 250, 253, 244, 243
140 return table_[(0xFF & (begining_value ^
data))];
149 uint8_t ret_value = begining_value;
151 for (i = start_index; i < (start_index + length); i++)
207 for (pos = 0; pos < 31; pos++)
228 for (pos = 0; pos < 31; pos++)
LTC SMBus Support: API for a shared SMBus layer.
uint8_t getCRC(uint8_t *data)
Get CRC of block data organized as 31 bytes pluse CRC.
union LT_union_int32_4bytes data
uint8_t doCalculate(uint8_t data, uint8_t begining_value)
Helper function for pec.
void constructTable(uint16_t user_polynomial)
Initialize the table used to speed up pec calculations.
bool checkCRC(uint8_t *data)
Check CRC of block data organized as 31 data bytes plus CRC.
uint8_t pecGet(void)
Get the current pec result.
unsigned char poly_
The poly used in the calc.
uint16_t crc_polynomial_
The crc poly used in the calc.
uint8_t running_pec_
Temporary pec calc value.
void pecClear(void)
Clear the pec value so it can start a new calculation.
uint8_t calculate(uint8_t *data, uint8_t begining_value, uint8_t start_index, uint8_t length)
Helper function for pec.
void pecAdd(uint8_t byte_value)
Add a byte to the pec calculation.
const uint8_t table_ [256] PROGMEM