Tiny protocol  0.9.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 CONFIG_ENABLE_CHECKSUM
26 #define INITCHECKSUM 0x0000
27 #define GOODCHECKSUM 0x0000
28 uint16_t chksum_byte(uint16_t sum, uint8_t data);
29 uint16_t chksum(uint16_t sum, const uint8_t* data, int data_length);
30 #endif
31 
32 #ifdef CONFIG_ENABLE_FCS16
33 #define PPPINITFCS16 0xffff /* Initial FCS value */
34 #define PPPGOODFCS16 0xf0b8 /* Good final FCS value */
35 uint16_t crc16_byte(uint16_t crc, uint8_t data);
36 uint16_t crc16(uint16_t crc, const uint8_t* data, int data_length);
37 #endif
38 
39 #ifdef CONFIG_ENABLE_FCS32
40 #define PPPINITFCS32 0xffffffff /* Initial FCS value */
41 #define PPPGOODFCS32 0xdebb20e3 /* Good final FCS value */
42 uint32_t crc32_byte(uint32_t crc, uint8_t data);
43 uint32_t crc32(uint32_t crc, const uint8_t *buf, int size);
44 #endif
45 
Tiny protocol Types.