px-fwlib 0.10.0
Cross-platform embedded library and documentation for 8/16/32-bit microcontrollers generated with Doxygen 1.9.2
px_crc8.h : 8-bit CRC calculator

Description

8-bit CRC (Cyclic Redundancy Check) calculator for checksums.

File(s):

A CRC is an error-detecting code that is used for data integrity checks.

See also
http://en.wikipedia.org/wiki/Cyclic_redundancy_check
https://crccalc.com

Macros

#define PX_CRC8_POLYNOMIAL   0x07
 The generator polynomial CRC8 (normal representation): x^8 + x^2 + x + 1. More...
 
#define PX_CRC8_INIT_VAL   0x00
 Initial CRC value. More...
 
#define PX_CRC8_RAM_TABLE   0
 Generate table in RAM to speed up CRC calculation. More...
 
#define PX_CRC8_ROM_TABLE   0
 Use table in ROM to speed up CRC calculation. More...
 

Functions

void px_crc8_init (void)
 Initialise 8-bit CRC calculator. More...
 
uint8_t px_crc8_update_u8 (uint8_t crc, uint8_t data)
 Calculate the 8-bit CRC over one byte. More...
 
uint8_t px_crc8_update_data (uint8_t crc, const void *data, size_t nr_of_bytes)
 Calculate the 8-bit CRC over a number of bytes. More...
 

Macro Definition Documentation

◆ PX_CRC8_POLYNOMIAL

#define PX_CRC8_POLYNOMIAL   0x07

The generator polynomial CRC8 (normal representation): x^8 + x^2 + x + 1.

Definition at line 65 of file px_crc8.h.

◆ PX_CRC8_INIT_VAL

#define PX_CRC8_INIT_VAL   0x00

Initial CRC value.

Definition at line 67 of file px_crc8.h.

◆ PX_CRC8_RAM_TABLE

#define PX_CRC8_RAM_TABLE   0

Generate table in RAM to speed up CRC calculation.

Definition at line 34 of file px_crc8_cfg_template.h.

◆ PX_CRC8_ROM_TABLE

#define PX_CRC8_ROM_TABLE   0

Use table in ROM to speed up CRC calculation.

Definition at line 37 of file px_crc8_cfg_template.h.

Function Documentation

◆ px_crc8_init()

void px_crc8_init ( void  )

Initialise 8-bit CRC calculator.

This function will initialise the table in RAM with constants to speed up CRC calculation. For other options it does nothing.

Definition at line 79 of file px_crc8.c.

◆ px_crc8_update_u8()

uint8_t px_crc8_update_u8 ( uint8_t  crc,
uint8_t  data 
)

Calculate the 8-bit CRC over one byte.

Parameters
crcThe initial CRC to start the calculation with
dataThe value to calculate the CRC over
Returns
uint8_t The resultant CRC

Definition at line 107 of file px_crc8.c.

◆ px_crc8_update_data()

uint8_t px_crc8_update_data ( uint8_t  crc,
const void *  data,
size_t  nr_of_bytes 
)

Calculate the 8-bit CRC over a number of bytes.

Parameters
crcThe initial CRC to start the calculation with
dataPointer to the data to calculate the CRC over
nr_of_bytesThe amount of bytes to calculate the CRC over
Returns
uint8_t The resultant CRC over the group of bytes

Definition at line 131 of file px_crc8.c.