RadioLib Universal wireless communication library for Arduino

CRC.h
1 #if !defined(_RADIOLIB_CRC_H)
2 #define _RADIOLIB_CRC_H
3
4 #include "../TypeDef.h"
5 #include "../Module.h"
6 #if defined(RADIOLIB_BUILD_ARDUINO)
7 #include "../ArduinoHal.h"
8 #endif
9
10 // CCITT CRC properties (used by AX.25)
11 #define RADIOLIB_CRC_CCITT_POLY (0x1021)
12 #define RADIOLIB_CRC_CCITT_INIT (0xFFFF)
13 #define RADIOLIB_CRC_CCITT_OUT (0xFFFF)
14
19 class RadioLibCRC {
20 public:
24 uint8_t size;
25
29 uint32_t poly;
30
34 uint32_t init;
35
39 uint32_t out;
40
44 bool refIn;
45
49 bool refOut;
50
54 RadioLibCRC();
55
62 uint32_t checksum(uint8_t* buff, size_t len);
63 };
64
65 // the global singleton
66 extern RadioLibCRC RadioLibCRCInstance;
67
68 #endif
RadioLibCRC
Class to calculate CRCs of varying formats.
Definition: CRC.h:19
RadioLibCRC::checksum
uint32_t checksum(uint8_t *buff, size_t len)
Calculate checksum of a buffer.
Definition: CRC.cpp:7
RadioLibCRC::out
uint32_t out
Final XOR value.
Definition: CRC.h:39
RadioLibCRC::RadioLibCRC
RadioLibCRC()
Default constructor.
Definition: CRC.cpp:3
RadioLibCRC::init
uint32_t init
Initial value.
Definition: CRC.h:34
RadioLibCRC::refOut
bool refOut
Whether to reflect the result.
Definition: CRC.h:49
RadioLibCRC::refIn
bool refIn
Whether to reflect input bytes.
Definition: CRC.h:44
RadioLibCRC::size
uint8_t size
CRC size in bits.
Definition: CRC.h:24
RadioLibCRC::poly
uint32_t poly
CRC polynomial.
Definition: CRC.h:29