CRC8, XOR, LRC

functions for calculating checksums.

This value is often used in checksum calculations.

uint8_t CRC8_u8Calc(uint8_t *pu8Data, uint8_t size, uint8_t init=0)
uint8_t CRC8_u8CalcU32(uint32_t u32c, uint8_t init=0)
uint8_t CRC8_u8CalcU16(uint16_t u16c, uint8_t init=0)
uint8_t XOR_u8Calc(uint8_t *pu8Data, uint8_t size)
uint8_t LRC_u8Calc(uint8_t* pu8Data, uint8_t size)

CRC8, XOR, LRC(ASCII format) calculations.

CRC8_u8CalcU16(), CRC8_u8CalcU32() computes CRC8 using u16c, u32c as big-endian sequence.

There are different types of CRC8 depending on the calculation formula, initial value, etc. This library uses a polynomial formula of X^8+X^5+X^4+1 (Polynomial Value is 0x31). This is sometimes called CRC8-CCITT or CRC8-Maxim.

XOR is the exclusive OR XOR of each element.

LRC calculates the sum of the values of each element and takes the two's complement of the lower 8 bits. The result is zero when all elements, including the checksum, are added together.

Background

Added as a library procedure because it is used to check data strings in wireless packets, checksums (LRC) in ASCII format, and various sensors.

最終更新