Solaris Software
Loading...
Searching...
No Matches
crc.h
Go to the documentation of this file.
1/**
2 * @file crc.h
3 * @brief CRC-16/CCITT checksum utility.
4 *
5 * Naming conventions used in this file:
6 * - Constants/macros: K_SPP_CRC_*
7 * - Public functions: SPP_UTIL_crc16()
8 */
9
10#ifndef SPP_CRC_H
11#define SPP_CRC_H
12
13#include "spp/core/types.h"
14
15/* ----------------------------------------------------------------
16 * Constants
17 * ---------------------------------------------------------------- */
18
19/** @brief CRC-16/CCITT polynomial (0x1021). */
20#define K_SPP_CRC_POLY (0x1021U)
21
22/** @brief CRC-16 initial value. */
23#define K_SPP_CRC_INIT (0xFFFFU)
24
25/* ----------------------------------------------------------------
26 * Public API
27 * ---------------------------------------------------------------- */
28
29/**
30 * @brief Compute a CRC-16/CCITT checksum over a byte buffer.
31 *
32 * @param[in] p_data Pointer to the data buffer.
33 * @param[in] length Number of bytes to process.
34 *
35 * @return 16-bit CRC value.
36 */
38
39#endif /* SPP_CRC_H */
spp_uint16_t SPP_UTIL_crc16(const spp_uint8_t *p_data, spp_uint32_t length)
Compute a CRC-16/CCITT checksum over a byte buffer.
Definition crc.c:8
Portable integer types and SPI/storage configuration types for SPP.
uint16_t spp_uint16_t
Definition types.h:29
uint32_t spp_uint32_t
Definition types.h:31
uint8_t spp_uint8_t
Definition types.h:27