From 46c988bdc2d2b432900adfdd914e664a5a32241a Mon Sep 17 00:00:00 2001 From: Silvano Seva Date: Wed, 25 May 2022 20:42:59 +0200 Subject: [PATCH] Restoring priority level of output streams to PRIO_BEEP when the stream terminates, made M17Modulator::emitBaseband() wait for effective stream termination before returning when transmission stop is requested. Fixes #76 --- openrtx/src/protocols/M17/M17Modulator.cpp | 4 +++- platform/drivers/audio/outputStream_MDx.cpp | 3 ++- platform/drivers/audio/outputStream_Mod17.cpp | 5 +++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/openrtx/src/protocols/M17/M17Modulator.cpp b/openrtx/src/protocols/M17/M17Modulator.cpp index 8c03c79e..61c9c209 100644 --- a/openrtx/src/protocols/M17/M17Modulator.cpp +++ b/openrtx/src/protocols/M17/M17Modulator.cpp @@ -132,10 +132,12 @@ void M17Modulator::emitBaseband() outputStream_sync(outStream, true); } - // Check if transmission stop is requested + // Check if transmission stop is requested, if so stop the output stream + // and wait until its effective termination. if(stopTx == true) { outputStream_stop(outStream); + outputStream_sync(outStream, false); stopTx = false; txRunning = false; idleBuffer = baseband_buffer; diff --git a/platform/drivers/audio/outputStream_MDx.cpp b/platform/drivers/audio/outputStream_MDx.cpp index ede16887..a248218c 100644 --- a/platform/drivers/audio/outputStream_MDx.cpp +++ b/platform/drivers/audio/outputStream_MDx.cpp @@ -52,10 +52,11 @@ static inline void stopTransfer() // Re-activate "beeps" toneGen_unlockBeep(); - // Finally, clear flags + // Finally, clear flags and restore priority level running = false; reqFinish = false; circularMode = false; + priority = PRIO_BEEP; } /** diff --git a/platform/drivers/audio/outputStream_Mod17.cpp b/platform/drivers/audio/outputStream_Mod17.cpp index 813444c0..efa56e19 100644 --- a/platform/drivers/audio/outputStream_Mod17.cpp +++ b/platform/drivers/audio/outputStream_Mod17.cpp @@ -42,7 +42,7 @@ static Thread *dmaWaiting = 0; * \internal * Stop an ongoing transfer, deactivating timers and DMA stream. */ -void stopTransfer() +static inline void stopTransfer() { // Stop DMA transfers DMA1_Stream5->CR = 0; @@ -53,10 +53,11 @@ void stopTransfer() DAC->CR = DAC_CR_EN1; // Keep only channel 1 active DAC->DHR12R1 = 1365; // Set channel 1 (RTX) to about 1.1V when idle - // Clear flags + // Clear flags and restore priority level running = false; reqFinish = false; circularMode = false; + priority = PRIO_BEEP; } /**