1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-15 20:35:33 +03:00

Restrict MSP DisplayPort output to the MSP port that is marked

This commit is contained in:
jflyper 2019-10-18 12:24:07 +09:00
parent 8494d6e634
commit 6a8dfa75c2
5 changed files with 16 additions and 6 deletions

View file

@ -63,6 +63,7 @@
#include "io/gimbal.h"
#include "io/gps.h"
#include "io/ledstrip.h"
#include "io/serial.h"
#include "io/vtx.h"
#include "io/vtx_control.h"
#include "io/vtx_rtc6705.h"
@ -1420,6 +1421,7 @@ const clivalue_t valueTable[] = {
#ifdef USE_MSP_DISPLAYPORT
{ "displayport_msp_col_adjust", VAR_INT8 | MASTER_VALUE, .config.minmax = { -6, 0 }, PG_DISPLAY_PORT_MSP_CONFIG, offsetof(displayPortProfile_t, colAdjust) },
{ "displayport_msp_row_adjust", VAR_INT8 | MASTER_VALUE, .config.minmax = { -3, 0 }, PG_DISPLAY_PORT_MSP_CONFIG, offsetof(displayPortProfile_t, rowAdjust) },
{ "displayport_msp_serial", VAR_INT8 | MASTER_VALUE, .config.minmax = { SERIAL_PORT_NONE, SERIAL_PORT_IDENTIFIER_MAX }, PG_DISPLAY_PORT_MSP_CONFIG, offsetof(displayPortProfile_t, displayPortSerial) },
#endif
// PG_DISPLAY_PORT_MSP_CONFIG

View file

@ -60,6 +60,7 @@ typedef struct displayPortProfile_s {
bool invert;
uint8_t blackBrightness;
uint8_t whiteBrightness;
int8_t displayPortSerial; // serialPortIdentifier_e
} displayPortProfile_t;
// Note: displayPortProfile_t used as a parameter group for CMS over CRSF (io/displayport_crsf)

View file

@ -88,7 +88,8 @@ typedef enum {
SERIAL_PORT_USART8,
SERIAL_PORT_USB_VCP = 20,
SERIAL_PORT_SOFTSERIAL1 = 30,
SERIAL_PORT_SOFTSERIAL2
SERIAL_PORT_SOFTSERIAL2,
SERIAL_PORT_IDENTIFIER_MAX = SERIAL_PORT_SOFTSERIAL2
} serialPortIdentifier_e;
extern const serialPortIdentifier_e serialPortIdentifiers[SERIAL_PORT_COUNT];

View file

@ -35,6 +35,7 @@
#include "drivers/system.h"
#include "io/serial.h"
#include "io/displayport_msp.h"
#include "msp/msp.h"
@ -57,6 +58,7 @@ void mspSerialAllocatePorts(void)
serialPortConfig_t *portConfig = findSerialPortConfig(FUNCTION_MSP);
while (portConfig && portIndex < MAX_MSP_PORT_COUNT) {
mspPort_t *mspPort = &mspPorts[portIndex];
if (mspPort->port) {
portIndex++;
continue;
@ -66,6 +68,13 @@ void mspSerialAllocatePorts(void)
if (serialPort) {
bool sharedWithTelemetry = isSerialPortShared(portConfig, FUNCTION_MSP, TELEMETRY_PORT_FUNCTIONS_MASK);
resetMspPort(mspPort, serialPort, sharedWithTelemetry);
#ifdef USE_MSP_DISPLAYPORT
if (serialPort->identifier == displayPortProfileMsp()->displayPortSerial) {
mspPort->isDisplayPort = true;
}
#endif
portIndex++;
}
@ -562,12 +571,8 @@ int mspSerialPush(uint8_t cmd, uint8_t *data, int datalen, mspDirection_e direct
for (int portIndex = 0; portIndex < MAX_MSP_PORT_COUNT; portIndex++) {
mspPort_t * const mspPort = &mspPorts[portIndex];
if (!mspPort->port) {
continue;
}
// XXX Kludge!!! Avoid zombie VCP port (avoid VCP entirely for now)
if (mspPort->port->identifier == SERIAL_PORT_USB_VCP) {
if (!mspPort->port || !mspPort->isDisplayPort) {
continue;
}

View file

@ -111,6 +111,7 @@ typedef struct mspPort_s {
uint8_t checksum2;
bool sharedWithTelemetry;
mspDescriptor_t descriptor;
bool isDisplayPort;
} mspPort_t;
void mspSerialInit(void);