From f1d6a8b36ea036a86382c7d996d9c9831d04a979 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Mon, 6 Jul 2020 10:03:48 +0100 Subject: [PATCH] Add DCD LED control. --- AX25Demodulator.cpp | 14 ++++++-------- AX25RX.cpp | 34 +++++++++++++++++++++++----------- AX25RX.h | 1 + 3 files changed, 30 insertions(+), 19 deletions(-) diff --git a/AX25Demodulator.cpp b/AX25Demodulator.cpp index df3e13c..276a8e6 100644 --- a/AX25Demodulator.cpp +++ b/AX25Demodulator.cpp @@ -177,14 +177,12 @@ bool CAX25Demodulator::PLL(bool input) float32_t jitter; ::arm_fir_f32(&m_pllFilter, &offset, &jitter, 1U); - if (!m_duplex) { - float32_t absOffset = adjust; - if (offset < 0.0F) - absOffset -= offset; - else - absOffset += offset; - m_pllJitter = iir(absOffset); - } + float32_t absOffset = adjust; + if (offset < 0.0F) + absOffset -= offset; + else + absOffset += offset; + m_pllJitter = iir(absOffset); m_pllCount -= jitter / 2.0F; m_pllBits = 1U; diff --git a/AX25RX.cpp b/AX25RX.cpp index 4836701..093316b 100644 --- a/AX25RX.cpp +++ b/AX25RX.cpp @@ -69,6 +69,7 @@ m_count(0U), m_slotTime(30U), m_slotCount(0U), m_pPersist(128U), +m_dcd(false), m_canTX(false), m_x(1U), m_a(0xB7U), @@ -121,19 +122,30 @@ void CAX25RX::samples(q15_t* samples, uint8_t length) DEBUG1("Decoder 3 reported"); } - if (!m_duplex) { - m_slotCount += RX_BLOCK_SIZE; - if (m_slotCount >= m_slotTime) { - m_slotCount = 0U; + m_slotCount += RX_BLOCK_SIZE; + if (m_slotCount >= m_slotTime) { + m_slotCount = 0U; - bool dcd1 = m_demod1.isDCD(); - bool dcd2 = m_demod2.isDCD(); - bool dcd3 = m_demod3.isDCD(); + bool dcd1 = m_demod1.isDCD(); + bool dcd2 = m_demod2.isDCD(); + bool dcd3 = m_demod3.isDCD(); - if (dcd1 || dcd2 || dcd3) - m_canTX = false; - else - m_canTX = m_pPersist >= rand(); + if (dcd1 || dcd2 || dcd3) { + if (!m_dcd) { + io.setDecode(true); + io.setADCDetection(true); + m_dcd = true; + } + + m_canTX = false; + } else { + if (m_dcd) { + io.setDecode(false); + io.setADCDetection(false); + m_dcd = false; + } + + m_canTX = m_pPersist >= rand(); } } } diff --git a/AX25RX.h b/AX25RX.h index 49186d2..cbafe91 100644 --- a/AX25RX.h +++ b/AX25RX.h @@ -44,6 +44,7 @@ private: uint32_t m_slotTime; uint32_t m_slotCount; uint8_t m_pPersist; + bool m_dcd; bool m_canTX; uint8_t m_x; uint8_t m_a;