Remove the DC blocker from DMR.

This commit is contained in:
Jonathan Naylor 2017-07-31 21:54:26 +01:00
parent ba81fa7396
commit 669acb99e8
8 changed files with 99 additions and 50 deletions

View file

@ -241,6 +241,10 @@ 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,8 +261,16 @@ m_pathMemory2(),
m_pathMemory3(),
m_fecOutput(),
m_rssiAccum(0U),
m_rssiCount(0U)
m_rssiCount(0U),
m_dcFilter(),
m_dcState()
{
::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()
@ -273,13 +285,24 @@ void CDStarRX::reset()
m_rssiCount = 0U;
}
void CDStarRX::samples(const q15_t* samples, const uint16_t* rssi, uint8_t length)
{
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 = samples[i] < 0;
bool bit = (q31Samples[i] - dcLevel) < 0;
if (bit != m_prev) {
if (m_pll < (PLLMAX / 2U))