rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Loading...
Searching...
No Matches
link_crc.c File Reference

CRC-16, polynomial 0x1021, computed bit by bit; see link_crc.h. More...

#include "link_crc.h"

Functions

uint16_t link_crc (uint16_t crc, const void *data, size_t len)
 Fold len bytes into crc and return the new accumulator.
uint32_t link_fnv1a32 (uint32_t hash, const void *data, size_t len)
 FNV-1a, 32 bits: per byte, XOR then multiply by 16777619.

Detailed Description

CRC-16, polynomial 0x1021, computed bit by bit; see link_crc.h.

SPDX-License-Identifier: MIT

Function Documentation

◆ link_crc()

uint16_t link_crc ( uint16_t crc,
const void * data,
size_t len )

Fold len bytes into crc and return the new accumulator.

Incremental, so a receiver can check a frame as it arrives without buffering it first.

Parameters
crcThe accumulator: LINK_CRC_INIT, or the value a previous call returned.
dataThe bytes to fold in.
lenNumber of bytes in data.
Returns
The new accumulator.

◆ link_fnv1a32()

uint32_t link_fnv1a32 ( uint32_t hash,
const void * data,
size_t len )

FNV-1a, 32 bits: per byte, XOR then multiply by 16777619.

The content key of the board drawing (LINK_AW_HASH_LO/HI) next to its CRC. Not a cryptographic hash; it tells two drawings apart, it does not authenticate one. Incremental like link_crc().

Parameters
hashThe hash: LINK_FNV_INIT, or the value a previous call returned.
dataThe bytes to fold in.
lenNumber of bytes in data.
Returns
The new hash.