Parameterized CRC engine - one source of truth for every cyclic redundancy check.
More...
|
| constexpr pc_crc_params | PC_CRC8_SMBUS = {8, 0x07u, 0x00u, false, false, 0x00u} |
| | CRC-8/SMBUS (a.k.a. CRC-8). check = 0xF4.
|
| |
| constexpr pc_crc_params | PC_CRC8_MAXIM_DOW = {8, 0x31u, 0x00u, true, true, 0x00u} |
| | CRC-8/MAXIM-DOW (1-Wire / Dallas). check = 0xA1.
|
| |
| constexpr pc_crc_params | PC_CRC8_NRSC5 = {8, 0x31u, 0xFFu, false, false, 0x00u} |
| | CRC-8/NRSC-5 - the Sensirion sensor CRC. check = 0xF7. Used by services/sht3x.
|
| |
| constexpr pc_crc_params | PC_CRC16_ARC = {16, 0x8005u, 0x0000u, true, true, 0x0000u} |
| | CRC-16/ARC (a.k.a. CRC-16, IBM). check = 0xBB3D.
|
| |
| constexpr pc_crc_params | PC_CRC16_MODBUS = {16, 0x8005u, 0xFFFFu, true, true, 0x0000u} |
| | CRC-16/MODBUS. check = 0x4B37.
|
| |
| constexpr pc_crc_params | PC_CRC16_IBM_3740 = {16, 0x1021u, 0xFFFFu, false, false, 0x0000u} |
| | CRC-16/IBM-3740 (often called CCITT-FALSE). check = 0x29B1.
|
| |
| constexpr pc_crc_params | PC_CRC16_XMODEM = {16, 0x1021u, 0x0000u, false, false, 0x0000u} |
| | CRC-16/XMODEM. check = 0x31C3.
|
| |
| constexpr pc_crc_params | PC_CRC16_KERMIT = {16, 0x1021u, 0x0000u, true, true, 0x0000u} |
| | CRC-16/KERMIT (a.k.a. CRC-16/CCITT, reflected). check = 0x2189.
|
| |
| constexpr pc_crc_params | PC_CRC16_X25 = {16, 0x1021u, 0xFFFFu, true, true, 0xFFFFu} |
| | CRC-16/X-25 (HDLC FCS). check = 0x906E. Used by services/radio/thread, mbplus, nema_ts2.
|
| |
| constexpr pc_crc_params | PC_CRC16_DNP = {16, 0x3D65u, 0x0000u, true, true, 0xFFFFu} |
| | CRC-16/DNP (DNP3 link-layer block check). check = 0xEA82. Used by services/dnp3.
|
| |
| constexpr pc_crc_params | PC_CRC24_OPENPGP = {24, 0x864CFBu, 0xB704CEu, false, false, 0x000000u} |
| | CRC-24/OPENPGP. check = 0x21CF02.
|
| |
| constexpr pc_crc_params | PC_CRC32_ISO_HDLC = {32, 0x04C11DB7u, 0xFFFFFFFFu, true, true, 0xFFFFFFFFu} |
| | CRC-32/ISO-HDLC (zlib / PKZIP / Ethernet). check = 0xCBF43926.
|
| |
| constexpr pc_crc_params | PC_CRC32_BZIP2 = {32, 0x04C11DB7u, 0xFFFFFFFFu, false, false, 0xFFFFFFFFu} |
| | CRC-32/BZIP2 (unreflected CRC-32). check = 0xFC891918.
|
| |
Parameterized CRC engine - one source of truth for every cyclic redundancy check.
Sixteen codecs in this tree each hand-rolled their own CRC loop under a different local name, differing only in a polynomial and a couple of flags - the same duplication endian.h was written to end for byte packing. This is that one implementation, and thirteen of them now call it (C37.118, DF1, DNP3, EnOcean, INTERBUS, Modbus, Modbus Plus, NEMA TS2, raw L2, SDI-12, SHT3x, Thread, Zigbee). The three that do not are excluded on purpose, not overlooked: the WAL is table-driven for bulk log throughput, RTCM3's CRC-24Q seed has no preset here yet, and DShot's "CRC" is a 4-bit XOR fold rather than a CRC at all. See the ROADMAP migration entry.
It is the standard Rocksoft / Williams model, so any published CRC is expressible as six numbers and needs no new code:
Every preset below carries its cataloge check value - the CRC of the nine ASCII octets "123456789" - and test_crc asserts each one: a wrong polynomial or a flipped reflect flag cannot reproduce a published check value by accident. test_crc then diffs the engine against the hand-rolled loops themselves, across every length from 0 to 64, so a preset meant to replace one of them is proven byte-identical to the interop-tested code it retires - not merely plausible.
Bitwise, not table-driven: a 256-entry table per polynomial would cost more flash than the frames are worth on this class of device, and every caller here checksums tens to hundreds of octets, not megabytes. Header-only and pure (<stddef.h> / <stdint.h> only), so it is host-testable, identical on device and host, and costs nothing when unused - the same contract as endian.h.
- Author
- Douglas Quigg (dstroy0)
- Date
- 2026
Definition in file crc.h.