diff --git a/IO.cpp b/IO.cpp index e5fbe29..6953d3a 100644 --- a/IO.cpp +++ b/IO.cpp @@ -119,7 +119,8 @@ m_ledCount(0U), m_ledValue(true), m_dcd(false), m_overflow(0U), -m_overcount(0U) +m_overcount(0U), +m_watchdog(0U) { ::memset(m_C4FSKState, 0x00U, 70U * sizeof(q15_t)); ::memset(m_GMSKState, 0x00U, 40U * sizeof(q15_t)); @@ -208,6 +209,17 @@ void CIO::process() { m_ledCount++; if (m_started) { + // Two seconds timeout + if (m_watchdog >= 48000U) { + if (m_modemState == STATE_DSTAR || m_modemState == STATE_DMR || m_modemState == STATE_YSF) { + if (m_modemState == STATE_DMR) + dmrTX.setStart(false); + m_modemState = STATE_IDLE; + } + + m_watchdog = 0U; + } + if (m_ledCount >= 24000U) { m_ledCount = 0U; m_ledValue = !m_ledValue; @@ -358,6 +370,8 @@ void CIO::interrupt() #endif m_rxBuffer.put(sample, control); + + m_watchdog++; } void CIO::setDecode(bool dcd) @@ -411,3 +425,8 @@ bool CIO::hasRXOverflow() return m_rxBuffer.hasOverflowed(); } +void CIO::resetWatchdog() +{ + m_watchdog = 0U; +} + diff --git a/IO.h b/IO.h index ed0905b..2ac77fd 100644 --- a/IO.h +++ b/IO.h @@ -46,6 +46,8 @@ public: bool hasTXOverflow(); bool hasRXOverflow(); + void resetWatchdog(); + private: #if defined(__MBED__) DigitalOut m_pinPTT; @@ -79,6 +81,8 @@ private: uint16_t m_overflow; uint16_t m_overcount; + + volatile uint32_t m_watchdog; }; #endif diff --git a/SerialPort.cpp b/SerialPort.cpp index 5c38118..9c6b56a 100644 --- a/SerialPort.cpp +++ b/SerialPort.cpp @@ -98,6 +98,8 @@ void CSerialPort::sendNAK(uint8_t err) const void CSerialPort::getStatus() const { + io.resetWatchdog(); + uint8_t reply[11U]; // Send all sorts of interesting internal values