mirror of https://github.com/g4klx/MMDVM.git
Set up ring buffer overflow signalling and a little debugging.
This commit is contained in:
parent
dd17a47972
commit
d9b5f5753e
|
@ -112,7 +112,7 @@ void CDMRIdleRX::processSample(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) {
|
||||||
DEBUG4("DMRIdleRX: data sync found pos/centre/threshold", m_dataPtr, centre, threshold);
|
DEBUG3("DMRIdleRX: data sync found centre/threshold", centre, threshold);
|
||||||
m_maxCorr = corr;
|
m_maxCorr = corr;
|
||||||
m_centre = centre;
|
m_centre = centre;
|
||||||
m_threshold = threshold;
|
m_threshold = threshold;
|
||||||
|
|
|
@ -246,6 +246,11 @@ 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) {
|
||||||
|
|
10
IO.cpp
10
IO.cpp
|
@ -401,3 +401,13 @@ bool CIO::hasADCOverflow()
|
||||||
return overflow;
|
return overflow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CIO::hasTXOverflow()
|
||||||
|
{
|
||||||
|
return m_txBuffer.hasOverflowed();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CIO::hasRXOverflow()
|
||||||
|
{
|
||||||
|
return m_rxBuffer.hasOverflowed();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
3
IO.h
3
IO.h
|
@ -43,6 +43,9 @@ public:
|
||||||
|
|
||||||
bool hasADCOverflow();
|
bool hasADCOverflow();
|
||||||
|
|
||||||
|
bool hasTXOverflow();
|
||||||
|
bool hasRXOverflow();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
#if defined(__MBED__)
|
#if defined(__MBED__)
|
||||||
DigitalOut m_pinPTT;
|
DigitalOut m_pinPTT;
|
||||||
|
|
16
SampleRB.cpp
16
SampleRB.cpp
|
@ -27,7 +27,8 @@ m_samples(NULL),
|
||||||
m_control(NULL),
|
m_control(NULL),
|
||||||
m_head(0U),
|
m_head(0U),
|
||||||
m_tail(0U),
|
m_tail(0U),
|
||||||
m_full(false)
|
m_full(false),
|
||||||
|
m_overflow(false)
|
||||||
{
|
{
|
||||||
m_samples = new uint16_t[length];
|
m_samples = new uint16_t[length];
|
||||||
m_control = new uint8_t[length];
|
m_control = new uint8_t[length];
|
||||||
|
@ -65,8 +66,10 @@ void CSampleRB::put(uint16_t sample, uint8_t control)
|
||||||
if (m_head >= m_length)
|
if (m_head >= m_length)
|
||||||
m_head = 0U;
|
m_head = 0U;
|
||||||
|
|
||||||
if (m_head == m_tail)
|
if (m_head == m_tail) {
|
||||||
|
m_overflow = true;
|
||||||
m_full = true;
|
m_full = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSampleRB::get(uint16_t& sample, uint8_t& control)
|
void CSampleRB::get(uint16_t& sample, uint8_t& control)
|
||||||
|
@ -81,3 +84,12 @@ void CSampleRB::get(uint16_t& sample, uint8_t& control)
|
||||||
m_tail = 0U;
|
m_tail = 0U;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CSampleRB::hasOverflowed()
|
||||||
|
{
|
||||||
|
bool overflow = m_overflow;
|
||||||
|
|
||||||
|
m_overflow = false;
|
||||||
|
|
||||||
|
return overflow;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,8 @@ public:
|
||||||
|
|
||||||
void get(uint16_t& sample, uint8_t& control);
|
void get(uint16_t& sample, uint8_t& control);
|
||||||
|
|
||||||
|
bool hasOverflowed();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint16_t m_length;
|
uint16_t m_length;
|
||||||
volatile uint16_t* m_samples;
|
volatile uint16_t* m_samples;
|
||||||
|
@ -46,6 +48,7 @@ private:
|
||||||
volatile uint16_t m_head;
|
volatile uint16_t m_head;
|
||||||
volatile uint16_t m_tail;
|
volatile uint16_t m_tail;
|
||||||
volatile bool m_full;
|
volatile bool m_full;
|
||||||
|
bool m_overflow;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -56,7 +56,7 @@ const uint8_t MMDVM_DEBUG4 = 0xF4U;
|
||||||
const uint8_t MMDVM_DEBUG5 = 0xF5U;
|
const uint8_t MMDVM_DEBUG5 = 0xF5U;
|
||||||
const uint8_t MMDVM_SAMPLES = 0xF8U;
|
const uint8_t MMDVM_SAMPLES = 0xF8U;
|
||||||
|
|
||||||
const uint8_t HARDWARE[] = "MMDVM 20160113 (D-Star/DMR/System Fusion)";
|
const uint8_t HARDWARE[] = "MMDVM 20160114 (D-Star/DMR/System Fusion)";
|
||||||
|
|
||||||
const uint8_t PROTOCOL_VERSION = 1U;
|
const uint8_t PROTOCOL_VERSION = 1U;
|
||||||
|
|
||||||
|
@ -120,6 +120,12 @@ void CSerialPort::getStatus() const
|
||||||
if (io.hasADCOverflow())
|
if (io.hasADCOverflow())
|
||||||
reply[5U] |= 0x02U;
|
reply[5U] |= 0x02U;
|
||||||
|
|
||||||
|
if (io.hasRXOverflow())
|
||||||
|
reply[5U] |= 0x04U;
|
||||||
|
|
||||||
|
if (io.hasTXOverflow())
|
||||||
|
reply[5U] |= 0x08U;
|
||||||
|
|
||||||
if (m_dstarEnable)
|
if (m_dstarEnable)
|
||||||
reply[6U] = dstarTX.getSpace();
|
reply[6U] = dstarTX.getSpace();
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue