Compare commits

...
18 Commits
Author SHA1 Message Date
Jonathan Naylor 046e1df161 Merge pull request #362 from n0mjs710/link-audio-fidelity
FM link-mode network audio: anti-alias/reconstruction filtering
2026-08-16 17:36:20 +01:00
Cort Buffington d70ab85bae Copy-construct the ds/us filters from m_filterStage1/2/3
Same coefficients, no need to retype them. CFMDirectFormI's copy ctor
already copies coefficients and (zeroed, at this point) state.
2026-08-13 13:52:06 -05:00
Cort Buffington 384c5d559d Reconstruction filter after ext-audio upsampling in FM mode
CFMUpSampler zero-stuffs 8kHz to 24kHz with no lowpass after it,
leaving imaging artifacts in the reconstructed ext audio. Filter it
with a second, separately-stated pass of the same 300-2700Hz design
already used for TX shaping, right where it comes out of the upsampler.
2026-08-12 07:43:23 -05:00
Cort Buffington 4c7e8fbe46 Anti-alias filter before RF->network downsampling in FM mode
The 24kHz->8kHz decimation in CFMDownSampler had no lowpass ahead of
it, aliasing everything above 4kHz back into the audio band. Reuse
the existing 300-2700Hz filter design (separate instance/state) ahead
of all three addSample() call sites in FM.cpp.

Also: reset() wasn't clearing the ring buffer or in-progress sample
pack, so stale audio could bleed into the next transmission. And
addSample() packed samples into 12 bits with no saturation, so an
out-of-range value corrupted the neighbouring sample.
2026-08-11 09:57:47 -05:00
Jonathan Naylor 894ba76432 Merge pull request #361 from n0mjs710/link-mode-ext-gap
Link mode ext audio gap
2026-08-11 15:02:32 +01:00
Cort Buffington 8a89804fda Refactor FM_LINK_EXT_GAP_MS and improve comments
Updated the FM_LINK_EXT_GAP_MS constant declaration and added comments for clarity.
2026-08-11 08:55:22 -05:00
Cort Buffington 8bd467598c Debounce link-mode external-audio underrun before dropping PTT
Under [FM] LinkMode=1, linkStateMachine() set m_extSignal false the
instant a single ext-audio sample went missing, with no debounce --
unlike the non-link duplex/simplex paths, which already tolerate a
brief gap via the RELAYING_EXT -> RELAYING_WAIT_EXT / m_ackDelayTimer
pattern before declaring a real loss. Since IO::process() drops PTT
the moment the downstream TX buffer runs dry, that zero-debounce cutoff
meant even a very brief, late-but-recoverable gap from the gateway
(scheduling jitter, a late UDP frame, etc.) could cascade into a full
PTT drop-and-rekey cycle -- far more audible than the underlying gap
itself.

Adds m_extGapTimer, mirroring the existing pattern: on the first missed
sample, start the timer instead of immediately clearing m_extSignal; a
gap that recovers before FM_LINK_EXT_GAP_MS (default 60ms) expires
never affects m_extSignal at all, so the transmitter never notices.
Only a gap that outlasts the timer is treated as a genuine end of
transmission, exactly as before.

linkSamples()'s currentExtSample is now zero-initialized, since
m_extSignal can now stay true for a few samples past an underrun --
silence, not stack garbage, must be what gets played out to the modem
during that window.
2026-08-09 11:42:20 -05:00
Jonathan Naylor 715d3f5839 Merge pull request #359 from chancellor1101/bugfixes
Fix several small bugs: STM UART repeater port, FM noise squelch, Due FM LED, DMR trunking state
2026-07-13 12:07:39 +01:00
Clint Chance 68252f15f5 Fix the FM 25kHz calibration debug message.
It said 10kHz, a copy and paste from the case above.
2026-07-12 16:45:24 -05:00
Clint Chance 96061a6013 Make DMR trunking state handling order-independent.
The CSBK slot type was only encoded into the ALOHA frame inside
setColorCode(), so it took effect only if a reconfigure happened after
an ALOHA frame had already been received; on the usual command ordering
(SET_CONFIG then ALOHA) the transmitted slot type depended entirely on
the host-supplied bytes. Remember the colour code and stamp the slot
type in writeAloha() as well.

Also clear m_controlChannel when trunking is disabled, so the host has
a way to stop control channel transmission other than rebooting, and
fix a stray tab introduced in createCACH().
2026-07-12 16:45:24 -05:00
Clint Chance 90220cbb9d Fix the FM mode LED pin guard on the Arduino Due.
The pinMode() call for PIN_FM was guarded by USE_ALTERNATE_POCSAG_LEDS
instead of USE_ALTERNATE_FM_LEDS, a copy and paste error. The Teensy
version and the setFMInt() implementation in this file both use the FM
macro.
2026-07-12 16:42:58 -05:00
Clint Chance 2eb6f7fd06 Initialise and reset the FM noise squelch invalid counter.
m_invalidCount was missing from the constructor initialiser list and was
read uninitialised in process(), making the squelch behaviour after
power-up indeterminate. reset() also cleared neither hysteresis counter,
so state leaked across squelch resets.
2026-07-12 16:42:58 -05:00
Clint Chance a1794b44ed Fix RX interrupt flag being cleared on the wrong USART in STMUART.
handleIRQ() hardcoded USART1 when clearing the RXNE pending bit, so on
boards where the repeater/display UART is not USART1 (Nucleo, Discovery,
F767, UART5-based boards) the flag was cleared on the wrong peripheral.
Use the m_usart member, matching the TXE handling below.

Also fix flush(): it passed a flag constant to USART_GetITStatus and
span while TXE was set, which returns immediately since TXE indicates
the data register is already empty. Wait for the software TX FIFO to
drain and then for the TC flag, which indicates the shift register has
actually emptied.
2026-07-12 16:42:47 -05:00
Jonathan Naylor 57e692ad8c Small cleanups of the DMR trunking code. 2026-04-24 16:54:23 +01:00
Jonathan Naylor 841d7505c2 Merge pull request #358 from qradiolink/trunking_patches
Add support for DMR tier III trunking
2026-04-24 14:50:28 +01:00
adrian 549dfd7258 Change DMR ALOHA header to 0x17 2026-04-19 11:32:07 +03:00
adrian 30ba4c4c55 Fix merge gone wrong in DMRTX.cpp 2026-04-19 11:12:37 +03:00
adrian a696fd454c DMR trunking patches to DMRTX and SerialPort 2026-04-18 11:29:48 +03:00
10 changed files with 169 additions and 37 deletions
+64 -11
View File
@@ -2,6 +2,7 @@
* Copyright (C) 2009-2017,2020 by Jonathan Naylor G4KLX
* Copyright (C) 2016 by Colin Durbridge G4EML
* Copyright (C) 2017 by Andy Uribe CA6JAU
* Copyright (C) 2022,2023,2026 by Adrian Musceac YO8RZZ
*
* 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
@@ -42,6 +43,12 @@ const uint8_t IDLE_DATA[] =
0x36U, 0x00U, 0x0DU, 0xFFU, 0x57U, 0xD7U, 0x5DU, 0xF5U, 0xD0U, 0x03U, 0xF6U,
0xE4U, 0x65U, 0x17U, 0x1BU, 0x48U, 0xCAU, 0x6DU, 0x4FU, 0xC6U, 0x10U, 0xB4U};
// DT Terminator with LC, empty
const uint8_t TERMINATOR_DATA[] =
{0x00U, 0xCCU, 0x01U, 0x80U, 0x01U, 0x94U, 0x01U, 0x48U, 0x08U, 0xB0U, 0x08U,
0x80U, 0x04U, 0xADU, 0xFFU, 0x57U, 0xD7U, 0x5DU, 0xF5U, 0xD9U, 0x65U, 0x90U,
0x01U, 0x78U, 0x00U, 0xD0U, 0x08U, 0x40U, 0x14U, 0x00U, 0x0DU, 0x80U, 0x15U};
const uint8_t CACH_INTERLEAVE[] =
{ 1U, 2U, 3U, 5U, 6U, 7U, 9U, 10U, 11U, 13U, 15U, 16U, 17U, 19U, 20U, 21U, 23U,
25U, 26U, 27U, 29U, 30U, 31U, 33U, 34U, 35U, 37U, 39U, 40U, 41U, 43U, 44U, 45U, 47U,
@@ -65,6 +72,7 @@ m_modFilter(),
m_modState(),
m_state(DMRTXSTATE_IDLE),
m_idle(),
m_aloha(),
m_cachPtr(0U),
m_shortLC(),
m_newShortLC(),
@@ -74,7 +82,10 @@ m_poLen(0U),
m_poPtr(0U),
m_frameCount(0U),
m_abortCount(),
m_abort()
m_abort(),
m_controlChannel(false),
m_trunking(false),
m_colorCode(0U)
{
::memset(m_modState, 0x00U, 16U * sizeof(q15_t));
@@ -211,6 +222,23 @@ uint8_t CDMRTX::writeShortLC(const uint8_t* data, uint16_t length)
return 0U;
}
uint8_t CDMRTX::writeAloha(const uint8_t* data, uint16_t length)
{
if (length != DMR_FRAME_LENGTH_BYTES)
return 4U;
::memcpy(m_aloha, data, length);
// Stamp the slot type with the current colour code so that the result
// doesn't depend on the ordering of the ALOHA and SET_CONFIG commands.
CDMRSlotType slotType;
slotType.encode(m_colorCode, DT_CSBK, m_aloha);
m_controlChannel = true;
return 0U;
}
uint8_t CDMRTX::writeAbort(const uint8_t* data, uint16_t length)
{
if (length != 1U)
@@ -294,7 +322,7 @@ uint8_t CDMRTX::getSpace2() const
void CDMRTX::createData(uint8_t slotIndex)
{
if (m_fifo[slotIndex].getData() >= DMR_FRAME_LENGTH_BYTES && m_frameCount >= STARTUP_COUNT && m_abortCount[slotIndex] >= ABORT_COUNT) {
if ((m_fifo[slotIndex].getData() >= DMR_FRAME_LENGTH_BYTES) && (m_frameCount >= STARTUP_COUNT) && (m_abortCount[slotIndex] >= ABORT_COUNT)) {
for (unsigned int i = 0U; i < DMR_FRAME_LENGTH_BYTES; i++) {
m_fifo[slotIndex].get(m_poBuffer[i]);
m_markBuffer[i] = MARK_NONE;
@@ -303,7 +331,11 @@ void CDMRTX::createData(uint8_t slotIndex)
m_abort[slotIndex] = false;
// Transmit an idle message
for (unsigned int i = 0U; i < DMR_FRAME_LENGTH_BYTES; i++) {
m_poBuffer[i] = m_idle[i];
if ((slotIndex == 0U) && m_controlChannel && m_trunking)
m_poBuffer[i] = m_aloha[i];
else
m_poBuffer[i] = m_idle[i];
m_markBuffer[i] = MARK_NONE;
}
}
@@ -354,10 +386,14 @@ void CDMRTX::createCACH(uint8_t txSlotIndex, uint8_t rxSlotIndex)
m_cachPtr = 0U;
if (m_cachPtr == 0U) {
if (m_fifo[0U].getData() == 0U && m_fifo[1U].getData() == 0U)
::memcpy(m_shortLC, EMPTY_SHORT_LC, 12U);
else
if ((m_fifo[0U].getData() == 0U) && (m_fifo[1U].getData() == 0U)) {
if (m_trunking)
::memcpy(m_shortLC, m_newShortLC, 12U);
else
::memcpy(m_shortLC, EMPTY_SHORT_LC, 12U);
} else {
::memcpy(m_shortLC, m_newShortLC, 12U);
}
}
::memcpy(m_poBuffer, m_shortLC + m_cachPtr, 3U);
@@ -367,8 +403,8 @@ void CDMRTX::createCACH(uint8_t txSlotIndex, uint8_t rxSlotIndex)
bool at = false;
if (m_frameCount >= STARTUP_COUNT)
at = m_fifo[rxSlotIndex].getData() > 0U;
bool tc = txSlotIndex == 1U;
at = (m_fifo[rxSlotIndex].getData() > 0U);
bool tc = (txSlotIndex == 1U);
bool ls0 = true; // For 1 and 2
bool ls1 = true;
@@ -397,10 +433,20 @@ void CDMRTX::createCACH(uint8_t txSlotIndex, uint8_t rxSlotIndex)
void CDMRTX::setColorCode(uint8_t colorCode)
{
::memcpy(m_idle, IDLE_DATA, DMR_FRAME_LENGTH_BYTES);
m_colorCode = colorCode;
if (m_trunking)
::memcpy(m_idle, TERMINATOR_DATA, DMR_FRAME_LENGTH_BYTES);
else
::memcpy(m_idle, IDLE_DATA, DMR_FRAME_LENGTH_BYTES);
CDMRSlotType slotType;
slotType.encode(colorCode, DT_IDLE, m_idle);
if (m_trunking) {
slotType.encode(colorCode, DT_TERMINATOR_WITH_LC, m_idle);
slotType.encode(colorCode, DT_CSBK, m_aloha);
} else {
slotType.encode(colorCode, DT_IDLE, m_idle);
}
}
void CDMRTX::resetFifo1()
@@ -418,5 +464,12 @@ uint32_t CDMRTX::getFrameCount()
return m_frameCount;
}
#endif
void CDMRTX::setTrunking(bool trunking)
{
m_trunking = trunking;
if (!trunking)
m_controlChannel = false;
}
#endif
+8 -2
View File
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2015,2016,2017,2020 by Jonathan Naylor G4KLX
* Copyright (C) 2016 by Colin Durbridge G4EML
* Copyright (C) 2026 by Adrian Musceac YO8RZZ
*
* 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
@@ -45,10 +46,12 @@ public:
uint8_t writeData2(const uint8_t* data, uint16_t length);
uint8_t writeShortLC(const uint8_t* data, uint16_t length);
uint8_t writeAloha(const uint8_t* data, uint16_t length);
uint8_t writeAbort(const uint8_t* data, uint16_t length);
void setStart(bool start);
void setCal(bool start);
void setTrunking(bool trunking);
void process();
@@ -62,11 +65,12 @@ public:
void setColorCode(uint8_t colorCode);
private:
CRingBuffer<uint8_t> m_fifo[2U];
CRingBuffer<uint8_t> m_fifo[2U];
arm_fir_interpolate_instance_q15 m_modFilter;
q15_t m_modState[16U]; // blockSize + phaseLength - 1, 4 + 9 - 1 plus some spare
DMRTXSTATE m_state;
uint8_t m_idle[DMR_FRAME_LENGTH_BYTES];
uint8_t m_aloha[DMR_FRAME_LENGTH_BYTES];
uint8_t m_cachPtr;
uint8_t m_shortLC[12U];
uint8_t m_newShortLC[12U];
@@ -77,6 +81,9 @@ private:
uint32_t m_frameCount;
uint32_t m_abortCount[2U];
bool m_abort[2U];
bool m_controlChannel;
bool m_trunking;
uint8_t m_colorCode;
void createData(uint8_t slotIndex);
void createCACH(uint8_t txSlotIndex, uint8_t rxSlotIndex);
@@ -87,4 +94,3 @@ private:
#endif
#endif
+61 -16
View File
@@ -27,7 +27,8 @@ const uint16_t FM_TX_BLOCK_SIZE = 100U;
const uint16_t FM_SERIAL_BLOCK_SIZE = 80U;//this is the number of sample pairs to send over serial. One sample pair is 3bytes.
//three times this value shall never exceed 252
const uint16_t FM_SERIAL_BLOCK_SIZE_BYTES = FM_SERIAL_BLOCK_SIZE * 3U;
const uint16_t FM_LINK_EXT_GAP_MS = 60U;// How long a link-mode external-audio underrun is tolerated before it is
// treated as a real end of transmission (see linkStateMachine()).
const uint8_t FS_LISTENING = 0U;
const uint8_t FS_KERCHUNK_RF = 1U;
const uint8_t FS_RELAYING_RF = 2U;
@@ -62,10 +63,17 @@ m_ackMinTimer(),
m_ackDelayTimer(),
m_hangTimer(),
m_reverseTimer(),
m_extGapTimer(),
m_needReverse(false),
m_filterStage1( 724, 1448, 724, 32768, -37895, 21352),//3rd order Cheby Filter 300 to 2700Hz, 0.2dB passband ripple, sampling rate 24kHz
m_filterStage2(32768, 0,-32768, 32768, -50339, 19052),
m_filterStage3(32768, -65536, 32768, 32768, -64075, 31460),
m_dsFilterStage1(m_filterStage1),//same coefficients, separate state
m_dsFilterStage2(m_filterStage2),
m_dsFilterStage3(m_filterStage3),
m_usFilterStage1(m_filterStage1),//same coefficients, separate state
m_usFilterStage2(m_filterStage2),
m_usFilterStage3(m_filterStage3),
m_blanking(),
m_accessMode(1U),
m_linkMode(false),
@@ -85,6 +93,7 @@ m_rssiAccum(0U),
m_rssiCount(0U)
{
m_reverseTimer.setTimeout(0U, 150U);
m_extGapTimer.setTimeout(0U, FM_LINK_EXT_GAP_MS);
insertDelay(100U);
}
@@ -119,6 +128,7 @@ void CFM::repeaterSamples(bool cos, q15_t* samples, const uint16_t* rssi, uint8_
q15_t currentExtSample;
bool inputExt = m_inputExtRB.getSample(currentExtSample);//always consume the external input data so it does not overflow
currentExtSample = m_usFilterStage3.filter(m_usFilterStage2.filter(m_usFilterStage1.filter(currentExtSample)));
inputExt = inputExt && m_extEnabled;
switch (m_accessMode) {
@@ -200,8 +210,10 @@ void CFM::repeaterSamples(bool cos, q15_t* samples, const uint16_t* rssi, uint8_
if (m_duplex) {
if (m_state == FS_RELAYING_RF || m_state == FS_KERCHUNK_RF || m_state == FS_RELAYING_EXT || m_state == FS_KERCHUNK_EXT) {
currentSample = m_blanking.process(currentSample);
if (m_extEnabled && (m_state == FS_RELAYING_RF || m_state == FS_KERCHUNK_RF))
m_downSampler.addSample(currentSample);
if (m_extEnabled && (m_state == FS_RELAYING_RF || m_state == FS_KERCHUNK_RF)) {
q15_t dsSample = m_dsFilterStage3.filter(m_dsFilterStage2.filter(m_dsFilterStage1.filter(currentSample)));
m_downSampler.addSample(dsSample);
}
currentSample *= currentBoost;
} else {
@@ -211,9 +223,11 @@ void CFM::repeaterSamples(bool cos, q15_t* samples, const uint16_t* rssi, uint8_
if (m_state == FS_RELAYING_EXT || m_state == FS_KERCHUNK_EXT) {
currentSample *= currentBoost;
} else {
if (m_extEnabled && (m_state == FS_RELAYING_RF || m_state == FS_KERCHUNK_RF))
m_downSampler.addSample(currentSample);
continue;
if (m_extEnabled && (m_state == FS_RELAYING_RF || m_state == FS_KERCHUNK_RF)) {
q15_t dsSample = m_dsFilterStage3.filter(m_dsFilterStage2.filter(m_dsFilterStage1.filter(currentSample)));
m_downSampler.addSample(dsSample);
}
continue;
}
}
@@ -250,14 +264,17 @@ void CFM::linkSamples(bool cos, q15_t* samples, uint8_t length)
uint8_t i = 0U;
for (; i < length; i++) {
// ARMv7-M has hardware integer division
q15_t currentRFSample = q15_t((q31_t(samples[i]) << 8) / m_rxLevel);
if (m_noiseSquelch)
cos = m_squelch.process(currentRFSample);
q15_t currentExtSample;
// Zero-initialized: getSample() leaves this untouched on underrun, and
// with the ext-gap debounce below, m_extSignal can now stay true for a
// few samples past that point
q15_t currentExtSample = 0;
bool inputExt = m_inputExtRB.getSample(currentExtSample);//always consume the external input data so it does not overflow
currentExtSample = m_usFilterStage3.filter(m_usFilterStage2.filter(m_usFilterStage1.filter(currentExtSample)));
inputExt = inputExt && m_extEnabled;
switch (m_accessMode) {
@@ -327,7 +344,8 @@ void CFM::linkSamples(bool cos, q15_t* samples, uint8_t length)
if (m_rfSignal && m_extEnabled) {
q15_t currentSample = m_blanking.process(currentRFSample);
m_downSampler.addSample(currentSample);
q15_t dsSample = m_dsFilterStage3.filter(m_dsFilterStage2.filter(m_dsFilterStage1.filter(currentSample)));
m_downSampler.addSample(dsSample);
}
if (!m_extSignal)
@@ -407,6 +425,12 @@ void CFM::reset()
m_inputExtRB.reset();
m_downSampler.reset();
m_dsFilterStage1.reset();
m_dsFilterStage2.reset();
m_dsFilterStage3.reset();
m_usFilterStage1.reset();
m_usFilterStage2.reset();
m_usFilterStage3.reset();
m_squelch.reset();
m_needReverse = false;
@@ -601,6 +625,7 @@ void CFM::clock(uint8_t length)
m_ackDelayTimer.clock(length);
m_hangTimer.clock(length);
m_reverseTimer.clock(length);
m_extGapTimer.clock(length);
}
void CFM::listeningStateDuplex(bool validRFSignal, bool validExtSignal)
@@ -1231,6 +1256,12 @@ void CFM::linkStateMachine(bool validRFSignal, bool validExtSignal)
m_extSignal = true;
}
if (validExtSignal && m_extGapTimer.isRunning()) {
// Recovered before the gap timer committed to a real loss below --
// m_extSignal was never flipped, so there is nothing else to undo.
m_extGapTimer.stop();
}
if (!validRFSignal && m_rfSignal) {
io.setDecode(false);
io.setADCDetection(false);
@@ -1248,14 +1279,28 @@ void CFM::linkStateMachine(bool validRFSignal, bool validExtSignal)
}
if (!validExtSignal && m_extSignal) {
if (!m_rfSignal) {
DEBUG1("State to LISTENING");
m_state = FS_LISTENING;
serial.writeFMStatus(m_state);
}
// A missed/late sample used to flip m_extSignal false right here, on
// the very first bad sample, with zero debounce -- that is what
// actually keys the transmitter off (IO::process() drops PTT the
// instant the downstream TX buffer runs dry, see IO.cpp). A gap well
// under FM_LINK_EXT_GAP_MS is less offensive than the PTT
// drop-and-rekey it triggers. Give it a short grace period
// mirroring the RELAYING_EXT/RELAYING_WAIT_EXT pattern the
// non-link duplex/simplex paths already use for exactly this
// situation (see relayingExtStateDuplex()/relayingExtWaitStateDuplex()).
if (!m_extGapTimer.isRunning()) {
m_extGapTimer.start();
} else if (m_extGapTimer.hasExpired()) {
if (!m_rfSignal) {
DEBUG1("State to LISTENING");
m_state = FS_LISTENING;
serial.writeFMStatus(m_state);
}
m_needReverse = true;
m_extSignal = false;
m_needReverse = true;
m_extSignal = false;
m_extGapTimer.stop();
}
}
}
+7
View File
@@ -75,10 +75,17 @@ private:
CFMTimer m_ackDelayTimer;
CFMTimer m_hangTimer;
CFMTimer m_reverseTimer;
CFMTimer m_extGapTimer; // debounce for link-mode ext-audio underrun, see linkStateMachine()
bool m_needReverse;
CFMDirectFormI m_filterStage1;
CFMDirectFormI m_filterStage2;
CFMDirectFormI m_filterStage3;
CFMDirectFormI m_dsFilterStage1; // anti-alias filter for the downsampler, own state
CFMDirectFormI m_dsFilterStage2;
CFMDirectFormI m_dsFilterStage3;
CFMDirectFormI m_usFilterStage1; // reconstruction filter for the upsampler, own state
CFMDirectFormI m_usFilterStage2;
CFMDirectFormI m_usFilterStage3;
CFMBlanking m_blanking;
uint8_t m_accessMode;
bool m_linkMode;
+3
View File
@@ -34,6 +34,7 @@ m_sampleIndex(0U)
void CFMDownSampler::addSample(q15_t sample)
{
sample = __SSAT(sample, 12);//clamp before packing to 12 bits
uint32_t usample = uint32_t(int32_t(sample) + 2048);
//only take one of three samples
switch(m_sampleIndex){
@@ -74,6 +75,8 @@ uint16_t CFMDownSampler::getData()
void CFMDownSampler::reset()
{
m_sampleIndex = 0U;
m_samplePack = 0U;
m_ringBuffer.reset();
}
#endif
+4 -1
View File
@@ -36,7 +36,8 @@ m_count(0U),
m_q0(0),
m_q1(0),
m_state(false),
m_validCount(0U)
m_validCount(0U),
m_invalidCount(0U)
{
}
@@ -127,6 +128,8 @@ void CFMNoiseSquelch::reset()
m_q1 = 0;
m_state = false;
m_count = 0U;
m_validCount = 0U;
m_invalidCount = 0U;
}
#endif
+1 -1
View File
@@ -110,7 +110,7 @@ void CIO::initInt()
#if !defined(USE_ALTERNATE_POCSAG_LEDS)
pinMode(PIN_POCSAG, OUTPUT);
#endif
#if !defined(USE_ALTERNATE_POCSAG_LEDS)
#if !defined(USE_ALTERNATE_FM_LEDS)
pinMode(PIN_FM, OUTPUT);
#endif
#endif
+7 -3
View File
@@ -61,7 +61,7 @@ void CSTMUART::handleIRQ()
if (USART_GetITStatus(m_usart, USART_IT_RXNE)) {
if(!m_rxFifo.isFull())
m_rxFifo.put((uint8_t) USART_ReceiveData(m_usart));
USART_ClearITPendingBit(USART1, USART_IT_RXNE);
USART_ClearITPendingBit(m_usart, USART_IT_RXNE);
}
if (USART_GetITStatus(m_usart, USART_IT_TXE)) {
@@ -82,8 +82,12 @@ void CSTMUART::flush()
if(m_usart == NULL)
return;
// wait until the TXE shows the shift register is empty
while (USART_GetITStatus(m_usart, USART_FLAG_TXE))
// wait until the TX FIFO has drained
while (!m_txFifo.isEmpty())
;
// wait until the TC flag shows the shift register is empty
while (USART_GetFlagStatus(m_usart, USART_FLAG_TC) == RESET)
;
}
+13 -2
View File
@@ -45,6 +45,7 @@ const uint8_t MMDVM_DSTAR_DATA = 0x11U;
const uint8_t MMDVM_DSTAR_LOST = 0x12U;
const uint8_t MMDVM_DSTAR_EOT = 0x13U;
const uint8_t MMDVM_DMR_ALOHA = 0x17U;
const uint8_t MMDVM_DMR_DATA1 = 0x18U;
const uint8_t MMDVM_DMR_LOST1 = 0x19U;
const uint8_t MMDVM_DMR_DATA2 = 0x1AU;
@@ -466,6 +467,7 @@ uint8_t CSerialPort::setConfig(const uint8_t* data, uint16_t length)
#endif
#if defined(MODE_DMR)
bool trunking = (data[25U] & 128U) == 128U;
uint8_t colorCode = data[26U];
if (colorCode > 15U)
return 4U;
@@ -484,7 +486,7 @@ uint8_t CSerialPort::setConfig(const uint8_t* data, uint16_t length)
#if defined(MODE_DMR)
m_dmrEnable = dmrEnable;
dmrDMOTX.setTXDelay(txDelay);
dmrTX.setTrunking(trunking);
dmrTX.setColorCode(colorCode);
dmrRX.setColorCode(colorCode);
dmrRX.setDelay(dmrDelay);
@@ -743,7 +745,7 @@ void CSerialPort::setMode(MMDVM_STATE modemState)
DEBUG1("Mode set to FM 20Khz Calibrate");
break;
case STATE_FMCAL25K:
DEBUG1("Mode set to FM 10Khz Calibrate");
DEBUG1("Mode set to FM 25Khz Calibrate");
break;
case STATE_FMCAL30K:
DEBUG1("Mode set to FM 30Khz Calibrate");
@@ -1123,6 +1125,15 @@ void CSerialPort::processMessage(uint8_t type, const uint8_t* buffer, uint16_t l
}
break;
case MMDVM_DMR_ALOHA:
if (m_dmrEnable)
err = dmrTX.writeAloha(buffer, length);
if (err != 0U) {
DEBUG2("Received invalid DMR ALOHA", err);
sendNAK(type, err);
}
break;
case MMDVM_DMR_ABORT:
if (m_dmrEnable)
err = dmrTX.writeAbort(buffer, length);
+1 -1
View File
@@ -19,6 +19,6 @@
#if !defined(VERSION_H)
#define VERSION_H
#define VERSION "20260219"
#define VERSION "20260424"
#endif