Lightweight CRC16 checksum algorithms.
More...
Lightweight CRC16 checksum algorithms.
This CRC16 implementation does not use pre-calculated lookup tables and is thus very lightweight (memory-wise), but as a caveat slower (about factor 8) than the version with pre-calculated lookup tables.
Additionally compared to CRC16-CCITT this is a generalized implementation. One can easily exchange generator polynomials and starting seeds.
|
uint16_t | ucrc16_calc_be (const uint8_t *buf, size_t len, uint16_t poly, uint16_t seed) |
| Calculate CRC16 (big-endian version)
|
|
uint16_t | ucrc16_calc_le (const uint8_t *buf, size_t len, uint16_t poly, uint16_t seed) |
| Calculate CRC16 (little-endian version)
|
|
#define | UCRC16_CCITT_POLY_BE (0x1021) |
| Various generator polynomials.
|
|
#define | UCRC16_CCITT_POLY_LE (0x8408) |
| CRC16-CCITT polynomial (little-endian)
|
|
◆ UCRC16_CCITT_POLY_BE
#define UCRC16_CCITT_POLY_BE (0x1021) |
Various generator polynomials.
CRC16-CCITT polynomial (big-endian)
Definition at line 43 of file ucrc16.h.
◆ UCRC16_CCITT_POLY_LE
#define UCRC16_CCITT_POLY_LE (0x8408) |
CRC16-CCITT polynomial (little-endian)
Definition at line 44 of file ucrc16.h.
◆ ucrc16_calc_be()
uint16_t ucrc16_calc_be |
( |
const uint8_t * |
buf, |
|
|
size_t |
len, |
|
|
uint16_t |
poly, |
|
|
uint16_t |
seed |
|
) |
| |
Calculate CRC16 (big-endian version)
- Parameters
-
[in] | buf | Start of memory are to checksum |
[in] | len | Number of bytes in buf to calculate checksum for |
[in] | poly | The generator polynomial for the checksum |
[in] | seed | The seed (starting value) for the checksum |
- Returns
- Checksum of the specified memory area based on
seed
and poly
- Note
- The return value is not the complement of the sum but the sum itself
◆ ucrc16_calc_le()
uint16_t ucrc16_calc_le |
( |
const uint8_t * |
buf, |
|
|
size_t |
len, |
|
|
uint16_t |
poly, |
|
|
uint16_t |
seed |
|
) |
| |
Calculate CRC16 (little-endian version)
- Parameters
-
[in] | buf | Start of memory are to checksum |
[in] | len | Number of bytes in buf to calculate checksum for |
[in] | poly | The generator polynomial for the checksum |
[in] | seed | The seed (starting value) for the checksum |
- Returns
- Checksum of the specified memory area based on
seed
and poly
- Note
- The return value is not the complement of the sum but the sum itself