mirror of https://github.com/g4klx/MMDVM.git
Alter end of slot processing.
This commit is contained in:
parent
ba6f21c958
commit
688488620a
44
DMRRX.cpp
44
DMRRX.cpp
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2009-2015 by Jonathan Naylor G4KLX
|
||||
* Copyright (C) 2015,2016 by Jonathan Naylor G4KLX
|
||||
*
|
||||
* 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
|
||||
|
@ -22,45 +22,34 @@
|
|||
|
||||
CDMRRX::CDMRRX() :
|
||||
m_slot1RX(false),
|
||||
m_slot2RX(true),
|
||||
m_slotNo(0U),
|
||||
m_dcd1(false),
|
||||
m_dcd2(false)
|
||||
m_slot2RX(true)
|
||||
{
|
||||
}
|
||||
|
||||
void CDMRRX::samples(const q15_t* samples, const uint8_t* control, uint8_t length)
|
||||
{
|
||||
for (uint16_t i = 0U; i < length; i++) {
|
||||
if (control[i] == MARK_SLOT1 && m_slotNo != 1U) {
|
||||
m_slot2RX.stop();
|
||||
m_slot1RX.start();
|
||||
m_slotNo = 1U;
|
||||
} else if (control[i] == MARK_SLOT2 && m_slotNo != 2U) {
|
||||
m_slot1RX.stop();
|
||||
m_slot2RX.start();
|
||||
m_slotNo = 2U;
|
||||
} else if (control[i] == MARK_END && m_slotNo != 0U) {
|
||||
if (m_slotNo == 1U)
|
||||
m_slot1RX.stop();
|
||||
if (m_slotNo == 2U)
|
||||
m_slot2RX.stop();
|
||||
m_slotNo = 0U;
|
||||
}
|
||||
bool dcd1 = false;
|
||||
bool dcd2 = false;
|
||||
|
||||
switch (m_slotNo) {
|
||||
case 1U:
|
||||
m_dcd1 = m_slot1RX.processSample(samples[i]);
|
||||
for (uint16_t i = 0U; i < length; i++) {
|
||||
switch (control[i]) {
|
||||
case MARK_SLOT1:
|
||||
m_slot2RX.stop();
|
||||
m_slot1RX.start();
|
||||
break;
|
||||
case 2U:
|
||||
m_dcd2 = m_slot2RX.processSample(samples[i]);
|
||||
case MARK_SLOT2:
|
||||
m_slot1RX.stop();
|
||||
m_slot2RX.start();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
dcd1 = m_slot1RX.processSample(samples[i]);
|
||||
dcd2 = m_slot2RX.processSample(samples[i]);
|
||||
}
|
||||
|
||||
io.setDecode(m_dcd1 || m_dcd2);
|
||||
io.setDecode(dcd1 || dcd2);
|
||||
}
|
||||
|
||||
void CDMRRX::setColorCode(uint8_t colorCode)
|
||||
|
@ -73,6 +62,5 @@ void CDMRRX::reset()
|
|||
{
|
||||
m_slot1RX.reset();
|
||||
m_slot2RX.reset();
|
||||
m_slotNo = 0U;
|
||||
}
|
||||
|
||||
|
|
5
DMRRX.h
5
DMRRX.h
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2015 by Jonathan Naylor G4KLX
|
||||
* Copyright (C) 2015,2016 by Jonathan Naylor G4KLX
|
||||
*
|
||||
* 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
|
||||
|
@ -35,9 +35,6 @@ public:
|
|||
private:
|
||||
CDMRSlotRX m_slot1RX;
|
||||
CDMRSlotRX m_slot2RX;
|
||||
uint8_t m_slotNo;
|
||||
bool m_dcd1;
|
||||
bool m_dcd2;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -121,26 +121,27 @@ bool CDMRSlotRX::processSample(q15_t sample)
|
|||
case DT_DATA_HEADER:
|
||||
case DT_VOICE_LC_HEADER:
|
||||
case DT_VOICE_PI_HEADER:
|
||||
DEBUG4("DMRSlotRX: header for slot with color code/data type", m_slot ? 2U : 1U, colorCode, dataType);
|
||||
DEBUG4("DMRSlotRX: header for slot/color code/data type", m_slot ? 2U : 1U, colorCode, dataType);
|
||||
m_receiving = true;
|
||||
m_syncCount = 0U;
|
||||
m_n = 0U;
|
||||
serial.writeDMRData(m_slot, frame, DMR_FRAME_LENGTH_BYTES + 1U);
|
||||
break;
|
||||
case DT_TERMINATOR_WITH_LC:
|
||||
DEBUG3("DMRSlotRX: terminator for slot with color code", m_slot ? 2U : 1U, colorCode);
|
||||
DEBUG3("DMRSlotRX: terminator for slot/color code", m_slot ? 2U : 1U, colorCode);
|
||||
m_receiving = false;
|
||||
m_endPtr = 999U;
|
||||
serial.writeDMRData(m_slot, frame, DMR_FRAME_LENGTH_BYTES + 1U);
|
||||
break;
|
||||
default:
|
||||
DEBUG4("DMRSlotRX: data sync for slot, type and color code", m_slot ? 2U : 1U, dataType, colorCode);
|
||||
DEBUG4("DMRSlotRX: data sync for slot/color code/data type", m_slot ? 2U : 1U, colorCode, dataType);
|
||||
m_receiving = false;
|
||||
serial.writeDMRData(m_slot, frame, DMR_FRAME_LENGTH_BYTES + 1U);
|
||||
break;
|
||||
}
|
||||
} else if (m_control == 0x20U) {
|
||||
// Voice sync
|
||||
DEBUG2("DMRSlotRX: voice sync for slot", m_slot ? 2U : 1U);
|
||||
serial.writeDMRData(m_slot, frame, DMR_FRAME_LENGTH_BYTES + 1U);
|
||||
m_receiving = true;
|
||||
m_syncCount = 0U;
|
||||
|
@ -215,6 +216,7 @@ void CDMRSlotRX::correlateSync(q15_t sample)
|
|||
m_threshold = threshold;
|
||||
m_control = 0x40U;
|
||||
m_endPtr = m_dataPtr + DMR_SLOT_TYPE_LENGTH_SAMPLES / 2U + DMR_INFO_LENGTH_SAMPLES / 2U - 1U;
|
||||
DEBUG3("DMRSlotRX: slot/endPtr", m_slot ? 2U : 1U, m_endPtr);
|
||||
}
|
||||
} else { // if (voice)
|
||||
uint8_t errs = 0U;
|
||||
|
@ -228,6 +230,7 @@ void CDMRSlotRX::correlateSync(q15_t sample)
|
|||
m_threshold = threshold;
|
||||
m_control = 0x20U;
|
||||
m_endPtr = m_dataPtr + DMR_SLOT_TYPE_LENGTH_SAMPLES / 2U + DMR_INFO_LENGTH_SAMPLES / 2U - 1U;
|
||||
DEBUG3("DMRSlotRX: slot/endPtr", m_slot ? 2U : 1U, m_endPtr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -241,11 +244,6 @@ void CDMRSlotRX::correlateSync(q15_t sample)
|
|||
void CDMRSlotRX::samplesToBits(uint16_t start, uint8_t count, uint8_t* buffer, uint16_t offset, q15_t centre, q15_t threshold)
|
||||
{
|
||||
for (uint8_t i = 0U; i < count; i++, start += DMR_RADIO_SYMBOL_LENGTH) {
|
||||
if (m_control == 0x20U || m_control == 0x40U) {
|
||||
if (i == 77U)
|
||||
DEBUG4("DMRSlotRX: slot/frame pos/sample pos", m_slot ? 2U : 1U, i, start);
|
||||
}
|
||||
|
||||
q15_t sample = m_buffer[start] - centre;
|
||||
|
||||
if (sample < -threshold) {
|
||||
|
|
|
@ -266,7 +266,7 @@ void CDMRTX::createCACH(uint8_t txSlotIndex, uint8_t rxSlotIndex)
|
|||
}
|
||||
|
||||
::memcpy(m_poBuffer, m_shortLC + m_cachPtr, 3U);
|
||||
m_markBuffer[0U] = MARK_END;
|
||||
m_markBuffer[0U] = MARK_NONE;
|
||||
m_markBuffer[1U] = MARK_NONE;
|
||||
m_markBuffer[2U] = rxSlotIndex == 1U ? MARK_SLOT2 : MARK_SLOT1;
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2015 by Jonathan Naylor G4KLX
|
||||
* Copyright (C) 2015,2016 by Jonathan Naylor G4KLX
|
||||
*
|
||||
* 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
|
||||
|
@ -57,7 +57,6 @@ enum MMDVM_STATE {
|
|||
|
||||
const uint8_t MARK_SLOT1 = 0x08U;
|
||||
const uint8_t MARK_SLOT2 = 0x04U;
|
||||
const uint8_t MARK_END = 0x0CU;
|
||||
const uint8_t MARK_NONE = 0x00U;
|
||||
|
||||
const uint16_t RX_BLOCK_SIZE = 20U;
|
||||
|
|
Loading…
Reference in New Issue