From 5b313b7cec7d8eb3bf698e276ffcc2c15799aff4 Mon Sep 17 00:00:00 2001 From: Andy CA6JAU Date: Sat, 19 Aug 2017 13:54:03 -0300 Subject: [PATCH 1/2] =?UTF-8?q?Replace=20=E2=80=9CGPIO=5FSpeed=5F50MHz?= =?UTF-8?q?=E2=80=9D=20definition=20for=20a=20better=20one=20=E2=80=9CGPIO?= =?UTF-8?q?=5FFast=5FSpeed=E2=80=9D=20(STM32F4)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IOSTM.cpp | 2 +- SerialSTM.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/IOSTM.cpp b/IOSTM.cpp index 56826bb3..f02c347e 100644 --- a/IOSTM.cpp +++ b/IOSTM.cpp @@ -355,7 +355,7 @@ void CIO::initInt() { GPIO_InitTypeDef GPIO_InitStruct; GPIO_StructInit(&GPIO_InitStruct); - GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz; + GPIO_InitStruct.GPIO_Speed = GPIO_Fast_Speed; GPIO_InitStruct.GPIO_OType = GPIO_OType_PP; GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_DOWN; diff --git a/SerialSTM.cpp b/SerialSTM.cpp index e2b128eb..263c034d 100644 --- a/SerialSTM.cpp +++ b/SerialSTM.cpp @@ -184,7 +184,7 @@ void InitUSART1(int speed) GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9 | GPIO_Pin_10; // Tx | Rx - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; + GPIO_InitStructure.GPIO_Speed = GPIO_Fast_Speed; GPIO_Init(GPIOA, &GPIO_InitStructure); // Configure USART baud rate @@ -375,7 +375,7 @@ void InitUSART2(int speed) GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2 | GPIO_Pin_3; // Tx | Rx - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; + GPIO_InitStructure.GPIO_Speed = GPIO_Fast_Speed; GPIO_Init(GPIOA, &GPIO_InitStructure); // Configure USART baud rate @@ -566,7 +566,7 @@ void InitUSART3(int speed) GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10 | GPIO_Pin_11; // Tx | Rx - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; + GPIO_InitStructure.GPIO_Speed = GPIO_Fast_Speed; GPIO_Init(GPIOC, &GPIO_InitStructure); // Configure USART baud rate @@ -758,7 +758,7 @@ void InitUART5(int speed) GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12; // Tx - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; + GPIO_InitStructure.GPIO_Speed = GPIO_Fast_Speed; GPIO_Init(GPIOC, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2; // Rx From 8f317fd332992e410a399af47d6244f933edce42 Mon Sep 17 00:00:00 2001 From: Andy CA6JAU Date: Sun, 20 Aug 2017 11:19:58 -0300 Subject: [PATCH 2/2] Adding watchdog to host serial port --- IO.cpp | 5 +++++ IO.h | 1 + SerialPort.cpp | 47 ++++++++++++++++++++++++++++------------------- 3 files changed, 34 insertions(+), 19 deletions(-) diff --git a/IO.cpp b/IO.cpp index f7111721..fb9a3252 100644 --- a/IO.cpp +++ b/IO.cpp @@ -386,6 +386,11 @@ void CIO::resetWatchdog() m_watchdog = 0U; } +uint32_t CIO::getWatchdog() +{ + return m_watchdog; +} + bool CIO::hasLockout() const { return m_lockout; diff --git a/IO.h b/IO.h index 54218814..6e243c85 100644 --- a/IO.h +++ b/IO.h @@ -52,6 +52,7 @@ class CIO { bool hasLockout() const; void resetWatchdog(); + uint32_t getWatchdog(); private: bool m_started; diff --git a/SerialPort.cpp b/SerialPort.cpp index 3ee2f210..daf0ee9d 100644 --- a/SerialPort.cpp +++ b/SerialPort.cpp @@ -421,6 +421,10 @@ void CSerialPort::process() m_ptr = 1U; m_len = 0U; } + else { + m_ptr = 0U; + m_len = 0U; + } } else if (m_ptr == 1U) { // Handle the frame length m_len = m_buffer[m_ptr] = c; @@ -645,9 +649,9 @@ void CSerialPort::process() #if defined(SERIAL_REPEATER) case MMDVM_SERIAL: { - for (uint8_t i = 3U; i < m_len; i++) - m_repeat.put(m_buffer[i]); - } + for (uint8_t i = 3U; i < m_len; i++) + m_repeat.put(m_buffer[i]); + } break; #endif @@ -663,23 +667,28 @@ void CSerialPort::process() } } + if (io.getWatchdog() >= 48000U) { + m_ptr = 0U; + m_len = 0U; + } + #if defined(SERIAL_REPEATER) - // Write any outgoing serial data - uint16_t space = m_repeat.getData(); - if (space > 0U) { - int avail = availableForWriteInt(3U); - if (avail < space) - space = avail; - - for (uint16_t i = 0U; i < space; i++) { - uint8_t c = m_repeat.get(); - writeInt(3U, &c, 1U); - } - } - - // Read any incoming serial data - while (availableInt(3U)) - readInt(3U); + // Write any outgoing serial data + uint16_t space = m_repeat.getData(); + if (space > 0U) { + int avail = availableForWriteInt(3U); + if (avail < space) + space = avail; + + for (uint16_t i = 0U; i < space; i++) { + uint8_t c = m_repeat.get(); + writeInt(3U, &c, 1U); + } + } + + // Read any incoming serial data + while (availableInt(3U)) + readInt(3U); #endif }