C/C++ API Reference
Loading...
Searching...
No Matches
pw::checksum::Crc8 Class Reference

Public Member Functions

constexpr Crc8 (uint8_t polynomial, uint8_t initial_value, bool reflect_in, bool reflect_out, uint8_t xor_out)
 Constructs a Crc8 calculator with the specified parameters.
 
constexpr uint8_t Calculate (pw::span< const std::byte > data) const
 Calculates the CRC-8 value for the given data.
 

Static Public Attributes

static const Crc8 kCrc8
 CRC-8: poly=0x07, init=0x00, refin=false, refout=false, xout=0x00.
 
static const Crc8 kMaxim
 CRC-8/MAXIM: poly=0x31, init=0x00, refin=true, refout=true, xout=0x00.
 
static const Crc8 kWcdma
 CRC-8/WCDMA: poly=0x9B, init=0x00, refin=true, refout=true, xout=0x00.
 
static const Crc8 kItu
 CRC-8/ITU: poly=0x07, init=0x00, refin=false, refout=false, xout=0x55.
 
static const Crc8 kRohc
 CRC-8/ROHC: poly=0x07, init=0xFF, refin=true, refout=true, xout=0x00.
 

Constructor & Destructor Documentation

◆ Crc8()

constexpr pw::checksum::Crc8::Crc8 ( uint8_t  polynomial,
uint8_t  initial_value,
bool  reflect_in,
bool  reflect_out,
uint8_t  xor_out 
)
inlineconstexpr

Constructs a Crc8 calculator with the specified parameters.

Parameters
polynomialThe polynomial used for the CRC calculation.
initial_valueThe initial value of the CRC register.
reflect_inWhether the input bytes should be reflected before processing.
reflect_outWhether the final CRC value should be reflected.
xor_outThe value to XOR with the final CRC result.

Member Function Documentation

◆ Calculate()

constexpr uint8_t pw::checksum::Crc8::Calculate ( pw::span< const std::byte >  data) const
constexpr

Calculates the CRC-8 value for the given data.

Parameters
dataThe data to calculate the CRC-8 for.
Returns
The CRC-8 value.

The documentation for this class was generated from the following file: