Parameterized CRC engine - one source of truth for every cyclic redundancy check. More...
#include "protocore_config.h"Go to the source code of this file.
Classes | |
| struct | protocore_crc_params |
| One CRC's full definition (Rocksoft model). See the file comment. More... | |
| struct | CrcArgs |
| What one CRC step runs over: the definition, the running register, and the octets. More... | |
| struct | CrcVars |
| struct | CrcNs |
| The entries. More... | |
Functions | |
| void | protocore_crc_begin (const uint8_t *work) |
| void | protocore_crc_update (const uint8_t *work) |
| void | protocore_crc_final (const uint8_t *work) |
| void | protocore_crc_compute (const uint8_t *work) |
Variables | |
| CrcVars | CrcV |
| The operands and the outcome. | |
| const protocore_crc_params | PROTOCORE_CRC8_SMBUS |
| CRC-8/SMBUS (a.k.a. CRC-8). check = 0xF4. | |
| const protocore_crc_params | PROTOCORE_CRC8_MAXIM_DOW |
| CRC-8/MAXIM-DOW (1-Wire / Dallas). check = 0xA1. | |
| const protocore_crc_params | PROTOCORE_CRC8_NRSC5 |
| CRC-8/NRSC-5 - the sensor CRC. check = 0xF7. Used by services/sht3x. | |
| const protocore_crc_params | PROTOCORE_CRC16_ARC |
| CRC-16/ARC (a.k.a. CRC-16, IBM). check = 0xBB3D. | |
| const protocore_crc_params | PROTOCORE_CRC16_MODBUS |
| CRC-16/MODBUS. check = 0x4B37. | |
| const protocore_crc_params | PROTOCORE_CRC16_IBM_3740 |
| CRC-16/IBM-3740 (often called CCITT-FALSE). check = 0x29B1. | |
| const protocore_crc_params | PROTOCORE_CRC16_XMODEM |
| CRC-16/XMODEM. check = 0x31C3. | |
| const protocore_crc_params | PROTOCORE_CRC16_KERMIT |
| CRC-16/KERMIT (a.k.a. CRC-16/CCITT, reflected). check = 0x2189. | |
| const protocore_crc_params | PROTOCORE_CRC16_X25 |
| CRC-16/X-25 (HDLC FCS). check = 0x906E. Used by services/radio/thread, mbplus, nema_ts2. | |
| const protocore_crc_params | PROTOCORE_CRC16_DNP |
| CRC-16/DNP (DNP3 link-layer block check). check = 0xEA82. Used by services/dnp3. | |
| const protocore_crc_params | PROTOCORE_CRC24_OPENPGP |
| CRC-24/OPENPGP. check = 0x21CF02. | |
| const protocore_crc_params | PROTOCORE_CRC32_ISO_HDLC |
| CRC-32/ISO-HDLC (zlib / PKZIP / Ethernet). check = 0xCBF43926. | |
| const protocore_crc_params | PROTOCORE_CRC32_BZIP2 |
| CRC-32/BZIP2 (unreflected CRC-32). check = 0xFC891918. | |
Parameterized CRC engine - one source of truth for every cyclic redundancy check.
One implementation for every CRC in the tree: C37.118, DF1, DNP3, EnOcean, INTERBUS, Modbus, Modbus Plus, NEMA TS2, raw L2, SDI-12, SHT3x, Thread and Zigbee all checksum through it. Three checks stay outside it: the WAL is table-driven for bulk log throughput, RTCM3's CRC-24Q has no preset here, and DShot's "CRC" is a 4-bit XOR fold rather than a CRC at all.
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 catalogue 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.
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. Pure, so it is host-testable and identical on device and host.
Definition in file crc.h.
| void protocore_crc_begin | ( | const uint8_t * | work | ) |
Referenced by protocore_crc_compute().
| void protocore_crc_update | ( | const uint8_t * | work | ) |
Referenced by protocore_crc_compute().
| void protocore_crc_final | ( | const uint8_t * | work | ) |
Referenced by protocore_crc_compute().
| void protocore_crc_compute | ( | const uint8_t * | work | ) |
References protocore_crc_begin(), protocore_crc_compute(), protocore_crc_final(), and protocore_crc_update().
Referenced by protocore_crc_compute().
|
extern |
The operands and the outcome.
|
extern |
CRC-8/SMBUS (a.k.a. CRC-8). check = 0xF4.
|
extern |
CRC-8/MAXIM-DOW (1-Wire / Dallas). check = 0xA1.
|
extern |
CRC-8/NRSC-5 - the sensor CRC. check = 0xF7. Used by services/sht3x.
|
extern |
CRC-16/ARC (a.k.a. CRC-16, IBM). check = 0xBB3D.
|
extern |
CRC-16/MODBUS. check = 0x4B37.
|
extern |
CRC-16/IBM-3740 (often called CCITT-FALSE). check = 0x29B1.
|
extern |
CRC-16/XMODEM. check = 0x31C3.
|
extern |
CRC-16/KERMIT (a.k.a. CRC-16/CCITT, reflected). check = 0x2189.
|
extern |
CRC-16/X-25 (HDLC FCS). check = 0x906E. Used by services/radio/thread, mbplus, nema_ts2.
|
extern |
CRC-16/DNP (DNP3 link-layer block check). check = 0xEA82. Used by services/dnp3.
|
extern |
CRC-24/OPENPGP. check = 0x21CF02.
|
extern |
CRC-32/ISO-HDLC (zlib / PKZIP / Ethernet). check = 0xCBF43926.
|
extern |
CRC-32/BZIP2 (unreflected CRC-32). check = 0xFC891918.