15#ifndef ZEPHYR_INCLUDE_SYS_CRC_H_
16#define ZEPHYR_INCLUDE_SYS_CRC_H_
31#define CRC8_CCITT_INITIAL_VALUE 0xFF
34#define CRC24_PGP_INITIAL_VALUE 0x00B704CEU
39#define CRC24_FINAL_VALUE_MASK 0x00FFFFFFU
262 size_t len,
bool first_pkt,
bool last_pkt);
378 return crc4(src, len, poly, seed, reflect);
380 return crc4_ti(seed, src, len);
382 return crc7_be(seed, src, len);
384 return crc8(src, len, poly, seed, reflect);
391 return crc16(poly, seed, src, len);
407 return crc32_c(seed, src, len, first, last);
414 __ASSERT_NO_MSG(
false);
#define CRC24_FINAL_VALUE_MASK
Definition: crc.h:39
uint8_t crc7_be(uint8_t seed, const uint8_t *src, size_t len)
Compute the CRC-7 checksum of a buffer.
uint32_t crc32_ieee_update(uint32_t crc, const uint8_t *data, size_t len)
Update an IEEE conforming CRC32 checksum.
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.
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_update(uint32_t crc, const uint8_t *data, size_t len)
Update an OpenPGP CRC-24 checksum.
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 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.
Definition: crc.h:372
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.
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 crc8(const uint8_t *src, size_t len, uint8_t polynomial, uint8_t initial_value, bool reversed)
Generic function for computing CRC 8.
static uint16_t crc16_ansi(const uint8_t *src, size_t len)
Compute the ANSI (or Modbus) variant of CRC-16.
Definition: crc.h:221
crc_type
CRC algorithm enumeration.
Definition: crc.h:57
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.
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 crc32_ieee(const uint8_t *data, size_t len)
Generate IEEE conform CRC32 checksum.
@ CRC7_BE
Use crc7_be.
Definition: crc.h:60
@ CRC16
Use crc16.
Definition: crc.h:63
@ CRC4_TI
Use crc4_ti.
Definition: crc.h:59
@ CRC16_ITU_T
Use crc16_itu_t.
Definition: crc.h:66
@ CRC32_C
Use crc32_c.
Definition: crc.h:68
@ CRC16_ANSI
Use crc16_ansi.
Definition: crc.h:64
@ CRC8
Use crc8.
Definition: crc.h:61
@ CRC24_PGP
Use crc24_pgp.
Definition: crc.h:67
@ CRC16_CCITT
Use crc16_ccitt.
Definition: crc.h:65
@ CRC8_CCITT
Use crc8_ccitt.
Definition: crc.h:62
@ CRC32_IEEE
Use crc32_ieee.
Definition: crc.h:69
@ CRC4
Use crc4.
Definition: crc.h:58
__UINT32_TYPE__ uint32_t
Definition: stdint.h:90
__UINT8_TYPE__ uint8_t
Definition: stdint.h:88
__UINT16_TYPE__ uint16_t
Definition: stdint.h:89