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