Go to the documentation of this file.
8 #include <initializer_list>
21 explicit constexpr
CRC16(uint16_t initialCRC = 0xffff)
28 constexpr
void init(uint16_t initialCRC)
33 constexpr
void init(std::initializer_list<uint8_t> list)
36 for (
auto& val : list) {
46 crc = (crc << 8) ^ tab[0][(crc >> 8) ^ value];
67 for (
auto n =
size / 8; n; --n) {
68 c = tab[7][data[0] ^ (c >> 8)] ^
69 tab[6][data[1] ^ (c & 255)] ^
80 c = uint16_t(c << 8) ^ tab[0][(c >> 8) ^ *data++];
87 [[nodiscard]] constexpr uint16_t
getValue()
const
93 static inline constexpr
auto tab = [] {
94 std::array<std::array<uint16_t, 0x100>, 8> result = {};
95 for (
auto i :
xrange(0x100)) {
98 x = (
x << 1) ^ ((
x & 0x8000) ? 0x1021 : 0);
102 for (
auto i :
xrange(0x100)) {
103 uint16_t c = result[0][i];
104 for (
auto j :
xrange(1, 8)) {
105 c = result[0][c >> 8] ^ (c << 8);
constexpr void init(uint16_t initialCRC)
(Re)initialize the current value
constexpr auto xrange(T e)
size_t size(std::string_view utf8)
constexpr void repeat(T n, Op op)
Repeat the given operation 'op' 'n' times.
constexpr void update(uint8_t value)
Update CRC with one byte.
constexpr uint16_t getValue() const
Get current CRC value.
This class calculates CRC numbers for the polygon x^16 + x^12 + x^5 + 1.
constexpr void update(const uint8_t *data, size_t size)
For large blocks (e.g.
constexpr void init(std::initializer_list< uint8_t > list)
constexpr CRC16(uint16_t initialCRC=0xffff)
Create CRC16 with an optional initial value.
constexpr KeyMatrixPosition x
Keyboard bindings.
This file implemented 3 utility functions: