mirror of https://github.com/g4klx/MMDVM.git
Merge remote-tracking branch 'upstream/FM' into FM
This commit is contained in:
commit
980c529107
20
FM.cpp
20
FM.cpp
|
@ -54,7 +54,7 @@ void CFM::samples(bool cos, q15_t* samples, uint8_t length)
|
|||
for (; i < length; i++) {
|
||||
q15_t currentSample = samples[i];//save to a local variable to avoid indirection on every access
|
||||
|
||||
CTCSSState ctcssState = m_ctcssRX.process(getUnscaledSample(currentSample));
|
||||
CTCSSState ctcssState = m_ctcssRX.process(currentSample);
|
||||
|
||||
if (CTCSS_NOT_READY(ctcssState) && m_modemState != STATE_FM) {
|
||||
//Not enough samples to determine if you have CTCSS, just carry on
|
||||
|
@ -144,7 +144,7 @@ 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 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_rxBoost = q15_t(rxBoost);
|
||||
|
@ -156,7 +156,7 @@ uint8_t CFM::setMisc(uint16_t timeout, uint8_t timeoutLevel, uint8_t ctcssFreque
|
|||
m_timeoutTone.setParams(timeoutLevel);
|
||||
m_blanking.setParams(maxDev, timeoutLevel);
|
||||
|
||||
uint8_t ret = m_ctcssRX.setParams(ctcssFrequency, ctcssThreshold);
|
||||
uint8_t ret = m_ctcssRX.setParams(ctcssFrequency, ctcssThreshold, rxLevel);
|
||||
if (ret != 0U)
|
||||
return ret;
|
||||
|
||||
|
@ -397,17 +397,3 @@ void CFM::beginRelaying()
|
|||
m_timeoutTimer.start();
|
||||
m_ackMinTimer.start();
|
||||
}
|
||||
|
||||
q15_t CFM::getUnscaledSample(q15_t sample)
|
||||
{
|
||||
// sample / rxLevel
|
||||
q15_t rxLevel = io.getRxLevel();
|
||||
q31_t sample31 = q31_t(sample) << 16;
|
||||
if (((sample31 >> 31) & 1) == ((rxLevel >> 15) & 1))
|
||||
sample31 += rxLevel >> 1;
|
||||
else
|
||||
sample31 -= rxLevel >> 1;
|
||||
sample31 /= rxLevel;
|
||||
|
||||
return q15_t(sample31);
|
||||
}
|
||||
|
|
4
FM.h
4
FM.h
|
@ -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 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:
|
||||
CFMKeyer m_callsign;
|
||||
|
@ -90,8 +90,6 @@ private:
|
|||
|
||||
void sendCallsign();
|
||||
void beginRelaying();
|
||||
|
||||
q15_t getUnscaledSample(q15_t sample);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -86,12 +86,15 @@ m_threshold(0),
|
|||
m_count(0U),
|
||||
m_q0(0),
|
||||
m_q1(0),
|
||||
m_result(CTS_NONE)
|
||||
m_result(CTS_NONE),
|
||||
m_rxLevelInverse(1)
|
||||
{
|
||||
}
|
||||
|
||||
uint8_t CFMCTCSSRX::setParams(uint8_t frequency, uint8_t threshold)
|
||||
uint8_t CFMCTCSSRX::setParams(uint8_t frequency, uint8_t threshold, uint8_t level)
|
||||
{
|
||||
m_rxLevelInverse = 511 / q15_t(level);
|
||||
|
||||
m_coeffDivTwo = 0;
|
||||
|
||||
for (uint8_t i = 0U; i < CTCSS_TABLE_DATA_LEN; i++) {
|
||||
|
@ -111,6 +114,8 @@ uint8_t CFMCTCSSRX::setParams(uint8_t frequency, uint8_t threshold)
|
|||
|
||||
CTCSSState CFMCTCSSRX::process(q15_t sample)
|
||||
{
|
||||
q31_t sample31 = q31_t(sample) * m_rxLevelInverse;
|
||||
|
||||
m_result = m_result & (~CTS_READY);
|
||||
|
||||
q31_t q2 = m_q1;
|
||||
|
@ -122,7 +127,7 @@ CTCSSState CFMCTCSSRX::process(q15_t sample)
|
|||
q31_t t3 = t2 * 2;
|
||||
|
||||
// m_q0 = m_coeffDivTwo * m_q1 * 2 - q2 + sample
|
||||
m_q0 = t3 - q2 + q31_t(sample);
|
||||
m_q0 = t3 - q2 + sample31;
|
||||
|
||||
m_count++;
|
||||
if (m_count == N) {
|
||||
|
|
15
FMCTCSSRX.h
15
FMCTCSSRX.h
|
@ -53,7 +53,7 @@ class CFMCTCSSRX {
|
|||
public:
|
||||
CFMCTCSSRX();
|
||||
|
||||
uint8_t setParams(uint8_t frequency, uint8_t threshold);
|
||||
uint8_t setParams(uint8_t frequency, uint8_t threshold, uint8_t level);
|
||||
|
||||
CTCSSState process(q15_t sample);
|
||||
|
||||
|
@ -62,12 +62,13 @@ public:
|
|||
void reset();
|
||||
|
||||
private:
|
||||
q63_t m_coeffDivTwo;
|
||||
q31_t m_threshold;
|
||||
uint16_t m_count;
|
||||
q31_t m_q0;
|
||||
q31_t m_q1;
|
||||
CTCSSState m_result;
|
||||
q63_t m_coeffDivTwo;
|
||||
q31_t m_threshold;
|
||||
uint16_t m_count;
|
||||
q31_t m_q0;
|
||||
q31_t m_q1;
|
||||
CTCSSState m_result;
|
||||
q15_t m_rxLevelInverse;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
5
IO.cpp
5
IO.cpp
|
@ -592,8 +592,3 @@ bool CIO::hasLockout() const
|
|||
{
|
||||
return m_lockout;
|
||||
}
|
||||
|
||||
q15_t CIO::getRxLevel() const
|
||||
{
|
||||
return m_rxLevel;
|
||||
}
|
||||
|
|
4
IO.h
4
IO.h
|
@ -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
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -56,8 +56,6 @@ public:
|
|||
|
||||
void selfTest();
|
||||
|
||||
q15_t getRxLevel() const;
|
||||
|
||||
private:
|
||||
bool m_started;
|
||||
|
||||
|
|
|
@ -101,7 +101,7 @@ const uint8_t MMDVM_DEBUG5 = 0xF5U;
|
|||
#define HW_TYPE "MMDVM"
|
||||
#endif
|
||||
|
||||
#define DESCRIPTION "20200426 (D-Star/DMR/System Fusion/P25/NXDN/POCSAG/FM)"
|
||||
#define DESCRIPTION "20200427 (D-Star/DMR/System Fusion/P25/NXDN/POCSAG/FM)"
|
||||
|
||||
#if defined(GITVERSION)
|
||||
#define concat(h, a, b, c) h " " a " " b " GitID #" c ""
|
||||
|
@ -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)
|
||||
{
|
||||
if (length < 10U)
|
||||
if (length < 11U)
|
||||
return 4U;
|
||||
|
||||
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 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)
|
||||
|
|
Loading…
Reference in New Issue