]>
Commit | Line | Data |
---|---|---|
2b1f4228 | 1 | //----------------------------------------------------------------------------- |
2 | // This code is licensed to you under the terms of the GNU GPL, version 2 or, | |
3 | // at your option, any later version. See the LICENSE.txt file for the text of | |
4 | // the license. | |
5 | //----------------------------------------------------------------------------- | |
6 | // Generic CRC calculation code. | |
7 | //----------------------------------------------------------------------------- | |
8 | ||
9 | #ifndef __PARITY_H | |
10 | #define __PARITY_H | |
11 | ||
12 | #include <stdint.h> | |
13 | ||
14 | extern const uint8_t OddByteParity[256]; | |
15 | ||
b351374c | 16 | static inline uint8_t oddparity8(uint8_t bt) |
17 | { | |
18 | return OddByteParity[bt]; | |
19 | } | |
2b1f4228 | 20 | |
21 | ||
22 | extern const uint8_t EvenByteParity[256]; | |
23 | ||
b351374c | 24 | static inline uint8_t evenparity8(const uint8_t bt) |
25 | { | |
26 | return EvenByteParity[bt]; | |
2b1f4228 | 27 | } |
28 | ||
29 | ||
a531720a | 30 | static inline uint8_t evenparity32(uint32_t x) |
2b1f4228 | 31 | { |
32 | x ^= x >> 16; | |
33 | x ^= x >> 8; | |
34 | return EvenByteParity[x & 0xff]; | |
35 | } | |
36 | ||
37 | ||
38 | #endif /* __PARITY_H */ |