-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcrc16.h
66 lines (46 loc) · 739 Bytes
/
crc16.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include <inttypes.h>
/*
Based on information from
http://www.nongnu.org/avr-libc/user-manual/group__util__crc.html
*/
#ifndef __CRC16_H__
#define __CRC16_H__
#ifdef AVR
#include <util/crc16.h>
#endif
struct CRC16_ccitt
{
typedef uint16_t crc_t;
crc_t crc;
inline void reset()
{
crc = 0xffff;
}
void update(uint8_t data);
inline crc_t get() {
return crc;
}
};
struct CRC16 {
typedef uint16_t crc_t;
crc_t crc;
inline void reset() {
crc = 0xffff;
}
void update(uint8_t data);
inline crc_t get() {
return crc;
}
};
struct CRC16_rfc1549 {
typedef uint16_t crc_t;
crc_t crc;
inline void reset() {
crc = 0xffff;
}
void update(uint8_t data);
inline crc_t get() {
return ~crc;
}
};
#endif