mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-07-29 01:29:03 -04:00
Refactor bit pattern matching.
Remove AccessCodeCorrelator, Unstuff classes.
This commit is contained in:
parent
f918a774b7
commit
36689f5c45
10 changed files with 116 additions and 150 deletions
|
@ -39,33 +39,6 @@ private:
|
|||
uint_fast8_t last { 0 };
|
||||
};
|
||||
|
||||
class Unstuff {
|
||||
public:
|
||||
uint_fast8_t is_stuffing_bit(const uint_fast8_t symbol) {
|
||||
history = (history << 1) | (symbol & 1);
|
||||
return (history & mask) == match;
|
||||
}
|
||||
|
||||
void configure(
|
||||
const uint32_t pattern,
|
||||
const size_t length
|
||||
) {
|
||||
// Ensure that length=0 (unstuffing disabled) never matches.
|
||||
match = length ? pattern : 1;
|
||||
mask = (1U << length) - 1;
|
||||
reset();
|
||||
}
|
||||
|
||||
void reset() {
|
||||
history = 0;
|
||||
}
|
||||
|
||||
private:
|
||||
uint32_t history { 0 };
|
||||
uint32_t match { 0b111110 };
|
||||
uint32_t mask { 0b111111 };
|
||||
};
|
||||
|
||||
} /* namespace symbol_coding */
|
||||
|
||||
#endif/*__SYMBOL_CODING_H__*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue