sketchbook
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
crc.h
Go to the documentation of this file.
1 #ifndef CRC_H
2 #define CRC_H
3 
4 #include <inttypes.h>
5 
6 /*
7  * Copyright © 2010-2015, Matthias Urlichs <matthias@urlichs.de>
8  *
9  * This program is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation, either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License (included; see the file LICENSE)
18  * for more details.
19  */
20 
21 /* Incrementally calculate CRC.
22  Initially, 'crc' is zero.
23  Calculate crc=crc16(crc,byte) for each byte sent/received.
24  After sending the last data byte, send crc^0xFFFF (LSB first).
25  After receiving data+crc, crc should be 0xB001.
26  */
27 uint16_t crc16(uint16_t crc, uint8_t x);
28 
29 #endif // crc.h
uint16_t crc16(uint16_t crc, uint8_t x)
Definition: crc.c:24