Tiny protocol  0.11.0
Tiny communication protocol for microcontrollers
crc.h
1 /*
2  Copyright 2016-2019 (C) Alexey Dynda
3 
4  This file is part of Tiny Protocol Library.
5 
6  Protocol Library is free software: you can redistribute it and/or modify
7  it under the terms of the GNU Lesser General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  Protocol Library is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU Lesser General Public License for more details.
15 
16  You should have received a copy of the GNU Lesser General Public License
17  along with Protocol Library. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #pragma once
21 
22 #include <stdint.h>
23 #include "proto/hal/tiny_types.h"
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 #ifdef CONFIG_ENABLE_CHECKSUM
30 #define INITCHECKSUM 0x0000
31 #define GOODCHECKSUM 0x0000
32 uint16_t chksum_byte(uint16_t sum, uint8_t data);
33 uint16_t chksum(uint16_t sum, const uint8_t* data, int data_length);
34 #endif
35 
36 #ifdef CONFIG_ENABLE_FCS16
37 #define PPPINITFCS16 0xffff /* Initial FCS value */
38 #define PPPGOODFCS16 0xf0b8 /* Good final FCS value */
39 uint16_t crc16_byte(uint16_t crc, uint8_t data);
40 uint16_t crc16(uint16_t crc, const uint8_t* data, int data_length);
41 #endif
42 
43 #ifdef CONFIG_ENABLE_FCS32
44 #define PPPINITFCS32 0xffffffff /* Initial FCS value */
45 #define PPPGOODFCS32 0xdebb20e3 /* Good final FCS value */
46 uint32_t crc32_byte(uint32_t crc, uint8_t data);
47 uint32_t crc32(uint32_t crc, const uint8_t *buf, int size);
48 #endif
49 
50 #ifdef __cplusplus
51 }
52 #endif
Tiny protocol Types.