[FEC] Reworked macro configuration system
This commit is contained in:
parent
a2e2003001
commit
1d77d8bd55
2 changed files with 15 additions and 15 deletions
|
@ -14,7 +14,7 @@ void RadioLibBCH::begin(uint8_t n, uint8_t k, uint32_t poly) {
|
||||||
this->n = n;
|
this->n = n;
|
||||||
this->k = k;
|
this->k = k;
|
||||||
this->poly = poly;
|
this->poly = poly;
|
||||||
#if !defined(RADIOLIB_STATIC_ONLY)
|
#if !RADIOLIB_STATIC_ONLY
|
||||||
this->alphaTo = new int32_t[n + 1];
|
this->alphaTo = new int32_t[n + 1];
|
||||||
this->indexOf = new int32_t[n + 1];
|
this->indexOf = new int32_t[n + 1];
|
||||||
this->generator = new int32_t[n - k + 1];
|
this->generator = new int32_t[n - k + 1];
|
||||||
|
@ -115,7 +115,7 @@ void RadioLibBCH::begin(uint8_t n, uint8_t k, uint32_t poly) {
|
||||||
|
|
||||||
// Search for roots 1, 2, ..., m-1 in cycle sets
|
// Search for roots 1, 2, ..., m-1 in cycle sets
|
||||||
int32_t rdncy = 0;
|
int32_t rdncy = 0;
|
||||||
#if defined(RADIOLIB_STATIC_ONLY)
|
#if RADIOLIB_STATIC_ONLY
|
||||||
int32_t min[RADIOLIB_BCH_MAX_N - RADIOLIB_BCH_MAX_K + 1];
|
int32_t min[RADIOLIB_BCH_MAX_N - RADIOLIB_BCH_MAX_K + 1];
|
||||||
#else
|
#else
|
||||||
int32_t* min = new int32_t[this->n - this->k + 1];
|
int32_t* min = new int32_t[this->n - this->k + 1];
|
||||||
|
@ -139,7 +139,7 @@ void RadioLibBCH::begin(uint8_t n, uint8_t k, uint32_t poly) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t noterms = kaux;
|
int32_t noterms = kaux;
|
||||||
#if defined(RADIOLIB_STATIC_ONLY)
|
#if RADIOLIB_STATIC_ONLY
|
||||||
int32_t zeros[RADIOLIB_BCH_MAX_N - RADIOLIB_BCH_MAX_K + 1];
|
int32_t zeros[RADIOLIB_BCH_MAX_N - RADIOLIB_BCH_MAX_K + 1];
|
||||||
#else
|
#else
|
||||||
int32_t* zeros = new int32_t[this->n - this->k + 1];
|
int32_t* zeros = new int32_t[this->n - this->k + 1];
|
||||||
|
@ -153,7 +153,7 @@ void RadioLibBCH::begin(uint8_t n, uint8_t k, uint32_t poly) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(RADIOLIB_STATIC_ONLY)
|
#if !RADIOLIB_STATIC_ONLY
|
||||||
delete[] min;
|
delete[] min;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -173,7 +173,7 @@ void RadioLibBCH::begin(uint8_t n, uint8_t k, uint32_t poly) {
|
||||||
this->generator[0] = this->alphaTo[(this->indexOf[this->generator[0]] + zeros[ii]) % this->n];
|
this->generator[0] = this->alphaTo[(this->indexOf[this->generator[0]] + zeros[ii]) % this->n];
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(RADIOLIB_STATIC_ONLY)
|
#if !RADIOLIB_STATIC_ONLY
|
||||||
delete[] zeros;
|
delete[] zeros;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -185,7 +185,7 @@ void RadioLibBCH::begin(uint8_t n, uint8_t k, uint32_t poly) {
|
||||||
*/
|
*/
|
||||||
uint32_t RadioLibBCH::encode(uint32_t dataword) {
|
uint32_t RadioLibBCH::encode(uint32_t dataword) {
|
||||||
// we only use the "k" most significant bits
|
// we only use the "k" most significant bits
|
||||||
#if defined(RADIOLIB_STATIC_ONLY)
|
#if RADIOLIB_STATIC_ONLY
|
||||||
int32_t data[RADIOLIB_BCH_MAX_K];
|
int32_t data[RADIOLIB_BCH_MAX_K];
|
||||||
#else
|
#else
|
||||||
int32_t* data = new int32_t[this->k];
|
int32_t* data = new int32_t[this->k];
|
||||||
|
@ -200,7 +200,7 @@ uint32_t RadioLibBCH::encode(uint32_t dataword) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// reset the M(x)+r array elements
|
// reset the M(x)+r array elements
|
||||||
#if defined(RADIOLIB_STATIC_ONLY)
|
#if RADIOLIB_STATIC_ONLY
|
||||||
int32_t Mr[RADIOLIB_BCH_MAX_N];
|
int32_t Mr[RADIOLIB_BCH_MAX_N];
|
||||||
#else
|
#else
|
||||||
int32_t* Mr = new int32_t[this->n];
|
int32_t* Mr = new int32_t[this->n];
|
||||||
|
@ -227,7 +227,7 @@ uint32_t RadioLibBCH::encode(uint32_t dataword) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(RADIOLIB_STATIC_ONLY)
|
#if RADIOLIB_STATIC_ONLY
|
||||||
int32_t bb[RADIOLIB_BCH_MAX_N - RADIOLIB_BCH_MAX_K + 1];
|
int32_t bb[RADIOLIB_BCH_MAX_N - RADIOLIB_BCH_MAX_K + 1];
|
||||||
#else
|
#else
|
||||||
int32_t* bb = new int32_t[this->n - this->k + 1];
|
int32_t* bb = new int32_t[this->n - this->k + 1];
|
||||||
|
@ -238,12 +238,12 @@ uint32_t RadioLibBCH::encode(uint32_t dataword) {
|
||||||
++j;
|
++j;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(RADIOLIB_STATIC_ONLY)
|
#if !RADIOLIB_STATIC_ONLY
|
||||||
delete[] Mr;
|
delete[] Mr;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int32_t iEvenParity = 0;
|
int32_t iEvenParity = 0;
|
||||||
#if defined(RADIOLIB_STATIC_ONLY)
|
#if RADIOLIB_STATIC_ONLY
|
||||||
int32_t recd[RADIOLIB_BCH_MAX_N + 1];
|
int32_t recd[RADIOLIB_BCH_MAX_N + 1];
|
||||||
#else
|
#else
|
||||||
int32_t* recd = new int32_t[this->n + 1];
|
int32_t* recd = new int32_t[this->n + 1];
|
||||||
|
@ -255,7 +255,7 @@ uint32_t RadioLibBCH::encode(uint32_t dataword) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(RADIOLIB_STATIC_ONLY)
|
#if !RADIOLIB_STATIC_ONLY
|
||||||
delete[] data;
|
delete[] data;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -266,7 +266,7 @@ uint32_t RadioLibBCH::encode(uint32_t dataword) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(RADIOLIB_STATIC_ONLY)
|
#if !RADIOLIB_STATIC_ONLY
|
||||||
delete[] bb;
|
delete[] bb;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -283,7 +283,7 @@ uint32_t RadioLibBCH::encode(uint32_t dataword) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(RADIOLIB_STATIC_ONLY)
|
#if !RADIOLIB_STATIC_ONLY
|
||||||
delete[] recd;
|
delete[] recd;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
#define RADIOLIB_PAGER_BCH_K (21)
|
#define RADIOLIB_PAGER_BCH_K (21)
|
||||||
#define RADIOLIB_PAGER_BCH_PRIMITIVE_POLY (0x25)
|
#define RADIOLIB_PAGER_BCH_PRIMITIVE_POLY (0x25)
|
||||||
|
|
||||||
#if defined(RADIOLIB_STATIC_ONLY)
|
#if RADIOLIB_STATIC_ONLY
|
||||||
#define RADIOLIB_BCH_MAX_N (63)
|
#define RADIOLIB_BCH_MAX_N (63)
|
||||||
#define RADIOLIB_BCH_MAX_K (31)
|
#define RADIOLIB_BCH_MAX_K (31)
|
||||||
#endif
|
#endif
|
||||||
|
@ -52,7 +52,7 @@ class RadioLibBCH {
|
||||||
uint32_t poly;
|
uint32_t poly;
|
||||||
uint8_t m;
|
uint8_t m;
|
||||||
|
|
||||||
#if defined(RADIOLIB_STATIC_ONLY)
|
#if RADIOLIB_STATIC_ONLY
|
||||||
int32_t alphaTo[RADIOLIB_BCH_MAX_N + 1];
|
int32_t alphaTo[RADIOLIB_BCH_MAX_N + 1];
|
||||||
int32_t indexOf[RADIOLIB_BCH_MAX_N + 1];
|
int32_t indexOf[RADIOLIB_BCH_MAX_N + 1];
|
||||||
int32_t generator[RADIOLIB_BCH_MAX_N - RADIOLIB_BCH_MAX_K + 1];
|
int32_t generator[RADIOLIB_BCH_MAX_N - RADIOLIB_BCH_MAX_K + 1];
|
||||||
|
|
Loading…
Add table
Reference in a new issue