From eb9c0dfd934864afb1e222b4ad679ba9d2af208b Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Wed, 6 May 2020 11:34:04 +0100 Subject: [PATCH] Allow for the inversion of COS levels. --- FM.cpp | 13 ++++++++++--- FM.h | 3 ++- SerialPort.cpp | 5 +++-- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/FM.cpp b/FM.cpp index 36200b4..70b6b6a 100644 --- a/FM.cpp +++ b/FM.cpp @@ -44,6 +44,7 @@ m_preemphasis(32768, 13967, 0, 32768, -18801, 0),//75µS 24kHz sampling rate m_deemphasis (32768, -18801, 0, 32768, 13967, 0),//75µS 24kHz sampling rate m_blanking(), m_useCOS(true), +m_cosInvert(false), m_rfAudioBoost(1U), m_downsampler(128)//Size might need adjustement { @@ -51,8 +52,12 @@ m_downsampler(128)//Size might need adjustement void CFM::samples(bool cos, q15_t* samples, uint8_t length) { - if (!m_useCOS) + if (m_useCOS) { + if (m_cosInvert) + cos = !cos; + } else { cos = true; + } clock(length); @@ -169,9 +174,11 @@ uint8_t CFM::setAck(const char* rfAck, uint8_t speed, uint16_t frequency, uint8_ return m_rfAck.setParams(rfAck, speed, frequency, level, level); } -uint8_t CFM::setMisc(uint16_t timeout, uint8_t timeoutLevel, uint8_t ctcssFrequency, uint8_t ctcssThreshold, uint8_t ctcssLevel, uint8_t kerchunkTime, uint8_t hangTime, bool useCOS, uint8_t rfAudioBoost, uint8_t maxDev, uint8_t rxLevel) +uint8_t CFM::setMisc(uint16_t timeout, uint8_t timeoutLevel, uint8_t ctcssFrequency, uint8_t ctcssThreshold, uint8_t ctcssLevel, uint8_t kerchunkTime, uint8_t hangTime, bool useCOS, bool cosInvert, uint8_t rfAudioBoost, uint8_t maxDev, uint8_t rxLevel) { - m_useCOS = useCOS; + m_useCOS = useCOS; + m_cosInvert = cosInvert; + m_rfAudioBoost = q15_t(rfAudioBoost); m_timeoutTimer.setTimeout(timeout, 0U); diff --git a/FM.h b/FM.h index 7e2e79f..9e15c8a 100644 --- a/FM.h +++ b/FM.h @@ -55,7 +55,7 @@ public: uint8_t setCallsign(const char* callsign, uint8_t speed, uint16_t frequency, uint8_t time, uint8_t holdoff, uint8_t highLevel, uint8_t lowLevel, bool callsignAtStart, bool callsignAtEnd, bool callsignAtLatch); uint8_t setAck(const char* rfAck, uint8_t speed, uint16_t frequency, uint8_t minTime, uint16_t delay, uint8_t level); - uint8_t setMisc(uint16_t timeout, uint8_t timeoutLevel, uint8_t ctcssFrequency, uint8_t ctcssThreshold, uint8_t ctcssLevel, uint8_t kerchunkTime, uint8_t hangTime, bool useCOS, uint8_t rfAudioBoost, uint8_t maxDev, uint8_t rxLevel); + uint8_t setMisc(uint16_t timeout, uint8_t timeoutLevel, uint8_t ctcssFrequency, uint8_t ctcssThreshold, uint8_t ctcssLevel, uint8_t kerchunkTime, uint8_t hangTime, bool useCOS, bool cosInvert, uint8_t rfAudioBoost, uint8_t maxDev, uint8_t rxLevel); private: CFMKeyer m_callsign; @@ -81,6 +81,7 @@ private: CFMDirectFormI m_deemphasis; CFMBlanking m_blanking; bool m_useCOS; + bool m_cosInvert; q15_t m_rfAudioBoost; CFMDownsampler m_downsampler; diff --git a/SerialPort.cpp b/SerialPort.cpp index 190e105..711ba6e 100644 --- a/SerialPort.cpp +++ b/SerialPort.cpp @@ -101,7 +101,7 @@ const uint8_t MMDVM_DEBUG5 = 0xF5U; #define HW_TYPE "MMDVM" #endif -#define DESCRIPTION "20200504 (D-Star/DMR/System Fusion/P25/NXDN/POCSAG/FM)" +#define DESCRIPTION "20200506 (D-Star/DMR/System Fusion/P25/NXDN/POCSAG/FM)" #if defined(GITVERSION) #define concat(h, a, b, c) h " " a " " b " GitID #" c "" @@ -423,12 +423,13 @@ uint8_t CSerialPort::setFMParams3(const uint8_t* data, uint8_t length) uint8_t hangTime = data[6U]; bool useCOS = (data[7U] & 0x01U) == 0x01U; + bool cosInvert = (data[7U] & 0x02U) == 0x02U; uint8_t rfAudioBoost = data[8U]; uint8_t maxDev = data[9U]; uint8_t rxLevel = data[10U]; - return fm.setMisc(timeout, timeoutLevel, ctcssFrequency, ctcssThreshold, ctcssLevel, kerchunkTime, hangTime, useCOS, rfAudioBoost, maxDev, rxLevel); + return fm.setMisc(timeout, timeoutLevel, ctcssFrequency, ctcssThreshold, ctcssLevel, kerchunkTime, hangTime, useCOS, cosInvert, rfAudioBoost, maxDev, rxLevel); } uint8_t CSerialPort::setMode(const uint8_t* data, uint8_t length)