mirror of https://github.com/g4klx/MMDVM.git
Adding watchdog to the host serial port.
This commit is contained in:
parent
fbd9c4d18b
commit
7bb042a6ca
5
IO.cpp
5
IO.cpp
|
@ -336,6 +336,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
1
IO.h
|
@ -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;
|
||||||
|
|
|
@ -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;
|
||||||
|
|
||||||
|
|
|
@ -422,6 +422,9 @@ void CSerialPort::process()
|
||||||
m_buffer[0U] = c;
|
m_buffer[0U] = c;
|
||||||
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
|
||||||
|
@ -647,9 +650,9 @@ void CSerialPort::process()
|
||||||
|
|
||||||
#if defined(SERIAL_REPEATER)
|
#if defined(SERIAL_REPEATER)
|
||||||
case MMDVM_SERIAL: {
|
case MMDVM_SERIAL: {
|
||||||
for (uint8_t i = 3U; i < m_len; i++)
|
for (uint8_t i = 3U; i < m_len; i++)
|
||||||
m_repeat.put(m_buffer[i]);
|
m_repeat.put(m_buffer[i]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -665,23 +668,28 @@ 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();
|
||||||
if (space > 0U) {
|
if (space > 0U) {
|
||||||
int avail = availableForWriteInt(3U);
|
int avail = availableForWriteInt(3U);
|
||||||
if (avail < space)
|
if (avail < space)
|
||||||
space = avail;
|
space = avail;
|
||||||
|
|
||||||
for (uint16_t i = 0U; i < space; i++) {
|
for (uint16_t i = 0U; i < space; i++) {
|
||||||
uint8_t c = m_repeat.get();
|
uint8_t c = m_repeat.get();
|
||||||
writeInt(3U, &c, 1U);
|
writeInt(3U, &c, 1U);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read any incoming serial data
|
// Read any incoming serial data
|
||||||
while (availableInt(3U))
|
while (availableInt(3U))
|
||||||
readInt(3U);
|
readInt(3U);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue