From 43f84ae9689346c33f029ef454062c94dbe297f1 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Mon, 29 Jun 2020 15:59:46 +0100 Subject: [PATCH] Simplify the pre-emphasis code for AX.25. --- AX25TX.cpp | 20 +++++++++++--------- AX25TX.h | 3 --- SerialPort.cpp | 2 +- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/AX25TX.cpp b/AX25TX.cpp index da4a002..3296288 100644 --- a/AX25TX.cpp +++ b/AX25TX.cpp @@ -49,7 +49,6 @@ const q15_t AUDIO_TABLE_DATA[] = { }; CAX25TX::CAX25TX() : -m_twist(-6), m_poBuffer(), m_poLen(0U), m_poPtr(0U), @@ -138,22 +137,25 @@ uint8_t CAX25TX::writeData(const uint8_t* data, uint16_t length) void CAX25TX::writeBit(bool b) { - q15_t in[AX25_RADIO_SYMBOL_LENGTH]; + q15_t buffer[AX25_RADIO_SYMBOL_LENGTH]; for (uint8_t i = 0U; i < AX25_RADIO_SYMBOL_LENGTH; i++) { - in[i] = AUDIO_TABLE_DATA[m_tablePtr]; - if (b) + q15_t value = AUDIO_TABLE_DATA[m_tablePtr]; + + if (b) { m_tablePtr += 11U; - else + } else { + // De-emphasise the lower frequency by 6dB + value >>= 2; m_tablePtr += 6U; + } + + buffer[i] = value; if (m_tablePtr >= AUDIO_TABLE_LEN) m_tablePtr -= AUDIO_TABLE_LEN; } - q15_t out[AX25_RADIO_SYMBOL_LENGTH]; - m_twist.process(in, out, AX25_RADIO_SYMBOL_LENGTH); - - io.write(STATE_AX25, out, AX25_RADIO_SYMBOL_LENGTH); + io.write(STATE_AX25, buffer, AX25_RADIO_SYMBOL_LENGTH); } void CAX25TX::setTXDelay(uint8_t delay) diff --git a/AX25TX.h b/AX25TX.h index 2c8eb8b..0a41757 100644 --- a/AX25TX.h +++ b/AX25TX.h @@ -21,8 +21,6 @@ #include "Config.h" -#include "AX25Twist.h" - class CAX25TX { public: CAX25TX(); @@ -36,7 +34,6 @@ public: uint8_t getSpace() const; private: - CAX25Twist m_twist; uint8_t m_poBuffer[600U]; uint16_t m_poLen; uint16_t m_poPtr; diff --git a/SerialPort.cpp b/SerialPort.cpp index 7a81dc9..390338a 100644 --- a/SerialPort.cpp +++ b/SerialPort.cpp @@ -109,7 +109,7 @@ const uint8_t MMDVM_DEBUG5 = 0xF5U; #define HW_TYPE "MMDVM" #endif -#define DESCRIPTION "20200628 (D-Star/DMR/System Fusion/P25/NXDN/POCSAG/FM/AX.25)" +#define DESCRIPTION "20200629 (D-Star/DMR/System Fusion/P25/NXDN/POCSAG/FM/AX.25)" #if defined(GITVERSION) #define concat(h, a, b, c) h " " a " " b " GitID #" c ""