Fix arm/disarm/arm bug when using shared msp/telemetry ports.
All msp ports are now re-initialised when disarming.
Bug wa introduced by c06fd78b83
- see
#144.
Runtime serial port scenario should not have been erased.
Fixes #144 and #155. Cleanup #125.
This commit is contained in:
parent
2d7184b25b
commit
db36cfe12e
|
@ -41,6 +41,7 @@ uartPort_t *serialUSART3(uint32_t baudRate, portMode_t mode);
|
|||
static void uartReconfigure(uartPort_t *uartPort)
|
||||
{
|
||||
USART_InitTypeDef USART_InitStructure;
|
||||
USART_Cmd(uartPort->USARTx, DISABLE);
|
||||
|
||||
USART_InitStructure.USART_BaudRate = uartPort->port.baudRate;
|
||||
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
|
||||
|
@ -59,6 +60,7 @@ static void uartReconfigure(uartPort_t *uartPort)
|
|||
USART_InitStructure.USART_Mode |= USART_Mode_Tx;
|
||||
|
||||
USART_Init(uartPort->USARTx, &USART_InitStructure);
|
||||
USART_Cmd(uartPort->USARTx, ENABLE);
|
||||
}
|
||||
|
||||
serialPort_t *uartOpen(USART_TypeDef *USARTx, serialReceiveCallbackPtr callback, uint32_t baudRate, portMode_t mode, serialInversion_e inversion)
|
||||
|
@ -170,7 +172,6 @@ void uartSetBaudRate(serialPort_t *instance, uint32_t baudRate)
|
|||
uartPort_t *uartPort = (uartPort_t *)instance;
|
||||
uartPort->port.baudRate = baudRate;
|
||||
uartReconfigure(uartPort);
|
||||
USART_Cmd(uartPort->USARTx, ENABLE);
|
||||
}
|
||||
|
||||
void uartSetMode(serialPort_t *instance, portMode_t mode)
|
||||
|
@ -178,7 +179,6 @@ void uartSetMode(serialPort_t *instance, portMode_t mode)
|
|||
uartPort_t *uartPort = (uartPort_t *)instance;
|
||||
uartPort->port.mode = mode;
|
||||
uartReconfigure(uartPort);
|
||||
USART_Cmd(uartPort->USARTx, ENABLE);
|
||||
}
|
||||
|
||||
void uartStartTxDMA(uartPort_t *s)
|
||||
|
|
|
@ -32,10 +32,10 @@
|
|||
#include "drivers/serial_uart.h"
|
||||
#include "drivers/serial_usb_vcp.h"
|
||||
|
||||
#include "io/serial.h"
|
||||
#include "serial_cli.h"
|
||||
#include "serial_msp.h"
|
||||
|
||||
#include "io/serial.h"
|
||||
#include "config/config.h"
|
||||
|
||||
uint32_t getTelemetryProviderBaudRate(void);
|
||||
|
@ -372,7 +372,6 @@ void endSerialPortFunction(serialPort_t *port, serialPortFunction_e function)
|
|||
serialPortFunction_t *serialPortFunction = findSerialPortFunctionByPort(port);
|
||||
|
||||
serialPortFunction->currentFunction = FUNCTION_NONE;
|
||||
serialPortFunction->scenario = SCENARIO_UNUSED;
|
||||
serialPortFunction->port = NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -615,7 +615,11 @@ void mspInit(serialConfig_t *serialConfig)
|
|||
activeBoxIds[activeBoxIdCount++] = BOXSONAR;
|
||||
}
|
||||
|
||||
mspReset(serialConfig);
|
||||
}
|
||||
|
||||
void mspReset(serialConfig_t *serialConfig)
|
||||
{
|
||||
memset(mspPorts, 0x00, sizeof(mspPorts));
|
||||
|
||||
openAllMSPSerialPorts(serialConfig);
|
||||
|
|
|
@ -23,3 +23,4 @@
|
|||
void mspProcess(void);
|
||||
void sendMspTelemetry(void);
|
||||
void mspSetTelemetryPort(serialPort_t *mspTelemetryPort);
|
||||
void mspReset(serialConfig_t *serialConfig);
|
||||
|
|
|
@ -59,8 +59,9 @@
|
|||
#include "io/gimbal.h"
|
||||
#include "io/gps.h"
|
||||
#include "io/ledstrip.h"
|
||||
#include "io/serial_cli.h"
|
||||
#include "io/serial.h"
|
||||
#include "io/serial_cli.h"
|
||||
#include "io/serial_msp.h"
|
||||
#include "io/statusindicator.h"
|
||||
#include "rx/msp.h"
|
||||
#include "telemetry/telemetry.h"
|
||||
|
@ -294,8 +295,17 @@ void annexCode(void)
|
|||
|
||||
void mwDisarm(void)
|
||||
{
|
||||
if (ARMING_FLAG(ARMED))
|
||||
if (ARMING_FLAG(ARMED)) {
|
||||
DISABLE_ARMING_FLAG(ARMED);
|
||||
|
||||
#ifdef TELEMETRY
|
||||
// the telemetry state must be checked immediately so that shared serial ports are released.
|
||||
checkTelemetryState();
|
||||
if (isSerialPortFunctionShared(FUNCTION_TELEMETRY, FUNCTION_MSP)) {
|
||||
mspReset(&masterConfig.serialConfig);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void mwArm(void)
|
||||
|
|
|
@ -33,8 +33,8 @@
|
|||
|
||||
#include "drivers/serial.h"
|
||||
#include "telemetry/telemetry.h"
|
||||
#include "io/serial_msp.h"
|
||||
#include "io/serial.h"
|
||||
#include "io/serial_msp.h"
|
||||
|
||||
static telemetryConfig_t *telemetryConfig;
|
||||
|
||||
|
|
Loading…
Reference in New Issue