This utility can be used to calculate a crc-checksum across given data.
utils/
└── crc/
├── crc16.c
└── crc16.h
The library is completely patform independent and can be usesd across a wide range of c-compilers.
The library can be downloaded (zip or tar), cloned or used as submodule in a project.
| Type | File | Description |
|---|---|---|
| Library | zip / tar | CRC library that implements checksum calculation |
mkdir -p ./utils/
git clone https://github.com/0x007E/utils-crc.git ./utils
mv ./utils/utils-crc ./utils/crcgit submodule add https://github.com/0x007E/utils-crc.git ./utils/crc#include "../lib/utils/crc/crc16.h"
int main(void)
{
crc16_init(CRC16_INITIAL_VALUE);
unsigned char data[] = { 0x01, 0xAF, 0xED, 0x30, 0x41 };
unsigned int crc;
// Bytewise
for (unsigned char i=0; i < (sizeof(data)/sizeof(data[0])); i++)
{
crc16_update(data[i]);
}
crc = crc16_result();
// Arraywise
crc = crc16_calculate(CRC16_INITIAL_VALUE, data, (sizeof(data)/sizeof(data[0]));
// CRC-checksum as array
unsigned char checksum[2];
crc16_result_array(checksum);
}| Type | Link | Description |
|---|---|---|
| AppNote | Application note for CRC16 |
R. GAECHTER