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_bbf.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 = bit-by-bit-fast
15 */
16#include "crc_16_dnp_bbf.h" /* include the header file generated with pycrc */
17#include <stdbool.h>
18#include <stdint.h>
19#include <stdlib.h>
20
22 size_t data_len) {
23 unsigned int i;
25
26 ret = data & 0x01;
27 for (i = 1; i < data_len; i++) {
28 data >>= 1;
29 ret = (ret << 1) | (data & 0x01);
30 }
31 return ret;
32}
33
35 size_t data_len) {
36 const unsigned char *d = (const unsigned char *)data;
37 unsigned int i;
38 bool bit;
39 unsigned char c;
40
41 while (data_len--) {
42 c = *d++;
43 for (i = 0x01; i & 0xff; i <<= 1) {
44 bit = crc & 0x8000;
45 if (c & i) {
46 bit = !bit;
47 }
48 crc <<= 1;
49 if (bit) {
50 crc ^= 0x3d65;
51 }
52 }
53 crc &= 0xffff;
54 }
55 return crc & 0xffff;
56}
crc_16_dnp_bbf_t crc_16_dnp_bbf_update(crc_16_dnp_bbf_t crc, const void *data, size_t data_len)
crc_16_dnp_bbf_t crc_16_dnp_bbf_reflect(crc_16_dnp_bbf_t data, size_t data_len)
uint_fast16_t crc_16_dnp_bbf_t