Merge pull request #104 from juribeparada/master

Adding watchdog to host serial port
This commit is contained in:
Jonathan Naylor 2017-08-20 15:41:04 +01:00 committed by GitHub
commit 5b1075f0f7
5 changed files with 37 additions and 22 deletions

5
IO.cpp
View File

@ -389,6 +389,11 @@ void CIO::resetWatchdog()
m_watchdog = 0U; m_watchdog = 0U;
} }
uint32_t CIO::getWatchdog()
{
return m_watchdog;
}
bool CIO::hasLockout() const bool CIO::hasLockout() const
{ {
return m_lockout; return m_lockout;

1
IO.h
View File

@ -52,6 +52,7 @@ public:
bool hasLockout() const; bool hasLockout() const;
void resetWatchdog(); void resetWatchdog();
uint32_t getWatchdog();
private: private:
bool m_started; bool m_started;

View File

@ -355,7 +355,7 @@ void CIO::initInt()
{ {
GPIO_InitTypeDef GPIO_InitStruct; GPIO_InitTypeDef GPIO_InitStruct;
GPIO_StructInit(&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_OType = GPIO_OType_PP;
GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_DOWN; GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_DOWN;

View File

@ -423,6 +423,10 @@ void CSerialPort::process()
m_ptr = 1U; m_ptr = 1U;
m_len = 0U; m_len = 0U;
} }
else {
m_ptr = 0U;
m_len = 0U;
}
} else if (m_ptr == 1U) { } else if (m_ptr == 1U) {
// Handle the frame length // Handle the frame length
m_len = m_buffer[m_ptr] = c; m_len = m_buffer[m_ptr] = c;
@ -665,6 +669,11 @@ void CSerialPort::process()
} }
} }
if (io.getWatchdog() >= 48000U) {
m_ptr = 0U;
m_len = 0U;
}
#if defined(SERIAL_REPEATER) #if defined(SERIAL_REPEATER)
// Write any outgoing serial data // Write any outgoing serial data
uint16_t space = m_repeat.getData(); uint16_t space = m_repeat.getData();

View File

@ -184,7 +184,7 @@ void InitUSART1(int speed)
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9 | GPIO_Pin_10; // Tx | Rx 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); GPIO_Init(GPIOA, &GPIO_InitStructure);
// Configure USART baud rate // Configure USART baud rate
@ -375,7 +375,7 @@ void InitUSART2(int speed)
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2 | GPIO_Pin_3; // Tx | Rx 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); GPIO_Init(GPIOA, &GPIO_InitStructure);
// Configure USART baud rate // Configure USART baud rate
@ -566,7 +566,7 @@ void InitUSART3(int speed)
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10 | GPIO_Pin_11; // Tx | Rx 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); GPIO_Init(GPIOC, &GPIO_InitStructure);
// Configure USART baud rate // Configure USART baud rate
@ -758,7 +758,7 @@ void InitUART5(int speed)
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12; // Tx 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_Init(GPIOC, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2; // Rx GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2; // Rx