|
ICARUS OS (Intelligent Cooperative Architecture for Real-time Unified Systems) 0.1.0
Preemptive Real-Time Operating System for ARM Cortex-M7
|
CRC16-CCITT implementation. More...
#include "icarus/crc.h"#include "icarus/config.h"#include <stddef.h>#include "icarus/kernel.h"#include "stm32h7xx.h"Go to the source code of this file.
Macros | |
| #define | CRC_CR_POLYSIZE_16 (0x1u << CRC_CR_POLYSIZE_Pos) |
Functions | |
| static void | crc_hw_init (void) |
| uint16_t | crc16_ccitt (const uint8_t *data, uint16_t len) |
| Compute CRC16-CCITT (poly 0x1021, init 0xFFFF) over a byte buffer. | |
Variables | |
| static volatile uint8_t | crc_initialised |
CRC16-CCITT implementation.
On STM32H7 target, drives the on-chip CRC peripheral with the CCITT polynomial (0x1021), 16-bit polynomial size, no input reversal, no output reversal, and an initial value of 0xFFFF. The peripheral is lazy-initialised on first call: the CRC clock is enabled on the AHB4 bus and the registers are configured once.
Hardware CRC consumes one AHB cycle per byte and frees the CPU for the duration of the transfer; for the buffer sizes used by the kvstore and table services this is roughly 4× faster than the bytewise software loop.
The peripheral has internal state (the running CRC value), so every public call is wrapped in a critical section to prevent two tasks corrupting each other's computation.
Under HOST_TEST a portable bytewise loop is used so unit tests run unchanged off-target.
Definition in file crc.c.
| uint16_t crc16_ccitt | ( | const uint8_t * | data, |
| uint16_t | len | ||
| ) |
Compute CRC16-CCITT (poly 0x1021, init 0xFFFF) over a byte buffer.
| data | Buffer to checksum (may be NULL only if len is 0). |
| len | Number of bytes in data. |
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().
|
static |
Definition at line 51 of file crc.c.
References CRC_CR_POLYSIZE_16, and crc_initialised.
Referenced by crc16_ccitt().
|
static |
Definition at line 49 of file crc.c.
Referenced by crc16_ccitt(), and crc_hw_init().