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.h
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 * This file defines the functions crc_16_dnp_tbl4bit_init(),
17 * crc_16_dnp_tbl4bit_update() and crc_16_dnp_tbl4bit_finalize().
18 *
19 * The crc_16_dnp_tbl4bit_init() function returns the inital \c crc value and
20 * must be called before the first call to crc_16_dnp_tbl4bit_update().
21 * Similarly, the crc_16_dnp_tbl4bit_finalize() function must be called after
22 * the last call to crc_16_dnp_tbl4bit_update(), before the \c crc is being
23 * used. is being used.
24 *
25 * The crc_16_dnp_tbl4bit_update() function can be called any number of times
26 * (including zero times) in between the crc_16_dnp_tbl4bit_init() and
27 * crc_16_dnp_tbl4bit_finalize() calls.
28 *
29 * This pseudo-code shows an example usage of the API:
30 * \code{.c}
31 * crc_16_dnp_tbl4bit_t crc;
32 * unsigned char data[MAX_DATA_LEN];
33 * size_t data_len;
34 *
35 * crc = crc_16_dnp_tbl4bit_init();
36 * while ((data_len = read_data(data, MAX_DATA_LEN)) > 0) {
37 * crc = crc_16_dnp_tbl4bit_update(crc, data, data_len);
38 * }
39 * crc = crc_16_dnp_tbl4bit_finalize(crc);
40 * \endcode
41 */
42#ifndef CRC_16_DNP_TBL4BIT_H
43#define CRC_16_DNP_TBL4BIT_H
44
45#include <stdint.h>
46#include <stdlib.h>
47
48#ifdef __cplusplus
49extern "C" {
50#endif
51
52/**
53 * The definition of the used algorithm.
54 *
55 * This is not used anywhere in the generated code, but it may be used by the
56 * application code to call algorithm-specific code, if desired.
57 */
58#define CRC_ALGO_TABLE_DRIVEN 1
59
60/**
61 * The type of the CRC values.
62 *
63 * This type must be big enough to contain at least 16 bits.
64 */
65typedef uint_fast16_t crc_16_dnp_tbl4bit_t;
66
67/**
68 * Calculate the initial crc value.
69 *
70 * \return The initial crc value.
71 */
73 return 0x0000;
74}
75
76/**
77 * Update the crc value with new data.
78 *
79 * \param[in] crc The current crc value.
80 * \param[in] data Pointer to a buffer of \a data_len bytes.
81 * \param[in] data_len Number of bytes in the \a data buffer.
82 * \return The updated crc value.
83 */
85 const void *data,
86 size_t data_len);
87
88/**
89 * Calculate the final crc value.
90 *
91 * \param[in] crc The current crc value.
92 * \return The final crc value.
93 */
94static inline crc_16_dnp_tbl4bit_t
96 return crc ^ 0xffff;
97}
98
99#ifdef __cplusplus
100} /* closing brace for extern "C" */
101#endif
102
103#endif /* CRC_16_DNP_TBL4BIT_H */
static crc_16_dnp_tbl4bit_t crc_16_dnp_tbl4bit_init(void)
crc_16_dnp_tbl4bit_t crc_16_dnp_tbl4bit_update(crc_16_dnp_tbl4bit_t crc, const void *data, size_t data_len)
uint_fast16_t crc_16_dnp_tbl4bit_t
static crc_16_dnp_tbl4bit_t crc_16_dnp_tbl4bit_finalize(crc_16_dnp_tbl4bit_t crc)