From a2518e99f270a96883f7e4852eb9bf33ae9fadf2 Mon Sep 17 00:00:00 2001 From: Geoffrey Merck Date: Sun, 10 May 2020 17:29:17 +0200 Subject: [PATCH 1/5] Fix stuck on TX --- FM.cpp | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/FM.cpp b/FM.cpp index 66bd5af..6a14e45 100644 --- a/FM.cpp +++ b/FM.cpp @@ -129,25 +129,8 @@ void CFM::samples(bool cos, const q15_t* samples, uint8_t length) void CFM::process() { - if (m_modemState != STATE_FM) - return; - - uint16_t length = m_outputRB.getData(); - if (length == 0U) - return; - - uint16_t space = io.getSpace(); - if (space < 3U) - return; - - space -= 2U; - - if (space < length) - length = space; - - for (uint16_t i = 0U; i < length; i++) { - q15_t sample; - m_outputRB.get(sample); + q15_t sample; + while(io.getSpace() >= 3U && m_outputRB.get(sample)) { io.write(STATE_FM, &sample, 1U); } } @@ -251,7 +234,7 @@ void CFM::stateMachine(bool validSignal) } if (m_state == FS_LISTENING && m_modemState == STATE_FM) { - if (!m_callsign.isRunning() && !m_rfAck.isRunning() && m_outputRB.getData() == 0U) { + if (!m_callsign.isRunning() && !m_rfAck.isRunning()) { DEBUG1("Change to STATE_IDLE"); m_modemState = STATE_IDLE; m_callsignTimer.stop(); From 66ea3ad0d11cc6e705e2e32c0668bce109ed85fb Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Sun, 10 May 2020 17:15:54 +0100 Subject: [PATCH 2/5] Only use the CTCSS delay when not using COS. --- FM.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/FM.cpp b/FM.cpp index 6a14e45..6d2e0e3 100644 --- a/FM.cpp +++ b/FM.cpp @@ -70,9 +70,11 @@ void CFM::samples(bool cos, const q15_t* samples, uint8_t length) uint8_t ctcssState = m_ctcssRX.process(currentSample); - // Delay the audio by 100ms to better match the CTCSS detector output - m_inputRB.put(currentSample); - m_inputRB.get(currentSample); + if (!m_useCOS) { + // Delay the audio by 100ms to better match the CTCSS detector output + m_inputRB.put(currentSample); + m_inputRB.get(currentSample); + } if (CTCSS_NOT_READY(ctcssState) && m_modemState != STATE_FM) { //Not enough samples to determine if you have CTCSS, just carry on @@ -130,9 +132,8 @@ void CFM::samples(bool cos, const q15_t* samples, uint8_t length) void CFM::process() { q15_t sample; - while(io.getSpace() >= 3U && m_outputRB.get(sample)) { + while(io.getSpace() >= 3U && m_outputRB.get(sample)) io.write(STATE_FM, &sample, 1U); - } } void CFM::reset() From d0062a55f85f474fc92e55343114b88f5c8bb767 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Sun, 10 May 2020 17:31:21 +0100 Subject: [PATCH 3/5] Rescale the FM calibration output. --- CalFM.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/CalFM.cpp b/CalFM.cpp index 3f847cc..e89f0be 100644 --- a/CalFM.cpp +++ b/CalFM.cpp @@ -41,7 +41,7 @@ CCalFM::CCalFM() : m_frequency(0), m_length(0), m_tone(NULL), -m_level(128*32), +m_level(128 * 12), m_transmit(false), m_audioSeq(0), m_lastState(STATE_IDLE) @@ -56,25 +56,25 @@ void CCalFM::process() { switch (m_modemState) { case STATE_FMCAL10K: - m_frequency=956U; + m_frequency = 956U; break; case STATE_FMCAL12K: - m_frequency=1039U; + m_frequency = 1039U; break; case STATE_FMCAL15K: - m_frequency=1247U; + m_frequency = 1247U; break; case STATE_FMCAL20K: - m_frequency=1633U; + m_frequency = 1633U; break; case STATE_FMCAL25K: - m_frequency=2079U; + m_frequency = 2079U; break; case STATE_FMCAL30K: - m_frequency=2495U; + m_frequency = 2495U; break; default: - m_frequency=0; + m_frequency = 0U; break; } From 4cba5931f4e16f47a51e043da07f008cf0f8b830 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Sun, 10 May 2020 21:29:01 +0100 Subject: [PATCH 4/5] Loosen the conditions for returning to STATE_IDLE --- FM.cpp | 20 +++++++++----------- SerialPort.cpp | 2 +- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/FM.cpp b/FM.cpp index 6d2e0e3..543c497 100644 --- a/FM.cpp +++ b/FM.cpp @@ -132,7 +132,7 @@ void CFM::samples(bool cos, const q15_t* samples, uint8_t length) void CFM::process() { q15_t sample; - while(io.getSpace() >= 3U && m_outputRB.get(sample)) + while (io.getSpace() >= 3U && m_outputRB.get(sample)) io.write(STATE_FM, &sample, 1U); } @@ -235,16 +235,14 @@ void CFM::stateMachine(bool validSignal) } if (m_state == FS_LISTENING && m_modemState == STATE_FM) { - if (!m_callsign.isRunning() && !m_rfAck.isRunning()) { - DEBUG1("Change to STATE_IDLE"); - m_modemState = STATE_IDLE; - m_callsignTimer.stop(); - m_timeoutTimer.stop(); - m_kerchunkTimer.stop(); - m_ackMinTimer.stop(); - m_ackDelayTimer.stop(); - m_hangTimer.stop(); - } + DEBUG1("Change to STATE_IDLE"); + m_modemState = STATE_IDLE; + m_callsignTimer.stop(); + m_timeoutTimer.stop(); + m_kerchunkTimer.stop(); + m_ackMinTimer.stop(); + m_ackDelayTimer.stop(); + m_hangTimer.stop(); } } diff --git a/SerialPort.cpp b/SerialPort.cpp index 69d691b..4910c10 100644 --- a/SerialPort.cpp +++ b/SerialPort.cpp @@ -101,7 +101,7 @@ const uint8_t MMDVM_DEBUG5 = 0xF5U; #define HW_TYPE "MMDVM" #endif -#define DESCRIPTION "20200508 (D-Star/DMR/System Fusion/P25/NXDN/POCSAG/FM)" +#define DESCRIPTION "20200510 (D-Star/DMR/System Fusion/P25/NXDN/POCSAG/FM)" #if defined(GITVERSION) #define concat(h, a, b, c) h " " a " " b " GitID #" c "" From 17a3743cd8fb58524e43d4c3bcd54fd3bacec6e8 Mon Sep 17 00:00:00 2001 From: phl0 Date: Mon, 11 May 2020 14:27:23 +0200 Subject: [PATCH 5/5] Add GPIO and LEDs for FM mode --- IOSTM.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/IOSTM.cpp b/IOSTM.cpp index 1d565fe..1757237 100644 --- a/IOSTM.cpp +++ b/IOSTM.cpp @@ -547,6 +547,7 @@ YSF PC7 output P25 PC8 output NXDN PC9 output POCSAG PA8 output +FM PA11 output MDSTAR PC1 output MDMR PC2 output @@ -554,6 +555,7 @@ MYSF PC3 output MP25 PC4 output MNXDN PC10 output MPOCSAG PC11 output +MFM PC13 output RX PA0 analog input RSSI PA7 analog input @@ -590,6 +592,10 @@ EXT_CLK PA15 input #define PORT_POCSAG GPIOA #define RCC_Per_POCSAG RCC_AHB1Periph_GPIOA +#define PIN_FM GPIO_Pin_11 +#define PORT_FM GPIOA +#define RCC_Per_FM RCC_AHB1Periph_GPIOA + #define PIN_DSTAR GPIO_Pin_15 #define PORT_DSTAR GPIOB #define RCC_Per_DSTAR RCC_AHB1Periph_GPIOB @@ -626,6 +632,10 @@ EXT_CLK PA15 input #define PIN_MPOCSAG GPIO_Pin_11 #define PORT_MPOCSAG GPIOC #define RCC_Per_MPOCSAG RCC_AHB1Periph_GPIOC + +#define PIN_MFM GPIO_Pin_13 +#define PORT_MFM GPIOC +#define RCC_Per_MFM RCC_AHB1Periph_GPIOC #endif #define PIN_EXT_CLK GPIO_Pin_15