Skip to content

0x007E/utils-crc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Version: 1.0 Release Build License GPLv3

CRC Utils

Ask DeepWiki

This utility can be used to calculate a crc-checksum across given data.

File Structure

File Structure

utils/
└── crc/
    ├── crc16.c
    └── crc16.h

The library is completely patform independent and can be usesd across a wide range of c-compilers.

Downloads

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

Using with git clone

mkdir -p ./utils/
git clone https://github.com/0x007E/utils-crc.git ./utils
mv ./utils/utils-crc ./utils/crc

Using as git submodule

git submodule add https://github.com/0x007E/utils-crc.git ./utils/crc

Programming

#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);
}

Additional Information

Type Link Description
AppNote pdf Application note for CRC16

R. GAECHTER