Zephyr Project API
3.2.0
A Scalable Open Source RTOS
|
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
static uint16_t | crc16_ansi (const uint8_t *src, size_t len) |
Compute the ANSI (or Modbus) variant of CRC-16. More... | |
uint32_t | crc32_ieee (const uint8_t *data, size_t len) |
Generate IEEE conform CRC32 checksum. More... | |
uint32_t | crc32_ieee_update (uint32_t crc, const uint8_t *data, size_t len) |
Update an IEEE conforming CRC32 checksum. More... | |
uint32_t | crc32_c (uint32_t crc, const uint8_t *data, size_t len, bool first_pkt, bool last_pkt) |
Calculate CRC32C (Castagnoli) checksum. More... | |
uint8_t | crc8_ccitt (uint8_t initial_value, const void *buf, size_t len) |
Compute CCITT variant of CRC 8. More... | |
uint8_t | crc7_be (uint8_t seed, const uint8_t *src, size_t len) |
Compute the CRC-7 checksum of a buffer. More... | |
#include <include/zephyr/sys/crc.h>
Generic function for computing a CRC-16 without input or output reflection.
Compute CRC-16 by passing in the address of the input, the input length and polynomial used in addition to the initial value. This is O(n*8) where n is the length of the buffer provided. No reflection is performed.
poly | The polynomial to use omitting the leading x^16 coefficient |
seed | Initial value for the CRC computation |
src | Input bytes for the computation |
len | Length of the input in bytes |
#include <include/zephyr/sys/crc.h>
Compute the ANSI (or Modbus) variant of CRC-16.
The ANSI variant of CRC-16 uses 0x8005 (0xA001 reflected) as its polynomial with the initial * value set to 0xffff.
src | Input bytes for the computation |
len | Length of the input in bytes |
#include <include/zephyr/sys/crc.h>
Compute the checksum of a buffer with polynomial 0x1021, reflecting input and output.
This function is able to calculate any CRC that uses 0x1021 as it polynomial and requires reflecting both the input and the output. It is a fast variant that runs in O(n) time, where n is the length of the input buffer.
The following checksums can, among others, be calculated by this function, depending on the value provided for the initial seed and the value the final calculated CRC is XORed with:
See ITU-T Recommendation V.41 (November 1988).
seed | Value to seed the CRC with |
src | Input bytes for the computation |
len | Length of the input in bytes |
#include <include/zephyr/sys/crc.h>
Compute the checksum of a buffer with polynomial 0x1021, no reflection of input or output.
This function is able to calculate any CRC that uses 0x1021 as it polynomial and requires no reflection on both the input and the output. It is a fast variant that runs in O(n) time, where n is the length of the input buffer.
The following checksums can, among others, be calculated by this function, depending on the value provided for the initial seed and the value the final calculated CRC is XORed with:
See ITU-T Recommendation V.41 (November 1988) (MSB first).
seed | Value to seed the CRC with |
src | Input bytes for the computation |
len | Length of the input in bytes |
#include <include/zephyr/sys/crc.h>
Generic function for computing a CRC-16 with input and output reflection.
Compute CRC-16 by passing in the address of the input, the input length and polynomial used in addition to the initial value. This is O(n*8) where n is the length of the buffer provided. Both input and output are reflected.
The following checksums can, among others, be calculated by this function, depending on the value provided for the initial seed and the value the final calculated CRC is XORed with:
poly | The polynomial to use omitting the leading x^16 coefficient. Important: please reflect the poly. For example, use 0xA001 instead of 0x8005 for CRC-16-MODBUS. |
seed | Initial value for the CRC computation |
src | Input bytes for the computation |
len | Length of the input in bytes |
#include <include/zephyr/sys/crc.h>
Calculate CRC32C (Castagnoli) checksum.
crc | CRC32C checksum that needs to be updated. |
*data | Pointer to data on which the CRC should be calculated. |
len | Data length. |
first_pkt | Whether this is the first packet in the stream. |
last_pkt | Whether this is the last packet in the stream. |
#include <include/zephyr/sys/crc.h>
Generate IEEE conform CRC32 checksum.
*data | Pointer to data on which the CRC should be calculated. |
len | Data length. |
#include <include/zephyr/sys/crc.h>
Update an IEEE conforming CRC32 checksum.
crc | CRC32 checksum that needs to be updated. |
*data | Pointer to data on which the CRC should be calculated. |
len | Data length. |
#include <include/zephyr/sys/crc.h>
Compute the CRC-7 checksum of a buffer.
See JESD84-A441. Used by the MMC protocol. Uses 0x09 as the polynomial with no reflection. The CRC is left justified, so bit 7 of the result is bit 6 of the CRC.
seed | Value to seed the CRC with |
src | Input bytes for the computation |
len | Length of the input in bytes |
uint8_t crc8 | ( | const uint8_t * | src, |
size_t | len, | ||
uint8_t | polynomial, | ||
uint8_t | initial_value, | ||
bool | reversed | ||
) |
#include <include/zephyr/sys/crc.h>
Generic function for computing CRC 8.
Compute CRC 8 by passing in the address of the input, the input length and polynomial used in addition to the initial value.
src | Input bytes for the computation |
len | Length of the input in bytes |
polynomial | The polynomial to use omitting the leading x^8 coefficient |
initial_value | Initial value for the CRC computation |
reversed | Should we use reflected/reversed values or not |
#include <include/zephyr/sys/crc.h>
Compute CCITT variant of CRC 8.
Normal CCITT variant of CRC 8 is using 0x07.
initial_value | Initial value for the CRC computation |
buf | Input bytes for the computation |
len | Length of the input in bytes |