mirror of https://github.com/g4klx/MMDVM.git
Add two more FM parameters.
This commit is contained in:
parent
868d33ebd2
commit
6ac6deba10
22
FM.cpp
22
FM.cpp
|
@ -38,14 +38,19 @@ m_ackDelayTimer(),
|
||||||
m_hangTimer(),
|
m_hangTimer(),
|
||||||
m_filterStage1( 724, 1448, 724, 32768, -37895, 21352),
|
m_filterStage1( 724, 1448, 724, 32768, -37895, 21352),
|
||||||
m_filterStage2(32768, 0,-32768, 32768, -50339, 19052),
|
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_useCOS(true),
|
||||||
|
m_rxBoost(1U)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void CFM::samples(q15_t* samples, uint8_t length)
|
void CFM::samples(bool cos, q15_t* samples, uint8_t length)
|
||||||
{
|
{
|
||||||
uint8_t i = 0;
|
uint8_t i = 0;
|
||||||
for (; i < length; i++) {
|
for (; i < length; i++) {
|
||||||
|
if (!m_useCOS)
|
||||||
|
cos = true;
|
||||||
|
|
||||||
q15_t currentSample = samples[i];//save to a local variable to avoid indirection on every access
|
q15_t currentSample = samples[i];//save to a local variable to avoid indirection on every access
|
||||||
|
|
||||||
CTCSSState ctcssState = m_ctcssRX.process(currentSample);
|
CTCSSState ctcssState = m_ctcssRX.process(currentSample);
|
||||||
|
@ -56,26 +61,28 @@ void CFM::samples(q15_t* samples, uint8_t length)
|
||||||
} else if (CTCSS_READY(ctcssState) && m_modemState != STATE_FM) {
|
} else if (CTCSS_READY(ctcssState) && m_modemState != STATE_FM) {
|
||||||
//we had enough samples for CTCSS and we are in some other mode than FM
|
//we had enough samples for CTCSS and we are in some other mode than FM
|
||||||
bool validCTCSS = CTCSS_VALID(ctcssState);
|
bool validCTCSS = CTCSS_VALID(ctcssState);
|
||||||
stateMachine(validCTCSS, i + 1U);
|
stateMachine(validCTCSS && cos, i + 1U);
|
||||||
if (m_modemState != STATE_FM)
|
if (m_modemState != STATE_FM)
|
||||||
continue;
|
continue;
|
||||||
} else if (CTCSS_READY(ctcssState) && m_modemState == STATE_FM) {
|
} else if (CTCSS_READY(ctcssState) && m_modemState == STATE_FM) {
|
||||||
//We had enough samples for CTCSS and we are in FM mode, trigger the state machine
|
//We had enough samples for CTCSS and we are in FM mode, trigger the state machine
|
||||||
bool validCTCSS = CTCSS_VALID(ctcssState);
|
bool validCTCSS = CTCSS_VALID(ctcssState);
|
||||||
stateMachine(validCTCSS, i + 1U);
|
stateMachine(validCTCSS && cos, i + 1U);
|
||||||
if (m_modemState != STATE_FM)
|
if (m_modemState != STATE_FM)
|
||||||
break;
|
break;
|
||||||
} else if (CTCSS_NOT_READY(ctcssState) && m_modemState == STATE_FM && i == length - 1) {
|
} else if (CTCSS_NOT_READY(ctcssState) && m_modemState == STATE_FM && i == length - 1) {
|
||||||
//Not enough samples for CTCSS but we already are in FM, trigger the state machine
|
//Not enough samples for CTCSS but we already are in FM, trigger the state machine
|
||||||
//but do not trigger the state machine on every single sample, save CPU!
|
//but do not trigger the state machine on every single sample, save CPU!
|
||||||
bool validCTCSS = CTCSS_VALID(ctcssState);
|
bool validCTCSS = CTCSS_VALID(ctcssState);
|
||||||
stateMachine(validCTCSS, i + 1U);
|
stateMachine(validCTCSS && cos, i + 1U);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only let audio through when relaying audio
|
// Only let audio through when relaying audio
|
||||||
if (m_state != FS_RELAYING && m_state != FS_KERCHUNK)
|
if (m_state != FS_RELAYING && m_state != FS_KERCHUNK)
|
||||||
currentSample = 0U;
|
currentSample = 0U;
|
||||||
|
|
||||||
|
currentSample *= m_rxBoost;
|
||||||
|
|
||||||
if (!m_callsign.isRunning())
|
if (!m_callsign.isRunning())
|
||||||
currentSample += m_rfAck.getHighAudio();
|
currentSample += m_rfAck.getHighAudio();
|
||||||
|
|
||||||
|
@ -134,8 +141,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)
|
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)
|
||||||
{
|
{
|
||||||
|
m_useCOS = useCOS;
|
||||||
|
m_rxBoost = q15_t(rxBoost);
|
||||||
|
|
||||||
m_timeoutTimer.setTimeout(timeout, 0U);
|
m_timeoutTimer.setTimeout(timeout, 0U);
|
||||||
m_kerchunkTimer.setTimeout(kerchunkTime, 0U);
|
m_kerchunkTimer.setTimeout(kerchunkTime, 0U);
|
||||||
m_hangTimer.setTimeout(hangTime, 0U);
|
m_hangTimer.setTimeout(hangTime, 0U);
|
||||||
|
|
6
FM.h
6
FM.h
|
@ -45,7 +45,7 @@ class CFM {
|
||||||
public:
|
public:
|
||||||
CFM();
|
CFM();
|
||||||
|
|
||||||
void samples(q15_t* samples, uint8_t length);
|
void samples(bool cos, q15_t* samples, uint8_t length);
|
||||||
|
|
||||||
void process();
|
void process();
|
||||||
|
|
||||||
|
@ -53,7 +53,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);
|
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);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CFMKeyer m_callsign;
|
CFMKeyer m_callsign;
|
||||||
|
@ -74,6 +74,8 @@ private:
|
||||||
CFMDirectFormI m_filterStage1;
|
CFMDirectFormI m_filterStage1;
|
||||||
CFMDirectFormI m_filterStage2;
|
CFMDirectFormI m_filterStage2;
|
||||||
CFMDirectFormI m_filterStage3;
|
CFMDirectFormI m_filterStage3;
|
||||||
|
bool m_useCOS;
|
||||||
|
q15_t m_rxBoost;
|
||||||
|
|
||||||
void stateMachine(bool validSignal, uint8_t length);
|
void stateMachine(bool validSignal, uint8_t length);
|
||||||
void listeningState(bool validSignal);
|
void listeningState(bool validSignal);
|
||||||
|
|
10
IO.cpp
10
IO.cpp
|
@ -357,10 +357,11 @@ void CIO::process()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_fmEnable) {
|
if (m_fmEnable) {
|
||||||
|
bool cos = getCOSInt();
|
||||||
#if defined(USE_DCBLOCKER)
|
#if defined(USE_DCBLOCKER)
|
||||||
fm.samples(dcSamples, RX_BLOCK_SIZE);
|
fm.samples(cos, dcSamples, RX_BLOCK_SIZE);
|
||||||
#else
|
#else
|
||||||
fm.samples(samples, RX_BLOCK_SIZE);
|
fm.samples(cos, samples, RX_BLOCK_SIZE);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
} else if (m_modemState == STATE_DSTAR) {
|
} else if (m_modemState == STATE_DSTAR) {
|
||||||
|
@ -422,10 +423,11 @@ void CIO::process()
|
||||||
nxdnRX.samples(NXDNVals, rssi, RX_BLOCK_SIZE);
|
nxdnRX.samples(NXDNVals, rssi, RX_BLOCK_SIZE);
|
||||||
}
|
}
|
||||||
} else if (m_modemState == STATE_FM) {
|
} else if (m_modemState == STATE_FM) {
|
||||||
|
bool cos = getCOSInt();
|
||||||
#if defined(USE_DCBLOCKER)
|
#if defined(USE_DCBLOCKER)
|
||||||
fm.samples(dcSamples, RX_BLOCK_SIZE);
|
fm.samples(cos, dcSamples, RX_BLOCK_SIZE);
|
||||||
#else
|
#else
|
||||||
fm.samples(samples, RX_BLOCK_SIZE);
|
fm.samples(cos, samples, RX_BLOCK_SIZE);
|
||||||
#endif
|
#endif
|
||||||
} else if (m_modemState == STATE_DSTARCAL) {
|
} else if (m_modemState == STATE_DSTARCAL) {
|
||||||
q15_t GMSKVals[RX_BLOCK_SIZE];
|
q15_t GMSKVals[RX_BLOCK_SIZE];
|
||||||
|
|
|
@ -101,7 +101,7 @@ const uint8_t MMDVM_DEBUG5 = 0xF5U;
|
||||||
#define HW_TYPE "MMDVM"
|
#define HW_TYPE "MMDVM"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define DESCRIPTION "20200424 (D-Star/DMR/System Fusion/P25/NXDN/POCSAG/FM)"
|
#define DESCRIPTION "20200425 (D-Star/DMR/System Fusion/P25/NXDN/POCSAG/FM)"
|
||||||
|
|
||||||
#if defined(GITVERSION)
|
#if defined(GITVERSION)
|
||||||
#define concat(h, a, b, c) h " " a " " b " GitID #" c ""
|
#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)
|
uint8_t CSerialPort::setFMParams3(const uint8_t* data, uint8_t length)
|
||||||
{
|
{
|
||||||
if (length < 7U)
|
if (length < 9U)
|
||||||
return 4U;
|
return 4U;
|
||||||
|
|
||||||
uint16_t timeout = data[0U] * 5U;
|
uint16_t timeout = data[0U] * 5U;
|
||||||
|
@ -421,7 +421,11 @@ uint8_t CSerialPort::setFMParams3(const uint8_t* data, uint8_t length)
|
||||||
uint8_t kerchunkTime = data[5U];
|
uint8_t kerchunkTime = data[5U];
|
||||||
uint8_t hangTime = data[6U];
|
uint8_t hangTime = data[6U];
|
||||||
|
|
||||||
return fm.setMisc(timeout, timeoutLevel, ctcssFrequency, ctcssThreshold, ctcssLevel, kerchunkTime, hangTime);
|
bool useCOS = (data[7U] & 0x01U) == 0x01U;
|
||||||
|
|
||||||
|
uint8_t rxBoost = data[8U];
|
||||||
|
|
||||||
|
return fm.setMisc(timeout, timeoutLevel, ctcssFrequency, ctcssThreshold, ctcssLevel, kerchunkTime, hangTime, useCOS, rxBoost);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t CSerialPort::setMode(const uint8_t* data, uint8_t length)
|
uint8_t CSerialPort::setMode(const uint8_t* data, uint8_t length)
|
||||||
|
|
Loading…
Reference in New Issue