diff --git a/src/main/config/config.c b/src/main/config/config.c index 25d6128d27..31744673f8 100644 --- a/src/main/config/config.c +++ b/src/main/config/config.c @@ -68,6 +68,7 @@ #include "pg/adc.h" #include "pg/beeper.h" #include "pg/beeper_dev.h" +#include "pg/displayport_profiles.h" #include "pg/gyrodev.h" #include "pg/motor.h" #include "pg/pg.h" @@ -598,6 +599,18 @@ static void validateAndFixConfig(void) batteryConfigMutable()->vbatmaxcellvoltage = VBAT_CELL_VOLTAGE_DEFAULT_MAX; } + // validate that displayport_msp_serial is referencing a valid UART that actually has MSP enabled + if (displayPortProfileMsp()->displayPortSerial != SERIAL_PORT_NONE) { + const serialPortConfig_t *portConfig = serialFindPortConfiguration(displayPortProfileMsp()->displayPortSerial); + if (!portConfig || !(portConfig->functionMask & FUNCTION_MSP) +#ifndef USE_MSP_PUSH_OVER_VCP + || (portConfig->identifier == SERIAL_PORT_USB_VCP) +#endif + ) { + displayPortProfileMspMutable()->displayPortSerial = SERIAL_PORT_NONE; + } + } + #if defined(TARGET_VALIDATECONFIG) // This should be done at the end of the validation targetValidateConfiguration(); diff --git a/src/main/pg/displayport_profiles.c b/src/main/pg/displayport_profiles.c index 537c77c9e6..2e702b6b54 100644 --- a/src/main/pg/displayport_profiles.c +++ b/src/main/pg/displayport_profiles.c @@ -22,13 +22,20 @@ #include "platform.h" +#include "io/serial.h" + #include "pg/displayport_profiles.h" #include "pg/pg.h" #include "pg/pg_ids.h" #if defined(USE_MSP_DISPLAYPORT) -PG_REGISTER(displayPortProfile_t, displayPortProfileMsp, PG_DISPLAY_PORT_MSP_CONFIG, 0); +PG_REGISTER_WITH_RESET_FN(displayPortProfile_t, displayPortProfileMsp, PG_DISPLAY_PORT_MSP_CONFIG, 0); + +void pgResetFn_displayPortProfileMsp(displayPortProfile_t *displayPortProfile) +{ + displayPortProfile->displayPortSerial = SERIAL_PORT_NONE; +} #endif