Zephyr API 3.6.99
Loading...
Searching...
No Matches
crc.h File Reference

CRC computation function. More...

#include <zephyr/types.h>
#include <stdbool.h>
#include <stddef.h>
#include <zephyr/sys/__assert.h>

Go to the source code of this file.

Macros

#define CRC8_CCITT_INITIAL_VALUE   0xFF
 
#define CRC24_PGP_INITIAL_VALUE   0x00B704CEU
 
#define CRC24_FINAL_VALUE_MASK   0x00FFFFFFU
 

Enumerations

enum  crc_type {
  CRC4 , CRC4_TI , CRC7_BE , CRC8 ,
  CRC8_CCITT , CRC16 , CRC16_ANSI , CRC16_CCITT ,
  CRC16_ITU_T , CRC24_PGP , CRC32_C , CRC32_IEEE
}
 CRC algorithm enumeration. More...
 

Functions

uint16_t crc16 (uint16_t poly, uint16_t seed, const uint8_t *src, size_t len)
 Generic function for computing a CRC-16 without input or output reflection.
 
uint16_t crc16_reflect (uint16_t poly, uint16_t seed, const uint8_t *src, size_t len)
 Generic function for computing a CRC-16 with input and output reflection.
 
uint8_t crc8 (const uint8_t *src, size_t len, uint8_t polynomial, uint8_t initial_value, bool reversed)
 Generic function for computing CRC 8.
 
uint16_t crc16_ccitt (uint16_t seed, const uint8_t *src, size_t len)
 Compute the checksum of a buffer with polynomial 0x1021, reflecting input and output.
 
uint16_t crc16_itu_t (uint16_t seed, const uint8_t *src, size_t len)
 Compute the checksum of a buffer with polynomial 0x1021, no reflection of input or output.
 
static uint16_t crc16_ansi (const uint8_t *src, size_t len)
 Compute the ANSI (or Modbus) variant of CRC-16.
 
uint32_t crc32_ieee (const uint8_t *data, size_t len)
 Generate IEEE conform CRC32 checksum.
 
uint32_t crc32_ieee_update (uint32_t crc, const uint8_t *data, size_t len)
 Update an IEEE conforming CRC32 checksum.
 
uint32_t crc32_c (uint32_t crc, const uint8_t *data, size_t len, bool first_pkt, bool last_pkt)
 Calculate CRC32C (Castagnoli) checksum.
 
uint8_t crc8_ccitt (uint8_t initial_value, const void *buf, size_t len)
 Compute CCITT variant of CRC 8.
 
uint8_t crc7_be (uint8_t seed, const uint8_t *src, size_t len)
 Compute the CRC-7 checksum of a buffer.
 
uint8_t crc4_ti (uint8_t seed, const uint8_t *src, size_t len)
 Compute the CRC-4 checksum of a buffer.
 
uint8_t crc4 (const uint8_t *src, size_t len, uint8_t polynomial, uint8_t initial_value, bool reversed)
 Generic function for computing CRC 4.
 
uint32_t crc24_pgp (const uint8_t *data, size_t len)
 Generate an OpenPGP CRC-24 checksum as defined in RFC 4880 section 6.1.
 
uint32_t crc24_pgp_update (uint32_t crc, const uint8_t *data, size_t len)
 Update an OpenPGP CRC-24 checksum.
 
static uint32_t crc_by_type (enum crc_type type, const uint8_t *src, size_t len, uint32_t seed, uint32_t poly, bool reflect, bool first, bool last)
 Compute a CRC checksum, in a generic way.
 

Detailed Description

CRC computation function.

Macro Definition Documentation

◆ CRC24_FINAL_VALUE_MASK

#define CRC24_FINAL_VALUE_MASK   0x00FFFFFFU

◆ CRC24_PGP_INITIAL_VALUE

#define CRC24_PGP_INITIAL_VALUE   0x00B704CEU

◆ CRC8_CCITT_INITIAL_VALUE

#define CRC8_CCITT_INITIAL_VALUE   0xFF