From 4e9b5cef259127928ec166fb9b26c1ce75a3fa08 Mon Sep 17 00:00:00 2001 From: phl0 Date: Thu, 17 Nov 2016 00:53:28 +0100 Subject: [PATCH 1/6] Fix length of reported parameters --- SerialPort.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SerialPort.cpp b/SerialPort.cpp index 3092ef6..b623332 100644 --- a/SerialPort.cpp +++ b/SerialPort.cpp @@ -116,7 +116,7 @@ void CSerialPort::getStatus() // Send all sorts of interesting internal values reply[0U] = MMDVM_FRAME_START; - reply[1U] = 10U; + reply[1U] = 11U; reply[2U] = MMDVM_GET_STATUS; reply[3U] = 0x00U; From d3eb7dbd4c22d3de365e285398eaa23b50eb8a89 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Thu, 17 Nov 2016 10:05:36 +0000 Subject: [PATCH 2/6] Use software trigger for RSSI. --- IOTeensy.cpp | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/IOTeensy.cpp b/IOTeensy.cpp index 877ef16..eb0bbbb 100644 --- a/IOTeensy.cpp +++ b/IOTeensy.cpp @@ -108,7 +108,7 @@ void CIO::startInt() ADC1_CFG1 = ADC_CFG1_ADIV(1) | ADC_CFG1_ADICLK(1) | // Single-ended 12 bits, long sample time ADC_CFG1_MODE(1) | ADC_CFG1_ADLSMP; ADC1_CFG2 = ADC_CFG2_MUXSEL | ADC_CFG2_ADLSTS(2); // Select channels ADxxxb - ADC1_SC2 = ADC_SC2_REFSEL(1) | ADC_SC2_ADTRG; // Voltage ref internal, hardware trigger + ADC1_SC2 = ADC_SC2_REFSEL(1); // Voltage ref internal, software trigger ADC1_SC3 = ADC_SC3_CAL | ADC_SC3_AVGE | ADC_SC3_AVGS(0); // Enable averaging, 4 samples while ((ADC1_SC3 & ADC_SC3_CAL) == ADC_SC3_CAL) // Wait for calibration @@ -119,7 +119,6 @@ void CIO::startInt() sum1 = (sum1 / 2U) | 0x8000U; ADC1_PG = sum1; - ADC1_SC1A = ADC_SC1_AIEN | PIN_RSSI; // Enable ADC interrupt, use A2 NVIC_ENABLE_IRQ(IRQ_ADC1); #endif @@ -137,12 +136,7 @@ void CIO::startInt() SIM_SOPT7 |= SIM_SOPT7_ADC0ALTTRGEN | !SIM_SOPT7_ADC0PRETRGSEL | SIM_SOPT7_ADC0TRGSEL(14); -#if defined(SEND_RSSI_DATA) - // Set ADC1 to trigger from the LPTMR - SIM_SOPT7 |= SIM_SOPT7_ADC1ALTTRGEN | - !SIM_SOPT7_ADC1PRETRGSEL | - SIM_SOPT7_ADC1TRGSEL(14); -#endif + NVIC_ENABLE_IRQ(IRQ_LPTMR); #else // Setup PDB for ADC0 (and ADC1) at 24 kHz @@ -150,9 +144,6 @@ void CIO::startInt() PDB0_MOD = F_BUS / 24000; // Timer period PDB0_IDLY = 0; // Interrupt delay PDB0_CH0C1 = PDB_CHnC1_TOS | PDB_CHnC1_EN; // Enable pre-trigger for ADC0 -#if defined(SEND_RSSI_DATA) - PDB0_CH1C1 = PDB_CHnC1_TOS | PDB_CHnC1_EN; // Enable pre-trigger for ADC1 -#endif PDB0_SC = PDB_SC_TRGSEL(15) | PDB_SC_PDBEN | // SW trigger, enable interrupts, continuous mode PDB_SC_PDBIE | PDB_SC_CONT | PDB_SC_LDOK; // No prescaling PDB0_SC |= PDB_SC_SWTRIG; // Software trigger (reset and restart counter) @@ -181,7 +172,9 @@ void CIO::interrupt(uint8_t source) sample = ADC0_RA; m_rxBuffer.put(sample, control); -#if !defined(SEND_RSSI_DATA) +#if defined(SEND_RSSI_DATA) + ADC1_SC1A = ADC_SC1_AIEN | PIN_RSSI; +#else m_rssiBuffer.put(0U); #endif } From e3f35e0875b512db63d227d85b809e453a541439 Mon Sep 17 00:00:00 2001 From: phl0 Date: Thu, 17 Nov 2016 11:29:43 +0100 Subject: [PATCH 3/6] Add carrier detect LED to MMDVM firmware --- IO.cpp | 5 +++++ IO.h | 2 ++ SerialPort.cpp | 9 +++++++-- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/IO.cpp b/IO.cpp index 282a7de..b7721a2 100644 --- a/IO.cpp +++ b/IO.cpp @@ -312,6 +312,11 @@ void CIO::setDecode(bool dcd) m_dcd = dcd; } +bool CIO::getDecode() +{ + return m_dcd; +} + void CIO::setADCDetection(bool detect) { m_detect = detect; diff --git a/IO.h b/IO.h index 2113358..39f2364 100644 --- a/IO.h +++ b/IO.h @@ -51,6 +51,8 @@ public: bool hasLockout() const; + bool getDecode(); + void resetWatchdog(); private: diff --git a/SerialPort.cpp b/SerialPort.cpp index b623332..0f02897 100644 --- a/SerialPort.cpp +++ b/SerialPort.cpp @@ -116,7 +116,7 @@ void CSerialPort::getStatus() // Send all sorts of interesting internal values reply[0U] = MMDVM_FRAME_START; - reply[1U] = 11U; + reply[1U] = 12U; reply[2U] = MMDVM_GET_STATUS; reply[3U] = 0x00U; @@ -180,7 +180,12 @@ void CSerialPort::getStatus() else reply[10U] = 0U; - writeInt(1U, reply, 11); + if (io.getDecode()) + reply[11U] = 1U; + else + reply[11U] = 0U; + + writeInt(1U, reply, 12); } void CSerialPort::getVersion() From 230fab308cec01f76739ba0f44be22d88c100370 Mon Sep 17 00:00:00 2001 From: phl0 Date: Thu, 17 Nov 2016 14:05:19 +0100 Subject: [PATCH 4/6] Make m_dcd global variable and save extra function --- Globals.h | 1 + IO.cpp | 6 ------ IO.h | 1 - MMDVM.cpp | 3 ++- MMDVM.ino | 3 ++- SerialPort.cpp | 2 +- 6 files changed, 6 insertions(+), 10 deletions(-) diff --git a/Globals.h b/Globals.h index 82d4f8e..b0e29bc 100644 --- a/Globals.h +++ b/Globals.h @@ -86,6 +86,7 @@ extern bool m_p25Enable; extern bool m_duplex; extern bool m_tx; +extern bool m_dcd; extern uint32_t m_sampleCount; extern bool m_sampleInsert; diff --git a/IO.cpp b/IO.cpp index b7721a2..006a47c 100644 --- a/IO.cpp +++ b/IO.cpp @@ -61,7 +61,6 @@ m_ysfTXLevel(128 * 128), m_p25TXLevel(128 * 128), m_ledCount(0U), m_ledValue(true), -m_dcd(false), m_detect(false), m_adcOverflow(0U), m_dacOverflow(0U), @@ -312,11 +311,6 @@ void CIO::setDecode(bool dcd) m_dcd = dcd; } -bool CIO::getDecode() -{ - return m_dcd; -} - void CIO::setADCDetection(bool detect) { m_detect = detect; diff --git a/IO.h b/IO.h index 39f2364..27379ed 100644 --- a/IO.h +++ b/IO.h @@ -78,7 +78,6 @@ private: uint32_t m_ledCount; bool m_ledValue; - bool m_dcd; bool m_detect; uint16_t m_adcOverflow; diff --git a/MMDVM.cpp b/MMDVM.cpp index 4f21843..9a410ff 100644 --- a/MMDVM.cpp +++ b/MMDVM.cpp @@ -33,7 +33,8 @@ bool m_p25Enable = true; bool m_duplex = true; -bool m_tx = false; +bool m_tx = false; +bool m_dcd = false; uint32_t m_sampleCount = 0U; bool m_sampleInsert = false; diff --git a/MMDVM.ino b/MMDVM.ino index dac658a..7b30b41 100644 --- a/MMDVM.ino +++ b/MMDVM.ino @@ -30,7 +30,8 @@ bool m_p25Enable = true; bool m_duplex = true; -bool m_tx = false; +bool m_tx = false; +bool m_dcd = false; uint32_t m_sampleCount = 0U; bool m_sampleInsert = false; diff --git a/SerialPort.cpp b/SerialPort.cpp index 0f02897..b77de92 100644 --- a/SerialPort.cpp +++ b/SerialPort.cpp @@ -180,7 +180,7 @@ void CSerialPort::getStatus() else reply[10U] = 0U; - if (io.getDecode()) + if (m_dcd) reply[11U] = 1U; else reply[11U] = 0U; From afce2b6cb9cba9351db61b36f1d4175b855c188a Mon Sep 17 00:00:00 2001 From: phl0 Date: Thu, 17 Nov 2016 14:07:08 +0100 Subject: [PATCH 5/6] Remove forgotten function definition --- IO.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/IO.h b/IO.h index 27379ed..357c04e 100644 --- a/IO.h +++ b/IO.h @@ -51,8 +51,6 @@ public: bool hasLockout() const; - bool getDecode(); - void resetWatchdog(); private: From e3c80e1aedb15fd6a19f497374cb4df7d29ab773 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Thu, 17 Nov 2016 16:02:53 +0000 Subject: [PATCH 6/6] Convert decode to be a bit. --- SerialPort.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/SerialPort.cpp b/SerialPort.cpp index b77de92..7701bbc 100644 --- a/SerialPort.cpp +++ b/SerialPort.cpp @@ -116,7 +116,7 @@ void CSerialPort::getStatus() // Send all sorts of interesting internal values reply[0U] = MMDVM_FRAME_START; - reply[1U] = 12U; + reply[1U] = 11U; reply[2U] = MMDVM_GET_STATUS; reply[3U] = 0x00U; @@ -131,7 +131,8 @@ void CSerialPort::getStatus() reply[4U] = uint8_t(m_modemState); - reply[5U] = m_tx ? 0x01U : 0x00U; + reply[5U] = m_tx ? 0x01U : 0x00U; + reply[5U] |= m_dcd ? 0x02U : 0x00U; bool adcOverflow; bool dacOverflow; @@ -180,12 +181,7 @@ void CSerialPort::getStatus() else reply[10U] = 0U; - if (m_dcd) - reply[11U] = 1U; - else - reply[11U] = 0U; - - writeInt(1U, reply, 12); + writeInt(1U, reply, 11); } void CSerialPort::getVersion()