Disassociate the ADC overload detection from the DCD LED.

48kHz
Jonathan Naylor 2016-06-06 18:04:03 +01:00
parent d4e56965da
commit b8457aed4c
6 changed files with 42 additions and 9 deletions

View File

@ -48,6 +48,7 @@ m_buffer(),
m_bitPtr(0U), m_bitPtr(0U),
m_dataPtr(0U), m_dataPtr(0U),
m_syncPtr(0U), m_syncPtr(0U),
m_startPtr(0U),
m_endPtr(NOENDPTR), m_endPtr(NOENDPTR),
m_delayPtr(0U), m_delayPtr(0U),
m_maxCorr(0), m_maxCorr(0),
@ -83,6 +84,7 @@ void CDMRSlotRX::reset()
m_control = CONTROL_NONE; m_control = CONTROL_NONE;
m_syncCount = 0U; m_syncCount = 0U;
m_state = DMRRXS_NONE; m_state = DMRRXS_NONE;
m_startPtr = 0U;
m_endPtr = NOENDPTR; m_endPtr = NOENDPTR;
} }
@ -92,6 +94,15 @@ bool CDMRSlotRX::processSample(q15_t sample)
if (m_delayPtr < m_delay) if (m_delayPtr < m_delay)
return m_state != DMRRXS_NONE; return m_state != DMRRXS_NONE;
if (m_state != DMRRXS_NONE) {
if (m_dataPtr > m_startPtr && m_dataPtr < m_endPtr)
io.setADCDetection(true);
else
io.setADCDetection(false);
} else {
io.setADCDetection(false);
}
// 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_state != DMRRXS_NONE; return m_state != DMRRXS_NONE;
@ -288,6 +299,7 @@ void CDMRSlotRX::correlateSync(bool first)
m_maxCorr = corr; m_maxCorr = corr;
m_control = CONTROL_DATA; m_control = CONTROL_DATA;
m_syncPtr = m_dataPtr; m_syncPtr = m_dataPtr;
m_startPtr = m_dataPtr - DMR_SLOT_TYPE_LENGTH_SAMPLES / 2U - DMR_INFO_LENGTH_SAMPLES / 2U;
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;
} }
} else { // if (voice) } else { // if (voice)
@ -312,6 +324,7 @@ void CDMRSlotRX::correlateSync(bool first)
m_maxCorr = corr; m_maxCorr = corr;
m_control = CONTROL_VOICE; m_control = CONTROL_VOICE;
m_syncPtr = m_dataPtr; m_syncPtr = m_dataPtr;
m_startPtr = m_dataPtr - DMR_SLOT_TYPE_LENGTH_SAMPLES / 2U - DMR_INFO_LENGTH_SAMPLES / 2U;
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;
} }
} }

View File

@ -48,6 +48,7 @@ private:
uint16_t m_bitPtr; uint16_t m_bitPtr;
uint16_t m_dataPtr; uint16_t m_dataPtr;
uint16_t m_syncPtr; uint16_t m_syncPtr;
uint16_t m_startPtr;
uint16_t m_endPtr; uint16_t m_endPtr;
uint16_t m_delayPtr; uint16_t m_delayPtr;
q31_t m_maxCorr; q31_t m_maxCorr;

View File

@ -333,7 +333,9 @@ void CDStarRX::processNone(bool bit)
// Exact matching of the data sync bit sequence // Exact matching of the data sync bit sequence
if (countBits32((m_patternBuffer & DATA_SYNC_MASK) ^ DATA_SYNC_DATA) == 0U) { if (countBits32((m_patternBuffer & DATA_SYNC_MASK) ^ DATA_SYNC_DATA) == 0U) {
DEBUG1("DStarRX: found data sync in None"); DEBUG1("DStarRX: found data sync in None");
io.setDecode(true); io.setDecode(true);
io.setADCDetection(true);
#if defined(WANT_DEBUG) #if defined(WANT_DEBUG)
q15_t min = 16000; q15_t min = 16000;
@ -374,6 +376,7 @@ void CDStarRX::processHeader(bool bit)
bool ok = rxHeader(m_rxBuffer, header); bool ok = rxHeader(m_rxBuffer, header);
if (ok) { if (ok) {
io.setDecode(true); io.setDecode(true);
io.setADCDetection(true);
serial.writeDStarHeader(header, DSTAR_HEADER_LENGTH_BYTES); serial.writeDStarHeader(header, DSTAR_HEADER_LENGTH_BYTES);
@ -401,7 +404,9 @@ void CDStarRX::processData(bool bit)
// Fuzzy matching of the end frame sequences // Fuzzy matching of the end frame sequences
if (countBits32((m_patternBuffer & END_SYNC_MASK) ^ END_SYNC_DATA) <= END_SYNC_ERRS) { if (countBits32((m_patternBuffer & END_SYNC_MASK) ^ END_SYNC_DATA) <= END_SYNC_ERRS) {
DEBUG1("DStarRX: Found end sync in Data"); DEBUG1("DStarRX: Found end sync in Data");
io.setDecode(false); io.setDecode(false);
io.setADCDetection(false);
serial.writeDStarEOT(); serial.writeDStarEOT();
@ -440,7 +445,9 @@ void CDStarRX::processData(bool bit)
m_dataBits--; m_dataBits--;
if (m_dataBits == 0U) { if (m_dataBits == 0U) {
DEBUG1("DStarRX: data sync timed out, lost lock"); DEBUG1("DStarRX: data sync timed out, lost lock");
io.setDecode(false); io.setDecode(false);
io.setADCDetection(false);
serial.writeDStarLost(); serial.writeDStarLost();

8
IO.cpp
View File

@ -120,6 +120,7 @@ m_txLevel(128 * 128),
m_ledCount(0U), m_ledCount(0U),
m_ledValue(true), m_ledValue(true),
m_dcd(false), m_dcd(false),
m_detect(false),
m_overflow(0U), m_overflow(0U),
m_overcount(0U), m_overcount(0U),
m_count(0U), m_count(0U),
@ -299,7 +300,7 @@ void CIO::process()
m_rxBuffer.get(sample, control[i]); m_rxBuffer.get(sample, control[i]);
// Detect ADC overflow // Detect ADC overflow
if (m_dcd && (sample == 0U || sample == 4095U)) if (m_detect && (sample == 0U || sample == 4095U))
m_overflow++; m_overflow++;
m_overcount++; m_overcount++;
@ -449,6 +450,11 @@ void CIO::setDecode(bool dcd)
m_dcd = dcd; m_dcd = dcd;
} }
void CIO::setADCDetection(bool detect)
{
m_detect = detect;
}
void CIO::setMode() void CIO::setMode()
{ {
#if !defined(__MBED__) #if !defined(__MBED__)

2
IO.h
View File

@ -36,6 +36,7 @@ public:
uint16_t getSpace() const; uint16_t getSpace() const;
void setDecode(bool dcd); void setDecode(bool dcd);
void setADCDetection(bool detect);
void setMode(); void setMode();
void interrupt(); void interrupt();
@ -82,6 +83,7 @@ private:
bool m_ledValue; bool m_ledValue;
bool m_dcd; bool m_dcd;
bool m_detect;
uint16_t m_overflow; uint16_t m_overflow;
uint16_t m_overcount; uint16_t m_overcount;

View File

@ -167,7 +167,9 @@ void CYSFRX::processNone(q15_t sample)
m_lostCount = MAX_SYNC_FRAMES; m_lostCount = MAX_SYNC_FRAMES;
m_bufferPtr = YSF_SYNC_LENGTH_BITS; m_bufferPtr = YSF_SYNC_LENGTH_BITS;
m_state = YSFRXS_DATA; m_state = YSFRXS_DATA;
io.setDecode(true); io.setDecode(true);
io.setADCDetection(true);
} }
} }
@ -226,7 +228,9 @@ void CYSFRX::processData(q15_t sample)
m_lostCount--; m_lostCount--;
if (m_lostCount == 0U) { if (m_lostCount == 0U) {
DEBUG1("YSFRX: sync timed out, lost lock"); DEBUG1("YSFRX: sync timed out, lost lock");
io.setDecode(false); io.setDecode(false);
io.setADCDetection(false);
serial.writeYSFLost(); serial.writeYSFLost();