ASCII Serial Com
Serial communication library between computers, microcontrollers, FPGAs, etc. Uses only ASCII. Not the most efficient protocol, but meant to be easy to read
Loading...
Searching...
No Matches
crc_16_dnp_tbl4bit.c
Go to the documentation of this file.
1
/**
2
* \file
3
* Functions and types for CRC checks.
4
*
5
* Generated on Mon Aug 24 06:27:49 2020
6
* by pycrc v0.9.2, https://pycrc.org
7
* using the configuration:
8
* - Width = 16
9
* - Poly = 0x3d65
10
* - XorIn = 0x0000
11
* - ReflectIn = True
12
* - XorOut = 0xffff
13
* - ReflectOut = True
14
* - Algorithm = table-driven
15
*/
16
#include "
crc_16_dnp_tbl4bit.h
"
/* include the header file generated with pycrc */
17
#include <stdint.h>
18
#include <stdlib.h>
19
20
/**
21
* Static table used for the table_driven implementation.
22
*/
23
static
const
crc_16_dnp_tbl4bit_t
crc_table
[16] = {
24
0x0000, 0xb26b, 0x29af, 0x9bc4, 0x535e, 0xe135, 0x7af1, 0xc89a,
25
0xa6bc, 0x14d7, 0x8f13, 0x3d78, 0xf5e2, 0x4789, 0xdc4d, 0x6e26};
26
27
crc_16_dnp_tbl4bit_t
crc_16_dnp_tbl4bit_update
(
crc_16_dnp_tbl4bit_t
crc,
28
const
void
*data,
29
size_t
data_len) {
30
const
unsigned
char
*d = (
const
unsigned
char
*)data;
31
unsigned
int
tbl_idx;
32
33
while
(data_len--) {
34
tbl_idx = crc ^ *d;
35
crc =
crc_table
[tbl_idx & 0x0f] ^ (crc >> 4);
36
tbl_idx = crc ^ (*d >> 4);
37
crc =
crc_table
[tbl_idx & 0x0f] ^ (crc >> 4);
38
d++;
39
}
40
return
crc & 0xffff;
41
}
crc_16_dnp_tbl4bit_update
crc_16_dnp_tbl4bit_t crc_16_dnp_tbl4bit_update(crc_16_dnp_tbl4bit_t crc, const void *data, size_t data_len)
Definition
crc_16_dnp_tbl4bit.c:27
crc_table
static const crc_16_dnp_tbl4bit_t crc_table[16]
Definition
crc_16_dnp_tbl4bit.c:23
crc_16_dnp_tbl4bit.h
crc_16_dnp_tbl4bit_t
uint_fast16_t crc_16_dnp_tbl4bit_t
Definition
crc_16_dnp_tbl4bit.h:65
Generated by
1.10.0