ProtoCore v1.0.16
Deterministic, zero-heap network stack for embedded targets
Loading...
Searching...
No Matches
crc.h File Reference

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 (uint8_t *work)
 
void protocore_crc_update (uint8_t *work)
 
void protocore_crc_final (uint8_t *work)
 
void protocore_crc_compute (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.
 

Detailed Description

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.

Author
Douglas Quigg (dstroy0)
Date
2026

Definition in file crc.h.

Function Documentation

◆ protocore_crc_begin()

void protocore_crc_begin ( uint8_t *  work)

◆ protocore_crc_update()

void protocore_crc_update ( uint8_t *  work)

◆ protocore_crc_final()

void protocore_crc_final ( uint8_t *  work)

◆ protocore_crc_compute()

void protocore_crc_compute ( uint8_t *  work)

Variable Documentation

◆ CrcV

CrcVars CrcV
extern

The operands and the outcome.

◆ PROTOCORE_CRC8_SMBUS

const protocore_crc_params PROTOCORE_CRC8_SMBUS
extern

CRC-8/SMBUS (a.k.a. CRC-8). check = 0xF4.

◆ PROTOCORE_CRC8_MAXIM_DOW

const protocore_crc_params PROTOCORE_CRC8_MAXIM_DOW
extern

CRC-8/MAXIM-DOW (1-Wire / Dallas). check = 0xA1.

◆ PROTOCORE_CRC8_NRSC5

const protocore_crc_params PROTOCORE_CRC8_NRSC5
extern

CRC-8/NRSC-5 - the sensor CRC. check = 0xF7. Used by services/sht3x.

◆ PROTOCORE_CRC16_ARC

const protocore_crc_params PROTOCORE_CRC16_ARC
extern

CRC-16/ARC (a.k.a. CRC-16, IBM). check = 0xBB3D.

◆ PROTOCORE_CRC16_MODBUS

const protocore_crc_params PROTOCORE_CRC16_MODBUS
extern

CRC-16/MODBUS. check = 0x4B37.

◆ PROTOCORE_CRC16_IBM_3740

const protocore_crc_params PROTOCORE_CRC16_IBM_3740
extern

CRC-16/IBM-3740 (often called CCITT-FALSE). check = 0x29B1.

◆ PROTOCORE_CRC16_XMODEM

const protocore_crc_params PROTOCORE_CRC16_XMODEM
extern

CRC-16/XMODEM. check = 0x31C3.

◆ PROTOCORE_CRC16_KERMIT

const protocore_crc_params PROTOCORE_CRC16_KERMIT
extern

CRC-16/KERMIT (a.k.a. CRC-16/CCITT, reflected). check = 0x2189.

◆ PROTOCORE_CRC16_X25

const protocore_crc_params PROTOCORE_CRC16_X25
extern

CRC-16/X-25 (HDLC FCS). check = 0x906E. Used by services/radio/thread, mbplus, nema_ts2.

◆ PROTOCORE_CRC16_DNP

const protocore_crc_params PROTOCORE_CRC16_DNP
extern

CRC-16/DNP (DNP3 link-layer block check). check = 0xEA82. Used by services/dnp3.

◆ PROTOCORE_CRC24_OPENPGP

const protocore_crc_params PROTOCORE_CRC24_OPENPGP
extern

CRC-24/OPENPGP. check = 0x21CF02.

◆ PROTOCORE_CRC32_ISO_HDLC

const protocore_crc_params PROTOCORE_CRC32_ISO_HDLC
extern

CRC-32/ISO-HDLC (zlib / PKZIP / Ethernet). check = 0xCBF43926.

◆ PROTOCORE_CRC32_BZIP2

const protocore_crc_params PROTOCORE_CRC32_BZIP2
extern

CRC-32/BZIP2 (unreflected CRC-32). check = 0xFC891918.