diff --git a/DMRRX.cpp b/DMRRX.cpp index ba3ea0c..22c2223 100644 --- a/DMRRX.cpp +++ b/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; } diff --git a/DMRRX.h b/DMRRX.h index 04a6cd8..f31f8ab 100644 --- a/DMRRX.h +++ b/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 diff --git a/DMRSlotRX.cpp b/DMRSlotRX.cpp index c024dcb..591aea8 100644 --- a/DMRSlotRX.cpp +++ b/DMRSlotRX.cpp @@ -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) { diff --git a/DMRTX.cpp b/DMRTX.cpp index 7a7bf06..2670369 100644 --- a/DMRTX.cpp +++ b/DMRTX.cpp @@ -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; diff --git a/Globals.h b/Globals.h index 31f012b..ccb4cd0 100644 --- a/Globals.h +++ b/Globals.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 @@ -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; diff --git a/IO.cpp b/IO.cpp index ace8b07..e7478f1 100644 --- a/IO.cpp +++ b/IO.cpp @@ -32,7 +32,7 @@ const uint16_t GMSK_FILTER_LEN = 12U; 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; #if defined(__SAM3X8E__)