mirror of
https://github.com/g4klx/MMDVM.git
synced 2026-04-04 14:08:33 +00:00
Move division to CTCSSRX, change sample unscaling to 1/rxLevel
This commit is contained in:
parent
f9530ee82a
commit
4ffaa62855
4 changed files with 31 additions and 27 deletions
27
FMCTCSSRX.h
27
FMCTCSSRX.h
|
|
@ -53,7 +53,7 @@ class CFMCTCSSRX {
|
|||
public:
|
||||
CFMCTCSSRX();
|
||||
|
||||
uint8_t setParams(uint8_t frequency, uint8_t threshold);
|
||||
uint8_t setParams(uint8_t frequency, uint8_t threshold, q15_t rxLevel);
|
||||
|
||||
CTCSSState process(q15_t sample);
|
||||
|
||||
|
|
@ -62,12 +62,25 @@ public:
|
|||
void reset();
|
||||
|
||||
private:
|
||||
q63_t m_coeffDivTwo;
|
||||
q31_t m_threshold;
|
||||
uint16_t m_count;
|
||||
q31_t m_q0;
|
||||
q31_t m_q1;
|
||||
CTCSSState m_result;
|
||||
static inline q15_t q15Division(q15_t a, q15_t divisor)
|
||||
{
|
||||
q31_t a31 = q31_t(a) << 16;
|
||||
|
||||
if (((a >> 31) & 1) == ((divisor >> 15) & 1))
|
||||
a31 += divisor >> 1;
|
||||
else
|
||||
a31 -= divisor >> 1;
|
||||
|
||||
return a31 / divisor;
|
||||
}
|
||||
|
||||
q63_t m_coeffDivTwo;
|
||||
q31_t m_threshold;
|
||||
uint16_t m_count;
|
||||
q31_t m_q0;
|
||||
q31_t m_q1;
|
||||
CTCSSState m_result;
|
||||
q31_t m_rxLevelInverse;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue