mirror of https://github.com/markqvist/MMDVM.git
Allow for a delay before processing a DMR slot.
parent
c7ea8a68c6
commit
da34f26c55
|
@ -56,6 +56,12 @@ void CDMRRX::setColorCode(uint8_t colorCode)
|
||||||
m_slot2RX.setColorCode(colorCode);
|
m_slot2RX.setColorCode(colorCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CDMRRX::setDelay(uint8_t delay)
|
||||||
|
{
|
||||||
|
m_slot1RX.setDelay(delay);
|
||||||
|
m_slot2RX.setDelay(delay);
|
||||||
|
}
|
||||||
|
|
||||||
void CDMRRX::reset()
|
void CDMRRX::reset()
|
||||||
{
|
{
|
||||||
m_slot1RX.reset();
|
m_slot1RX.reset();
|
||||||
|
|
1
DMRRX.h
1
DMRRX.h
|
@ -29,6 +29,7 @@ public:
|
||||||
void samples(const q15_t* samples, const uint8_t* control, uint8_t length);
|
void samples(const q15_t* samples, const uint8_t* control, uint8_t length);
|
||||||
|
|
||||||
void setColorCode(uint8_t colorCode);
|
void setColorCode(uint8_t colorCode);
|
||||||
|
void setDelay(uint8_t delay);
|
||||||
|
|
||||||
void reset();
|
void reset();
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// #define WANT_DEBUG
|
#define WANT_DEBUG
|
||||||
|
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
#include "Globals.h"
|
#include "Globals.h"
|
||||||
|
@ -45,28 +45,32 @@ m_bitPtr(0U),
|
||||||
m_dataPtr(0U),
|
m_dataPtr(0U),
|
||||||
m_syncPtr(0U),
|
m_syncPtr(0U),
|
||||||
m_endPtr(NOENDPTR),
|
m_endPtr(NOENDPTR),
|
||||||
|
m_delayPtr(0U),
|
||||||
m_maxCorr(0),
|
m_maxCorr(0),
|
||||||
m_centre(0),
|
m_centre(0),
|
||||||
m_threshold(0),
|
m_threshold(0),
|
||||||
m_control(0x00U),
|
m_control(0x00U),
|
||||||
m_syncCount(0U),
|
m_syncCount(0U),
|
||||||
m_colorCode(0U),
|
m_colorCode(0U),
|
||||||
|
m_delay(0U),
|
||||||
m_n(0U)
|
m_n(0U)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDMRSlotRX::start()
|
void CDMRSlotRX::start()
|
||||||
{
|
{
|
||||||
m_dataPtr = 0U;
|
m_dataPtr = 0U;
|
||||||
m_bitPtr = 0U;
|
m_delayPtr = 0U;
|
||||||
m_maxCorr = 0;
|
m_bitPtr = 0U;
|
||||||
m_control = 0x00U;
|
m_maxCorr = 0;
|
||||||
|
m_control = 0x00U;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDMRSlotRX::reset()
|
void CDMRSlotRX::reset()
|
||||||
{
|
{
|
||||||
m_syncPtr = 0U;
|
m_syncPtr = 0U;
|
||||||
m_dataPtr = 0U;
|
m_dataPtr = 0U;
|
||||||
|
m_delayPtr = 0U;
|
||||||
m_bitPtr = 0U;
|
m_bitPtr = 0U;
|
||||||
m_maxCorr = 0;
|
m_maxCorr = 0;
|
||||||
m_control = 0x00U;
|
m_control = 0x00U;
|
||||||
|
@ -78,6 +82,10 @@ void CDMRSlotRX::reset()
|
||||||
|
|
||||||
bool CDMRSlotRX::processSample(q15_t sample)
|
bool CDMRSlotRX::processSample(q15_t sample)
|
||||||
{
|
{
|
||||||
|
m_delayPtr++;
|
||||||
|
if (m_delayPtr < m_delay)
|
||||||
|
return m_endPtr != NOENDPTR;
|
||||||
|
|
||||||
// Ensure that the buffer doesn't overflow
|
// Ensure that the buffer doesn't overflow
|
||||||
if (m_dataPtr > m_endPtr || m_dataPtr >= 900U)
|
if (m_dataPtr > m_endPtr || m_dataPtr >= 900U)
|
||||||
return m_endPtr != NOENDPTR;
|
return m_endPtr != NOENDPTR;
|
||||||
|
@ -95,7 +103,7 @@ bool CDMRSlotRX::processSample(q15_t sample)
|
||||||
if (m_dataPtr >= min && m_dataPtr <= max)
|
if (m_dataPtr >= min && m_dataPtr <= max)
|
||||||
correlateSync(sample);
|
correlateSync(sample);
|
||||||
} else {
|
} else {
|
||||||
if (m_dataPtr >= 390U && m_dataPtr <= 500U)
|
if (m_dataPtr >= 420U && m_dataPtr <= 500U)
|
||||||
correlateSync(sample);
|
correlateSync(sample);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -226,10 +234,9 @@ void CDMRSlotRX::correlateSync(q15_t sample)
|
||||||
errs += countBits8((sync[i] & DMR_SYNC_BYTES_MASK[i]) ^ DMR_MS_DATA_SYNC_BYTES[i]);
|
errs += countBits8((sync[i] & DMR_SYNC_BYTES_MASK[i]) ^ DMR_MS_DATA_SYNC_BYTES[i]);
|
||||||
|
|
||||||
if (errs <= MAX_SYNC_BYTES_ERRS) {
|
if (errs <= MAX_SYNC_BYTES_ERRS) {
|
||||||
// DEBUG5("DMRSlotRX: data sync found slot/pos/centre/threshold", m_slot ? 2U : 1U, m_dataPtr, centre, threshold);
|
|
||||||
#if defined(WANT_DEBUG)
|
#if defined(WANT_DEBUG)
|
||||||
if (m_endPtr == NOENDPTR)
|
if (m_endPtr == NOENDPTR)
|
||||||
DEBUG5("DMRSlotRX: data sync found slot/pos/centre/threshold", m_slot ? 2U : 1U, m_dataPtr, centre, threshold);
|
DEBUG5("DMRSlotRX: data sync found slot/pos/centre/threshold", m_slot ? 2U : 1U, int16_t(m_dataPtr) - 420, centre, threshold);
|
||||||
else
|
else
|
||||||
DEBUG3("DMRSlotRX: data sync found slot/rel pos", m_slot ? 2U : 1U, int16_t(m_dataPtr) - int16_t(m_syncPtr));
|
DEBUG3("DMRSlotRX: data sync found slot/rel pos", m_slot ? 2U : 1U, int16_t(m_dataPtr) - int16_t(m_syncPtr));
|
||||||
#endif
|
#endif
|
||||||
|
@ -246,10 +253,9 @@ void CDMRSlotRX::correlateSync(q15_t sample)
|
||||||
errs += countBits8((sync[i] & DMR_SYNC_BYTES_MASK[i]) ^ DMR_MS_VOICE_SYNC_BYTES[i]);
|
errs += countBits8((sync[i] & DMR_SYNC_BYTES_MASK[i]) ^ DMR_MS_VOICE_SYNC_BYTES[i]);
|
||||||
|
|
||||||
if (errs <= MAX_SYNC_BYTES_ERRS) {
|
if (errs <= MAX_SYNC_BYTES_ERRS) {
|
||||||
// DEBUG5("DMRSlotRX: voice sync found slot/pos/centre/threshold", m_slot ? 2U : 1U, m_dataPtr, centre, threshold);
|
|
||||||
#if defined(WANT_DEBUG)
|
#if defined(WANT_DEBUG)
|
||||||
if (m_endPtr == NOENDPTR)
|
if (m_endPtr == NOENDPTR)
|
||||||
DEBUG5("DMRSlotRX: voice sync found slot/pos/centre/threshold", m_slot ? 2U : 1U, m_dataPtr, centre, threshold);
|
DEBUG5("DMRSlotRX: voice sync found slot/pos/centre/threshold", m_slot ? 2U : 1U, int16_t(m_dataPtr) - 420, centre, threshold);
|
||||||
else
|
else
|
||||||
DEBUG3("DMRSlotRX: voice sync found slot/rel pos", m_slot ? 2U : 1U, int16_t(m_dataPtr) - int16_t(m_syncPtr));
|
DEBUG3("DMRSlotRX: voice sync found slot/rel pos", m_slot ? 2U : 1U, int16_t(m_dataPtr) - int16_t(m_syncPtr));
|
||||||
#endif
|
#endif
|
||||||
|
@ -299,3 +305,8 @@ void CDMRSlotRX::setColorCode(uint8_t colorCode)
|
||||||
m_colorCode = colorCode;
|
m_colorCode = colorCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CDMRSlotRX::setDelay(uint8_t delay)
|
||||||
|
{
|
||||||
|
m_delay = delay;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,7 @@ public:
|
||||||
bool processSample(q15_t sample);
|
bool processSample(q15_t sample);
|
||||||
|
|
||||||
void setColorCode(uint8_t colorCode);
|
void setColorCode(uint8_t colorCode);
|
||||||
|
void setDelay(uint8_t delay);
|
||||||
|
|
||||||
void reset();
|
void reset();
|
||||||
|
|
||||||
|
@ -42,16 +43,18 @@ private:
|
||||||
uint16_t m_dataPtr;
|
uint16_t m_dataPtr;
|
||||||
uint16_t m_syncPtr;
|
uint16_t m_syncPtr;
|
||||||
uint16_t m_endPtr;
|
uint16_t m_endPtr;
|
||||||
|
uint16_t m_delayPtr;
|
||||||
q31_t m_maxCorr;
|
q31_t m_maxCorr;
|
||||||
q15_t m_centre;
|
q15_t m_centre;
|
||||||
q15_t m_threshold;
|
q15_t m_threshold;
|
||||||
uint8_t m_control;
|
uint8_t m_control;
|
||||||
uint8_t m_syncCount;
|
uint8_t m_syncCount;
|
||||||
uint8_t m_colorCode;
|
uint8_t m_colorCode;
|
||||||
|
uint16_t m_delay;
|
||||||
uint8_t m_n;
|
uint8_t m_n;
|
||||||
|
|
||||||
void correlateSync(q15_t sample);
|
void correlateSync(q15_t sample);
|
||||||
void samplesToBits(uint16_t start, uint8_t count, uint8_t* buffer, uint16_t offset, q15_t centre, q15_t threshold);
|
void samplesToBits(uint16_t start, uint8_t count, uint8_t* buffer, uint16_t offset, q15_t centre, q15_t threshold);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -176,7 +176,7 @@ void CSerialPort::getVersion()
|
||||||
|
|
||||||
uint8_t CSerialPort::setConfig(const uint8_t* data, uint8_t length)
|
uint8_t CSerialPort::setConfig(const uint8_t* data, uint8_t length)
|
||||||
{
|
{
|
||||||
if (length < 7U)
|
if (length < 8U)
|
||||||
return 4U;
|
return 4U;
|
||||||
|
|
||||||
bool rxInvert = (data[0U] & 0x01U) == 0x01U;
|
bool rxInvert = (data[0U] & 0x01U) == 0x01U;
|
||||||
|
@ -209,6 +209,8 @@ uint8_t CSerialPort::setConfig(const uint8_t* data, uint8_t length)
|
||||||
if (colorCode > 15U)
|
if (colorCode > 15U)
|
||||||
return 4U;
|
return 4U;
|
||||||
|
|
||||||
|
uint8_t dmrDelay = data[7U];
|
||||||
|
|
||||||
m_modemState = modemState;
|
m_modemState = modemState;
|
||||||
|
|
||||||
m_dstarEnable = dstarEnable;
|
m_dstarEnable = dstarEnable;
|
||||||
|
@ -220,6 +222,7 @@ uint8_t CSerialPort::setConfig(const uint8_t* data, uint8_t length)
|
||||||
|
|
||||||
dmrTX.setColorCode(colorCode);
|
dmrTX.setColorCode(colorCode);
|
||||||
dmrRX.setColorCode(colorCode);
|
dmrRX.setColorCode(colorCode);
|
||||||
|
dmrRX.setDelay(dmrDelay);
|
||||||
dmrIdleRX.setColorCode(colorCode);
|
dmrIdleRX.setColorCode(colorCode);
|
||||||
|
|
||||||
io.setParameters(rxInvert, txInvert, pttInvert, rxLevel, txLevel);
|
io.setParameters(rxInvert, txInvert, pttInvert, rxLevel, txLevel);
|
||||||
|
|
Loading…
Reference in New Issue