Alter end of slot processing.

This commit is contained in:
Jonathan Naylor 2016-01-15 06:57:02 +00:00
parent ba6f21c958
commit 688488620a
6 changed files with 26 additions and 44 deletions

View File

@ -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 * 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 * it under the terms of the GNU General Public License as published by
@ -22,45 +22,34 @@
CDMRRX::CDMRRX() : CDMRRX::CDMRRX() :
m_slot1RX(false), m_slot1RX(false),
m_slot2RX(true), m_slot2RX(true)
m_slotNo(0U),
m_dcd1(false),
m_dcd2(false)
{ {
} }
void CDMRRX::samples(const q15_t* samples, const uint8_t* control, uint8_t length) void CDMRRX::samples(const q15_t* samples, const uint8_t* control, uint8_t length)
{ {
for (uint16_t i = 0U; i < length; i++) { bool dcd1 = false;
if (control[i] == MARK_SLOT1 && m_slotNo != 1U) { bool dcd2 = false;
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;
}
switch (m_slotNo) { for (uint16_t i = 0U; i < length; i++) {
case 1U: switch (control[i]) {
m_dcd1 = m_slot1RX.processSample(samples[i]); case MARK_SLOT1:
m_slot2RX.stop();
m_slot1RX.start();
break; break;
case 2U: case MARK_SLOT2:
m_dcd2 = m_slot2RX.processSample(samples[i]); m_slot1RX.stop();
m_slot2RX.start();
break; break;
default: default:
break; 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) void CDMRRX::setColorCode(uint8_t colorCode)
@ -73,6 +62,5 @@ void CDMRRX::reset()
{ {
m_slot1RX.reset(); m_slot1RX.reset();
m_slot2RX.reset(); m_slot2RX.reset();
m_slotNo = 0U;
} }

View File

@ -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 * 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 * it under the terms of the GNU General Public License as published by
@ -35,9 +35,6 @@ public:
private: private:
CDMRSlotRX m_slot1RX; CDMRSlotRX m_slot1RX;
CDMRSlotRX m_slot2RX; CDMRSlotRX m_slot2RX;
uint8_t m_slotNo;
bool m_dcd1;
bool m_dcd2;
}; };
#endif #endif

View File

@ -121,26 +121,27 @@ bool CDMRSlotRX::processSample(q15_t sample)
case DT_DATA_HEADER: case DT_DATA_HEADER:
case DT_VOICE_LC_HEADER: case DT_VOICE_LC_HEADER:
case DT_VOICE_PI_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_receiving = true;
m_syncCount = 0U; m_syncCount = 0U;
m_n = 0U; m_n = 0U;
serial.writeDMRData(m_slot, frame, DMR_FRAME_LENGTH_BYTES + 1U); serial.writeDMRData(m_slot, frame, DMR_FRAME_LENGTH_BYTES + 1U);
break; break;
case DT_TERMINATOR_WITH_LC: 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_receiving = false;
m_endPtr = 999U; m_endPtr = 999U;
serial.writeDMRData(m_slot, frame, DMR_FRAME_LENGTH_BYTES + 1U); serial.writeDMRData(m_slot, frame, DMR_FRAME_LENGTH_BYTES + 1U);
break; break;
default: 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; m_receiving = false;
serial.writeDMRData(m_slot, frame, DMR_FRAME_LENGTH_BYTES + 1U); serial.writeDMRData(m_slot, frame, DMR_FRAME_LENGTH_BYTES + 1U);
break; break;
} }
} else if (m_control == 0x20U) { } else if (m_control == 0x20U) {
// Voice sync // Voice sync
DEBUG2("DMRSlotRX: voice sync for slot", m_slot ? 2U : 1U);
serial.writeDMRData(m_slot, frame, DMR_FRAME_LENGTH_BYTES + 1U); serial.writeDMRData(m_slot, frame, DMR_FRAME_LENGTH_BYTES + 1U);
m_receiving = true; m_receiving = true;
m_syncCount = 0U; m_syncCount = 0U;
@ -215,6 +216,7 @@ void CDMRSlotRX::correlateSync(q15_t sample)
m_threshold = threshold; m_threshold = threshold;
m_control = 0x40U; m_control = 0x40U;
m_endPtr = m_dataPtr + DMR_SLOT_TYPE_LENGTH_SAMPLES / 2U + DMR_INFO_LENGTH_SAMPLES / 2U - 1U; 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) } else { // if (voice)
uint8_t errs = 0U; uint8_t errs = 0U;
@ -228,6 +230,7 @@ void CDMRSlotRX::correlateSync(q15_t sample)
m_threshold = threshold; m_threshold = threshold;
m_control = 0x20U; m_control = 0x20U;
m_endPtr = m_dataPtr + DMR_SLOT_TYPE_LENGTH_SAMPLES / 2U + DMR_INFO_LENGTH_SAMPLES / 2U - 1U; 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) 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) { 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; q15_t sample = m_buffer[start] - centre;
if (sample < -threshold) { if (sample < -threshold) {

View File

@ -266,7 +266,7 @@ void CDMRTX::createCACH(uint8_t txSlotIndex, uint8_t rxSlotIndex)
} }
::memcpy(m_poBuffer, m_shortLC + m_cachPtr, 3U); ::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[1U] = MARK_NONE;
m_markBuffer[2U] = rxSlotIndex == 1U ? MARK_SLOT2 : MARK_SLOT1; m_markBuffer[2U] = rxSlotIndex == 1U ? MARK_SLOT2 : MARK_SLOT1;

View File

@ -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 * 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 * 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_SLOT1 = 0x08U;
const uint8_t MARK_SLOT2 = 0x04U; const uint8_t MARK_SLOT2 = 0x04U;
const uint8_t MARK_END = 0x0CU;
const uint8_t MARK_NONE = 0x00U; const uint8_t MARK_NONE = 0x00U;
const uint16_t RX_BLOCK_SIZE = 20U; const uint16_t RX_BLOCK_SIZE = 20U;

2
IO.cpp
View File

@ -32,7 +32,7 @@ const uint16_t GMSK_FILTER_LEN = 12U;
const uint16_t DC_OFFSET = 2048U; const uint16_t DC_OFFSET = 2048U;
const uint16_t TX_BUFFER_SIZE = 1001U; const uint16_t TX_BUFFER_SIZE = 1101U;
const uint16_t RX_BUFFER_SIZE = 501U; const uint16_t RX_BUFFER_SIZE = 501U;
#if defined(__SAM3X8E__) #if defined(__SAM3X8E__)