RadioLib
Universal wireless communication library for Arduino
Loading...
Searching...
No Matches
BCH.h
1#if !defined(_RADIOLIB_BCH_H)
2#define _RADIOLIB_BCH_H
3
4#include "../TypeDef.h"
5#include "../Module.h"
6
7// BCH(31, 21) code constants
8#define RADIOLIB_PAGER_BCH_N (31)
9#define RADIOLIB_PAGER_BCH_K (21)
10#define RADIOLIB_PAGER_BCH_PRIMITIVE_POLY (0x25)
11
12#if RADIOLIB_STATIC_ONLY
13#define RADIOLIB_BCH_MAX_N (63)
14#define RADIOLIB_BCH_MAX_K (31)
15#endif
16
24 public:
29
34
41 void begin(uint8_t n, uint8_t k, uint32_t poly);
42
49 uint32_t encode(uint32_t dataword);
50
51 private:
52 uint8_t n = 0;
53 uint8_t k = 0;
54 uint32_t poly = 0;
55 uint8_t m = 0;
56
57 #if RADIOLIB_STATIC_ONLY
58 int32_t alphaTo[RADIOLIB_BCH_MAX_N + 1] = { 0 };
59 int32_t indexOf[RADIOLIB_BCH_MAX_N + 1] = { 0 };
60 int32_t generator[RADIOLIB_BCH_MAX_N - RADIOLIB_BCH_MAX_K + 1] = { 0 };
61 #else
62 int32_t* alphaTo = nullptr;
63 int32_t* indexOf = nullptr;
64 int32_t* generator = nullptr;
65 #endif
66};
67
68#endif
Class to calculate Bose–Chaudhuri–Hocquenghem (BCH) class of forward error correction codes....
Definition BCH.h:23
RadioLibBCH()
Default constructor.
Definition BCH.cpp:4
void begin(uint8_t n, uint8_t k, uint32_t poly)
Initialization method.
Definition BCH.cpp:21
~RadioLibBCH()
Default destructor.
Definition BCH.cpp:8
uint32_t encode(uint32_t dataword)
Encoding method - encodes one data word (without check bits) into a code word (with check bits).
Definition BCH.cpp:200