ICARUS OS (Intelligent Cooperative Architecture for Real-time Unified Systems) 0.1.0
Preemptive Real-Time Operating System for ARM Cortex-M7
Loading...
Searching...
No Matches
crc.h File Reference

CRC16-CCITT helper for the ICARUS OS kernel. More...

#include <stdint.h>

Go to the source code of this file.

Functions

uint16_t crc16_ccitt (const uint8_t *data, uint16_t len)
 Compute CRC16-CCITT (poly 0x1021, init 0xFFFF) over a byte buffer.
 

Detailed Description

CRC16-CCITT helper for the ICARUS OS kernel.

Polynomial 0x1021, initial value 0xFFFF, no reflection, no final XOR. Suitable for CCSDS Space Packet integrity checks and small flash record protection.

On STM32H7 target, backed by the on-chip CRC peripheral (AHB4 bus, configurable polynomial), lazy-initialised on the first call. Under HOST_TEST a portable bytewise loop is used so unit tests run unchanged off-target.

Thread-safe: each call wraps a critical section because the CRC peripheral has internal state.

Author
Souham Biswas
Date
2026

Definition in file crc.h.

Function Documentation

◆ crc16_ccitt()

uint16_t crc16_ccitt ( const uint8_t *  data,
uint16_t  len 
)

Compute CRC16-CCITT (poly 0x1021, init 0xFFFF) over a byte buffer.

Parameters
dataBuffer to checksum (may be NULL only if len is 0).
lenNumber of bytes in data.
Returns
The 16-bit CRC value.

Definition at line 66 of file crc.c.

References __enter_critical(), __exit_critical(), crc_hw_init(), and crc_initialised.

Referenced by __cs_add_region(), __cs_check_all(), __cs_rebaseline(), __tbl_activate_prepare(), __tbl_load(), and cs_selftest().