Add lockout functionality with the option to use the COS line.

This commit is contained in:
Jonathan Naylor 2016-03-03 17:49:03 +00:00
parent 7258bf34fb
commit e7334a2d7a
4 changed files with 45 additions and 2 deletions

View File

@ -21,6 +21,9 @@
// #define WANT_DEBUG // #define WANT_DEBUG
// Allow the use of the COS line to lockout the modem
// #define USE_COS_AS_LOCKOUT
// For the original Arduino Due pin layout // For the original Arduino Due pin layout
// #define ARDUINO_DUE_PAPA // #define ARDUINO_DUE_PAPA

34
IO.cpp
View File

@ -95,6 +95,7 @@ CIO::CIO() :
m_pinPTT(PIN_PTT), m_pinPTT(PIN_PTT),
m_pinCOSLED(PIN_COSLED), m_pinCOSLED(PIN_COSLED),
m_pinLED(LED1), m_pinLED(LED1),
m_pinCOS(PIN_COS),
m_pinADC(PIN_ADC), m_pinADC(PIN_ADC),
m_pinDAC(PIN_DAC), m_pinDAC(PIN_DAC),
m_ticker(), m_ticker(),
@ -114,7 +115,8 @@ m_ledValue(true),
m_dcd(false), m_dcd(false),
m_overflow(0U), m_overflow(0U),
m_overcount(0U), m_overcount(0U),
m_watchdog(0U) m_watchdog(0U),
m_lockout(false)
{ {
::memset(m_C4FSKState, 0x00U, 70U * sizeof(q15_t)); ::memset(m_C4FSKState, 0x00U, 70U * sizeof(q15_t));
::memset(m_GMSKState, 0x00U, 40U * sizeof(q15_t)); ::memset(m_GMSKState, 0x00U, 40U * sizeof(q15_t));
@ -132,6 +134,7 @@ m_watchdog(0U)
pinMode(PIN_PTT, OUTPUT); pinMode(PIN_PTT, OUTPUT);
pinMode(PIN_COSLED, OUTPUT); pinMode(PIN_COSLED, OUTPUT);
pinMode(PIN_LED, OUTPUT); pinMode(PIN_LED, OUTPUT);
pinMode(PIN_COS, INPUT);
#endif #endif
} }
@ -232,6 +235,14 @@ void CIO::process()
return; return;
} }
#if defined(USE_COS_AS_LOCKOUT)
#if defined(__MBED__)
m_lockout = m_pinCOS.read() == 1;
#else
m_lockout = digitalRead(PIN_COS) == HIGH;
#endif
#endif
// Switch off the transmitter if needed // Switch off the transmitter if needed
if (m_txBuffer.getData() == 0U && m_tx) { if (m_txBuffer.getData() == 0U && m_tx) {
m_tx = false; m_tx = false;
@ -242,6 +253,19 @@ void CIO::process()
#endif #endif
} }
if (m_lockout) {
// Drain the receive queue
if (m_rxBuffer.getData() >= RX_BLOCK_SIZE) {
for (uint16_t i = 0U; i < RX_BLOCK_SIZE; i++) {
uint16_t sample;
uint8_t control;
m_rxBuffer.get(sample, control);
}
}
return;
}
if (m_rxBuffer.getData() >= RX_BLOCK_SIZE) { if (m_rxBuffer.getData() >= RX_BLOCK_SIZE) {
q15_t samples[RX_BLOCK_SIZE]; q15_t samples[RX_BLOCK_SIZE];
uint8_t control[RX_BLOCK_SIZE]; uint8_t control[RX_BLOCK_SIZE];
@ -317,6 +341,9 @@ void CIO::write(q15_t* samples, uint16_t length, const uint8_t* control)
if (!m_started) if (!m_started)
return; return;
if (m_lockout)
return;
// Switch the transmitter on if needed // Switch the transmitter on if needed
if (!m_tx) { if (!m_tx) {
m_tx = true; m_tx = true;
@ -419,3 +446,8 @@ void CIO::resetWatchdog()
m_watchdog = 0U; m_watchdog = 0U;
} }
bool CIO::hasLockout() const
{
return m_lockout;
}

5
IO.h
View File

@ -46,6 +46,8 @@ public:
bool hasTXOverflow(); bool hasTXOverflow();
bool hasRXOverflow(); bool hasRXOverflow();
bool hasLockout() const;
void resetWatchdog(); void resetWatchdog();
private: private:
@ -53,6 +55,7 @@ private:
DigitalOut m_pinPTT; DigitalOut m_pinPTT;
DigitalOut m_pinCOSLED; DigitalOut m_pinCOSLED;
DigitalOut m_pinLED; DigitalOut m_pinLED;
DigitalIn m_pinCOS;
AnalogIn m_pinADC; AnalogIn m_pinADC;
AnalogOut m_pinDAC; AnalogOut m_pinDAC;
@ -83,6 +86,8 @@ private:
uint16_t m_overcount; uint16_t m_overcount;
volatile uint32_t m_watchdog; volatile uint32_t m_watchdog;
bool m_lockout;
}; };
#endif #endif

View File

@ -57,7 +57,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 20160229 (D-Star/DMR/System Fusion)"; const uint8_t HARDWARE[] = "MMDVM 20160303 (D-Star/DMR/System Fusion)";
const uint8_t PROTOCOL_VERSION = 1U; const uint8_t PROTOCOL_VERSION = 1U;
@ -129,6 +129,9 @@ void CSerialPort::getStatus() const
if (io.hasTXOverflow()) if (io.hasTXOverflow())
reply[5U] |= 0x08U; reply[5U] |= 0x08U;
if (io.hasLockout())
reply[5U] |= 0x10U;
if (m_dstarEnable) if (m_dstarEnable)
reply[6U] = dstarTX.getSpace(); reply[6U] = dstarTX.getSpace();
else else