Zephyr API Documentation  2.7.0-rc2
A Scalable Open Source RTOS
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
55uint16_t crc16(const uint8_t *src, size_t len, uint16_t polynomial,
56 uint16_t initial_value, bool pad);
57
73uint8_t crc8(const uint8_t *src, size_t len, uint8_t polynomial, uint8_t initial_value,
74 bool reversed);
75
99uint16_t crc16_ccitt(uint16_t seed, const uint8_t *src, size_t len);
100
123uint16_t crc16_itu_t(uint16_t seed, const uint8_t *src, size_t len);
124
136static inline uint16_t crc16_ansi(const uint8_t *src, size_t len)
137{
138 return crc16(src, len, 0x8005, 0xffff, true);
139}
140
150uint32_t crc32_ieee(const uint8_t *data, size_t len);
151
163
177 size_t len, bool first_pkt, bool last_pkt);
178
190uint8_t crc8_ccitt(uint8_t initial_value, const void *buf, size_t len);
191
205uint8_t crc7_be(uint8_t seed, const uint8_t *src, size_t len);
206
211#ifdef __cplusplus
212}
213#endif
214
215#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_itu_t(uint16_t seed, const uint8_t *src, size_t len)
Compute the CRC-16/XMODEM checksum of a buffer.
uint16_t crc16_ccitt(uint16_t seed, const uint8_t *src, size_t len)
Compute the CRC-16/CCITT checksum of a buffer.
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.
uint16_t crc16(const uint8_t *src, size_t len, uint16_t polynomial, uint16_t initial_value, bool pad)
Generic function for computing CRC 16.
static uint16_t crc16_ansi(const uint8_t *src, size_t len)
Compute ANSI variant of CRC 16.
Definition: crc.h:136
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