mirror of
https://github.com/g4klx/MMDVM.git
synced 2026-05-07 13:37:48 +00:00
Optimise the DC offset code.
This commit is contained in:
parent
04ca97e5f8
commit
74682e7ac0
8 changed files with 44 additions and 90 deletions
27
DStarRX.cpp
27
DStarRX.cpp
|
|
@ -237,10 +237,6 @@ const uint16_t CCITT_TABLE[] = {
|
|||
0xf78fU, 0xe606U, 0xd49dU, 0xc514U, 0xb1abU, 0xa022U, 0x92b9U, 0x8330U,
|
||||
0x7bc7U, 0x6a4eU, 0x58d5U, 0x495cU, 0x3de3U, 0x2c6aU, 0x1ef1U, 0x0f78U};
|
||||
|
||||
// Generated using [b, a] = butter(1, 0.001) in MATLAB
|
||||
static q31_t DC_FILTER[] = {3367972, 0, 3367972, 0, 2140747704, 0}; // {b0, 0, b1, b2, -a1, -a2}
|
||||
const uint32_t DC_FILTER_STAGES = 1U; // One Biquad stage
|
||||
|
||||
CDStarRX::CDStarRX() :
|
||||
m_pll(0U),
|
||||
m_prev(false),
|
||||
|
|
@ -257,16 +253,8 @@ m_pathMemory2(),
|
|||
m_pathMemory3(),
|
||||
m_fecOutput(),
|
||||
m_rssiAccum(0U),
|
||||
m_rssiCount(0U),
|
||||
m_dcFilter(),
|
||||
m_dcState()
|
||||
m_rssiCount(0U)
|
||||
{
|
||||
::memset(m_dcState, 0x00U, 4U * sizeof(q31_t));
|
||||
|
||||
m_dcFilter.numStages = DC_FILTER_STAGES;
|
||||
m_dcFilter.pState = m_dcState;
|
||||
m_dcFilter.pCoeffs = DC_FILTER;
|
||||
m_dcFilter.postShift = 0;
|
||||
}
|
||||
|
||||
void CDStarRX::reset()
|
||||
|
|
@ -283,22 +271,11 @@ void CDStarRX::reset()
|
|||
|
||||
void CDStarRX::samples(q15_t* samples, const uint16_t* rssi, uint8_t length)
|
||||
{
|
||||
q31_t dcLevel = 0;
|
||||
q31_t dcVals[20U];
|
||||
q31_t q31Samples[20U];
|
||||
|
||||
::arm_q15_to_q31(samples, q31Samples, length);
|
||||
::arm_biquad_cascade_df1_q31(&m_dcFilter, q31Samples, dcVals, length);
|
||||
|
||||
for (uint8_t i = 0U; i < length; i++)
|
||||
dcLevel += dcVals[i];
|
||||
dcLevel /= length;
|
||||
|
||||
for (uint16_t i = 0U; i < length; i++) {
|
||||
m_rssiAccum += rssi[i];
|
||||
m_rssiCount++;
|
||||
|
||||
bool bit = (q31Samples[i] - dcLevel) < 0;
|
||||
bool bit = samples[i] < 0;
|
||||
|
||||
if (bit != m_prev) {
|
||||
if (m_pll < (PLLMAX / 2U))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue