mirror of https://github.com/g4klx/MMDVM.git
Add lockout functionality with the option to use the COS line.
This commit is contained in:
parent
7258bf34fb
commit
e7334a2d7a
3
Config.h
3
Config.h
|
@ -21,6 +21,9 @@
|
|||
|
||||
// #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
|
||||
// #define ARDUINO_DUE_PAPA
|
||||
|
||||
|
|
34
IO.cpp
34
IO.cpp
|
@ -95,6 +95,7 @@ CIO::CIO() :
|
|||
m_pinPTT(PIN_PTT),
|
||||
m_pinCOSLED(PIN_COSLED),
|
||||
m_pinLED(LED1),
|
||||
m_pinCOS(PIN_COS),
|
||||
m_pinADC(PIN_ADC),
|
||||
m_pinDAC(PIN_DAC),
|
||||
m_ticker(),
|
||||
|
@ -114,7 +115,8 @@ m_ledValue(true),
|
|||
m_dcd(false),
|
||||
m_overflow(0U),
|
||||
m_overcount(0U),
|
||||
m_watchdog(0U)
|
||||
m_watchdog(0U),
|
||||
m_lockout(false)
|
||||
{
|
||||
::memset(m_C4FSKState, 0x00U, 70U * sizeof(q15_t));
|
||||
::memset(m_GMSKState, 0x00U, 40U * sizeof(q15_t));
|
||||
|
@ -132,6 +134,7 @@ m_watchdog(0U)
|
|||
pinMode(PIN_PTT, OUTPUT);
|
||||
pinMode(PIN_COSLED, OUTPUT);
|
||||
pinMode(PIN_LED, OUTPUT);
|
||||
pinMode(PIN_COS, INPUT);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -232,6 +235,14 @@ void CIO::process()
|
|||
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
|
||||
if (m_txBuffer.getData() == 0U && m_tx) {
|
||||
m_tx = false;
|
||||
|
@ -242,6 +253,19 @@ void CIO::process()
|
|||
#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) {
|
||||
q15_t samples[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)
|
||||
return;
|
||||
|
||||
if (m_lockout)
|
||||
return;
|
||||
|
||||
// Switch the transmitter on if needed
|
||||
if (!m_tx) {
|
||||
m_tx = true;
|
||||
|
@ -419,3 +446,8 @@ void CIO::resetWatchdog()
|
|||
m_watchdog = 0U;
|
||||
}
|
||||
|
||||
bool CIO::hasLockout() const
|
||||
{
|
||||
return m_lockout;
|
||||
}
|
||||
|
||||
|
|
5
IO.h
5
IO.h
|
@ -46,6 +46,8 @@ public:
|
|||
bool hasTXOverflow();
|
||||
bool hasRXOverflow();
|
||||
|
||||
bool hasLockout() const;
|
||||
|
||||
void resetWatchdog();
|
||||
|
||||
private:
|
||||
|
@ -53,6 +55,7 @@ private:
|
|||
DigitalOut m_pinPTT;
|
||||
DigitalOut m_pinCOSLED;
|
||||
DigitalOut m_pinLED;
|
||||
DigitalIn m_pinCOS;
|
||||
|
||||
AnalogIn m_pinADC;
|
||||
AnalogOut m_pinDAC;
|
||||
|
@ -83,6 +86,8 @@ private:
|
|||
uint16_t m_overcount;
|
||||
|
||||
volatile uint32_t m_watchdog;
|
||||
|
||||
bool m_lockout;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -57,7 +57,7 @@ const uint8_t MMDVM_DEBUG4 = 0xF4U;
|
|||
const uint8_t MMDVM_DEBUG5 = 0xF5U;
|
||||
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;
|
||||
|
||||
|
@ -129,6 +129,9 @@ void CSerialPort::getStatus() const
|
|||
if (io.hasTXOverflow())
|
||||
reply[5U] |= 0x08U;
|
||||
|
||||
if (io.hasLockout())
|
||||
reply[5U] |= 0x10U;
|
||||
|
||||
if (m_dstarEnable)
|
||||
reply[6U] = dstarTX.getSpace();
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue