Pass the RX level to the FM controller.

This commit is contained in:
Jonathan Naylor 2020-04-26 22:01:11 +01:00
parent d66c6d7f9c
commit f9530ee82a
5 changed files with 16 additions and 18 deletions

17
FM.cpp
View File

@ -41,7 +41,8 @@ m_filterStage2(32768, 0,-32768, 32768, -50339, 19052),
m_filterStage3(32768, -65536, 32768, 32768, -64075, 31460), m_filterStage3(32768, -65536, 32768, 32768, -64075, 31460),
m_blanking(), m_blanking(),
m_useCOS(true), m_useCOS(true),
m_rxBoost(1U) m_rxBoost(1U),
m_rxLevel(128 * 128)
{ {
} }
@ -144,10 +145,11 @@ uint8_t CFM::setAck(const char* rfAck, uint8_t speed, uint16_t frequency, uint8_
return m_rfAck.setParams(rfAck, speed, frequency, level, level); 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 rxBoost, uint8_t maxDev) 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 rxBoost, uint8_t maxDev, uint8_t rxLevel)
{ {
m_useCOS = useCOS; m_useCOS = useCOS;
m_rxBoost = q15_t(rxBoost); m_rxBoost = q15_t(rxBoost);
m_rxLevel = q15_t(rxLevel * 128);
m_timeoutTimer.setTimeout(timeout, 0U); m_timeoutTimer.setTimeout(timeout, 0U);
m_kerchunkTimer.setTimeout(kerchunkTime, 0U); m_kerchunkTimer.setTimeout(kerchunkTime, 0U);
@ -401,13 +403,14 @@ void CFM::beginRelaying()
q15_t CFM::getUnscaledSample(q15_t sample) q15_t CFM::getUnscaledSample(q15_t sample)
{ {
// sample / rxLevel // sample / rxLevel
q15_t rxLevel = io.getRxLevel();
q31_t sample31 = q31_t(sample) << 16; q31_t sample31 = q31_t(sample) << 16;
if (((sample31 >> 31) & 1) == ((rxLevel >> 15) & 1))
sample31 += rxLevel >> 1; if (((sample31 >> 31) & 1) == ((m_rxLevel >> 15) & 1))
sample31 += m_rxLevel >> 1;
else else
sample31 -= rxLevel >> 1; sample31 -= m_rxLevel >> 1;
sample31 /= rxLevel;
sample31 /= m_rxLevel;
return q15_t(sample31); return q15_t(sample31);
} }

3
FM.h
View File

@ -54,7 +54,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); 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);
uint8_t setAck(const char* rfAck, uint8_t speed, uint16_t frequency, uint8_t minTime, uint16_t delay, uint8_t level); 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 rxBoost, uint8_t maxDev); 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 rxBoost, uint8_t maxDev, uint8_t rxLevel);
private: private:
CFMKeyer m_callsign; CFMKeyer m_callsign;
@ -78,6 +78,7 @@ private:
CFMBlanking m_blanking; CFMBlanking m_blanking;
bool m_useCOS; bool m_useCOS;
q15_t m_rxBoost; q15_t m_rxBoost;
q15_t m_rxLevel;
void stateMachine(bool validSignal, uint8_t length); void stateMachine(bool validSignal, uint8_t length);
void listeningState(bool validSignal); void listeningState(bool validSignal);

5
IO.cpp
View File

@ -592,8 +592,3 @@ bool CIO::hasLockout() const
{ {
return m_lockout; return m_lockout;
} }
q15_t CIO::getRxLevel() const
{
return m_rxLevel;
}

4
IO.h
View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2015,2016,2017,2018 by Jonathan Naylor G4KLX * Copyright (C) 2015,2016,2017,2018,2020 by Jonathan Naylor G4KLX
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -56,8 +56,6 @@ public:
void selfTest(); void selfTest();
q15_t getRxLevel() const;
private: private:
bool m_started; bool m_started;

View File

@ -408,7 +408,7 @@ uint8_t CSerialPort::setFMParams2(const uint8_t* data, uint8_t length)
uint8_t CSerialPort::setFMParams3(const uint8_t* data, uint8_t length) uint8_t CSerialPort::setFMParams3(const uint8_t* data, uint8_t length)
{ {
if (length < 10U) if (length < 11U)
return 4U; return 4U;
uint16_t timeout = data[0U] * 5U; uint16_t timeout = data[0U] * 5U;
@ -425,8 +425,9 @@ uint8_t CSerialPort::setFMParams3(const uint8_t* data, uint8_t length)
uint8_t rxBoost = data[8U]; uint8_t rxBoost = data[8U];
uint8_t maxDev = data[9U]; uint8_t maxDev = data[9U];
uint8_t rxLevel = data[10U];
return fm.setMisc(timeout, timeoutLevel, ctcssFrequency, ctcssThreshold, ctcssLevel, kerchunkTime, hangTime, useCOS, rxBoost, maxDev); return fm.setMisc(timeout, timeoutLevel, ctcssFrequency, ctcssThreshold, ctcssLevel, kerchunkTime, hangTime, useCOS, rxBoost, maxDev, rxLevel);
} }
uint8_t CSerialPort::setMode(const uint8_t* data, uint8_t length) uint8_t CSerialPort::setMode(const uint8_t* data, uint8_t length)