mirror of
https://github.com/g4klx/MMDVM.git
synced 2026-08-21 14:36:21 +02:00
Move division to CTCSSRX, change sample unscaling to 1/rxLevel
This commit is contained in:
+20
-7
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user