Simplify the calculations.

This commit is contained in:
Jonathan Naylor 2020-04-27 12:05:55 +01:00
parent 82dcc44a2d
commit e8ed77241c
4 changed files with 7 additions and 22 deletions

View file

@ -53,7 +53,7 @@ class CFMCTCSSRX {
public:
CFMCTCSSRX();
uint8_t setParams(uint8_t frequency, uint8_t threshold, q15_t rxLevel);
uint8_t setParams(uint8_t frequency, uint8_t threshold, uint8_t level);
CTCSSState process(q15_t sample);
@ -62,25 +62,13 @@ public:
void reset();
private:
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;
q15_t m_rxLevelInverse;
};
#endif