RadioLib Universal wireless communication library for Arduino

FEC.h
1 #if !defined(_RADIOLIB_FEC_H)
2 #define _RADIOLIB_FEC_H
3
4 #include "../TypeDef.h"
5 #include "../Module.h"
6 #if defined(RADIOLIB_BUILD_ARDUINO)
7 #include "../ArduinoHal.h"
8 #endif
9
10 // BCH(31, 21) code constants
11 #define RADIOLIB_PAGER_BCH_N (31)
12 #define RADIOLIB_PAGER_BCH_K (21)
13 #define RADIOLIB_PAGER_BCH_PRIMITIVE_POLY (0x25)
14
15 #if RADIOLIB_STATIC_ONLY
16 #define RADIOLIB_BCH_MAX_N (63)
17 #define RADIOLIB_BCH_MAX_K (31)
18 #endif
19
26 class RadioLibBCH {
27 public:
31 RadioLibBCH();
32
39 void begin(uint8_t n, uint8_t k, uint32_t poly);
40
47 uint32_t encode(uint32_t dataword);
48
49 private:
50 uint8_t n;
51 uint8_t k;
52 uint32_t poly;
53 uint8_t m;
54
55 #if RADIOLIB_STATIC_ONLY
56 int32_t alphaTo[RADIOLIB_BCH_MAX_N + 1];
57 int32_t indexOf[RADIOLIB_BCH_MAX_N + 1];
58 int32_t generator[RADIOLIB_BCH_MAX_N - RADIOLIB_BCH_MAX_K + 1];
59 #else
60 int32_t* alphaTo;
61 int32_t* indexOf;
62 int32_t* generator;
63 #endif
64 };
65
66 // the global singleton
67 extern RadioLibBCH RadioLibBCHInstance;
68
69 #endif
RadioLibBCH
Class to calculate Bose–Chaudhuri–Hocquenghem (BCH) class of forward error correction codes....
Definition: FEC.h:26
RadioLibBCH::RadioLibBCH
RadioLibBCH()
Default constructor.
Definition: FEC.cpp:4
RadioLibBCH::begin
void begin(uint8_t n, uint8_t k, uint32_t poly)
Initialization method.
Definition: FEC.cpp:13
RadioLibBCH::encode
uint32_t encode(uint32_t dataword)
Encoding method - encodes one data word (without check bits) into a code word (with check bits).
Definition: FEC.cpp:186