-
Notifications
You must be signed in to change notification settings - Fork 20
/
crc.h
29 lines (25 loc) · 978 Bytes
/
crc.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#ifndef CRC_H
#define CRC_H
#include <inttypes.h>
/*
* Copyright © 2010-2015, Matthias Urlichs <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License (included; see the file LICENSE)
* for more details.
*/
/* Incrementally calculate CRC.
Initially, 'crc' is zero.
Calculate crc=crc16(crc,byte) for each byte sent/received.
After sending the last data byte, send crc^0xFFFF (LSB first).
After receiving data+crc, crc should be 0xB001.
*/
uint16_t crc16(uint16_t crc, uint8_t x);
#endif // crc.h