PER Firmware
Loading...
Searching...
No Matches
crc.h File Reference

STM32G4 CRC public API. More...

#include "stm32g474xx.h"
Include dependency graph for crc.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void PHAL_CRC_init (void)
 Initialize and configure the hardware CRC peripheral.
 
uint32_t PHAL_CRC_calculate (const uint32_t *data, uint32_t words)
 Compute a CRC-32/MPEG-2 over a word buffer using the hardware unit.
 
uint32_t PHAL_CRC_calculateSw (const uint32_t *data, uint32_t words)
 Software reference implementation of PHAL_CRC_calculate().
 

Detailed Description

STM32G4 CRC public API.

Author
Hannah Song (song8.nosp@m.92@p.nosp@m.urdue.nosp@m..edu)

Function Documentation

◆ PHAL_CRC_calculate()

uint32_t PHAL_CRC_calculate ( const uint32_t * data,
uint32_t words )

Compute a CRC-32/MPEG-2 over a word buffer using the hardware unit.

Resets the CRC unit (reloading the initial value), feeds each 32-bit word into the peripheral in order, and returns the accumulated remainder. Input is consumed as 32-bit words fed most-significant-bit first; no reflection or final XOR is applied.

Assumes PHAL_CRC_init() has already been called. Uses the single shared CRC peripheral, so it is not reentrant and must not be called concurrently from another context.

Parameters
dataPointer to the buffer of 32-bit words to process.
wordsNumber of 32-bit words in data.
Returns
The 32-bit CRC-32/MPEG-2 remainder over the input.
Here is the call graph for this function:

◆ PHAL_CRC_calculateSw()

uint32_t PHAL_CRC_calculateSw ( const uint32_t * data,
uint32_t words )

Software reference implementation of PHAL_CRC_calculate().

Computes the same CRC-32/MPEG-2 remainder as PHAL_CRC_calculate() using a nibble lookup table, producing bit-identical results. Independent of the CRC peripheral: does not require PHAL_CRC_init() and touches no hardware registers. Intended as a cross-check against the hardware path, or as a fallback where the peripheral is unavailable.

Parameters
dataPointer to the buffer of 32-bit words to process.
wordsNumber of 32-bit words in data.
Returns
The 32-bit CRC-32/MPEG-2 remainder over the input.
Here is the call graph for this function:

◆ PHAL_CRC_init()

void PHAL_CRC_init ( void )

Initialize and configure the hardware CRC peripheral.

Enables the CRC peripheral clock on AHB1, then explicitly configures the unit for CRC-32/MPEG-2: 32-bit polynomial 0x04C11DB7, initial value 0xFFFFFFFF, no input or output bit reversal, and no final XOR. These parameters are written explicitly rather than relying on the peripheral's reset defaults.

Assumes the system and AHB clocks are already configured. Must be called once before any call to PHAL_CRC_calculate().

Here is the call graph for this function: