Zephyr API Documentation  3.0.0
A Scalable Open Source RTOS
3.0.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
crc.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2018 Workaround GmbH.
3 * Copyright (c) 2017 Intel Corporation.
4 * Copyright (c) 2017 Nordic Semiconductor ASA
5 * Copyright (c) 2015 Runtime Inc
6 * Copyright (c) 2018 Google LLC.
7 *
8 * SPDX-License-Identifier: Apache-2.0
9 */
14#ifndef ZEPHYR_INCLUDE_SYS_CRC_H_
15#define ZEPHYR_INCLUDE_SYS_CRC_H_
16
17#include <zephyr/types.h>
18#include <stdbool.h>
19#include <stddef.h>
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
25/* Initial value expected to be used at the beginning of the crc8_ccitt
26 * computation.
27 */
28#define CRC8_CCITT_INITIAL_VALUE 0xFF
29
59uint16_t crc16(uint16_t poly, uint16_t seed, const uint8_t *src, size_t len);
60
89uint16_t crc16_reflect(uint16_t poly, uint16_t seed, const uint8_t *src, size_t len);
105uint8_t crc8(const uint8_t *src, size_t len, uint8_t polynomial, uint8_t initial_value,
106 bool reversed);
107
139uint16_t crc16_ccitt(uint16_t seed, const uint8_t *src, size_t len);
140
176uint16_t crc16_itu_t(uint16_t seed, const uint8_t *src, size_t len);
177
189static inline uint16_t crc16_ansi(const uint8_t *src, size_t len)
190{
191 return crc16_reflect(0xA001, 0xffff, src, len);
192}
193
203uint32_t crc32_ieee(const uint8_t *data, size_t len);
204
216
230 size_t len, bool first_pkt, bool last_pkt);
231
243uint8_t crc8_ccitt(uint8_t initial_value, const void *buf, size_t len);
244
258uint8_t crc7_be(uint8_t seed, const uint8_t *src, size_t len);
259
264#ifdef __cplusplus
265}
266#endif
267
268#endif
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.
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.
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:189
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 crc32_ieee(const uint8_t *data, size_t len)
Generate IEEE conform CRC32 checksum.
__UINT32_TYPE__ uint32_t
Definition: stdint.h:60
__UINT8_TYPE__ uint8_t
Definition: stdint.h:58
__UINT16_TYPE__ uint16_t
Definition: stdint.h:59
static fdata_t data[2]
Definition: test_fifo_contexts.c:15