33 template<byte V1>
void init()
35 static const word T0 = 0xffff;
36 static const word T1 = CT_CRC16<T0, V1>::value;
39 template<byte V1, byte V2>
void init()
41 static const word T0 = 0xffff;
42 static const word T1 = CT_CRC16<T0, V1>::value;
43 static const word T2 = CT_CRC16<T1, V2>::value;
46 template<byte V1, byte V2, byte V3>
void init()
48 static const word T0 = 0xffff;
49 static const word T1 = CT_CRC16<T0, V1>::value;
50 static const word T2 = CT_CRC16<T1, V2>::value;
51 static const word T3 = CT_CRC16<T2, V3>::value;
54 template<byte V1, byte V2, byte V3, byte V4>
void init()
56 static const word T0 = 0xffff;
57 static const word T1 = CT_CRC16<T0, V1>::value;
58 static const word T2 = CT_CRC16<T1, V2>::value;
59 static const word T3 = CT_CRC16<T2, V3>::value;
60 static const word T4 = CT_CRC16<T3, V4>::value;
69 crc = (crc << 8) ^ tab[0][(crc >> 8) ^ value];
91 for (
auto n = size / 8; n; --n) {
92 c = tab[7][data[0] ^ (c >> 8)] ^
93 tab[6][data[1] ^ (c & 255)] ^
104 c =
word(c << 8) ^ tab[0][(c >> 8) ^ *data++];
118 static const word tab[8][256];
125 template<word C, word V,
int B>
struct CT_H {
126 static const word D =
word(C << 1) ^ (((C ^ V) & 0x8000) ? 0x1021 : 0);
127 static const word value = CT_H<D,
word(V << 1), B - 1>::value;
129 template<word C, word V>
struct CT_H<C, V, 0> {
130 static const word value = C;
132 template<word IN, byte VAL>
struct CT_CRC16 : CT_H<IN, VAL << 8, 8> {};