utils
utilities in C for microcontrollers
Macros | Functions
crc16.h File Reference

functions for calculating 16 bit cyclic redundancy codes More...

#include <stddef.h>
#include <stdint.h>

Go to the source code of this file.

Macros

#define CRC16_INIT   (0xffff)
 initial crc value
 
#define CRC16_FINALIZE(val)   (val ^ 0xffff)
 finalize crc value More...
 

Functions

int crc16 (uint16_t *crc, const uint8_t *data, size_t size)
 computes the crc for data and uses crc for the result More...
 

Detailed Description

functions for calculating 16 bit cyclic redundancy codes

Macro Definition Documentation

◆ CRC16_FINALIZE

#define CRC16_FINALIZE (   val)    (val ^ 0xffff)

finalize crc value

Parameters
valan initialized crc value
Returns
a finalized crc value

Function Documentation

◆ crc16()

int crc16 ( uint16_t *  crc,
const uint8_t *  data,
size_t  size 
)

computes the crc for data and uses crc for the result

Parameters
crcpointer to initialized crc value
datapointer to data over which to calculate crc
sizenumber of bytes of data
Returns
0 if successful