feat: Automatic soft-serial fallback for module ports (#3823)
This commit is contained in:
@@ -343,7 +343,7 @@ const char *FrskyDeviceFirmwareUpdate::doFlashFirmware(
|
||||
//
|
||||
uint8_t serial_module = module != SPORT_MODULE ? module : EXTERNAL_MODULE;
|
||||
|
||||
mod_st = modulePortInitSerial(serial_module, port, &cfg);
|
||||
mod_st = modulePortInitSerial(serial_module, port, &cfg, false);
|
||||
if (!mod_st) return "Communication port error";
|
||||
|
||||
// assume RX port is the same as TX
|
||||
|
||||
@@ -90,31 +90,25 @@ bool MultiFirmwareUpdateDriver::init()
|
||||
{
|
||||
if (type == MULTI_TYPE_MULTIMODULE && module == INTERNAL_MODULE) {
|
||||
// duplex internal USART
|
||||
mod_st = modulePortInitSerial(INTERNAL_MODULE, ETX_MOD_PORT_UART, &serialInitParams);
|
||||
mod_st = modulePortInitSerial(INTERNAL_MODULE, ETX_MOD_PORT_UART, &serialInitParams, false);
|
||||
} else if (type == MULTI_TYPE_MULTIMODULE && module == EXTERNAL_MODULE) {
|
||||
// TX on PPM (inverted softserial)
|
||||
etx_serial_init params(serialInitParams);
|
||||
params.direction = ETX_Dir_TX;
|
||||
params.polarity = ETX_Pol_Inverted;
|
||||
mod_st = modulePortInitSerial(EXTERNAL_MODULE, ETX_MOD_PORT_UART, ¶ms);
|
||||
if (!mod_st) {
|
||||
params.polarity = ETX_Pol_Inverted;
|
||||
mod_st = modulePortInitSerial(EXTERNAL_MODULE, ETX_MOD_PORT_SOFT_INV, ¶ms);
|
||||
if (!mod_st) return false;
|
||||
}
|
||||
mod_st = modulePortInitSerial(EXTERNAL_MODULE, ETX_MOD_PORT_UART, ¶ms, true);
|
||||
if (!mod_st) return false;
|
||||
|
||||
// RX on S.PORT (inverted softserial)
|
||||
params.direction = ETX_Dir_RX;
|
||||
params.polarity = ETX_Pol_Inverted;
|
||||
if (!modulePortInitSerial(EXTERNAL_MODULE, ETX_MOD_PORT_SPORT, ¶ms)) {
|
||||
params.polarity = ETX_Pol_Inverted;
|
||||
if (!modulePortInitSerial(EXTERNAL_MODULE, ETX_MOD_PORT_SPORT_INV, ¶ms)) {
|
||||
modulePortDeInit(mod_st);
|
||||
return false;
|
||||
}
|
||||
if (!modulePortInitSerial(EXTERNAL_MODULE, ETX_MOD_PORT_SPORT, ¶ms, true)) {
|
||||
modulePortDeInit(mod_st);
|
||||
return false;
|
||||
}
|
||||
} else if (type == MULTI_TYPE_ELRS && module == EXTERNAL_MODULE) {
|
||||
// half-duplex on S.PORT USART
|
||||
mod_st = modulePortInitSerial(EXTERNAL_MODULE, ETX_MOD_PORT_SPORT, &serialInitParams);
|
||||
mod_st = modulePortInitSerial(EXTERNAL_MODULE, ETX_MOD_PORT_SPORT, &serialInitParams, false);
|
||||
}
|
||||
|
||||
if (!mod_st) return false;
|
||||
|
||||
Reference in New Issue
Block a user