diff --git a/src/main/telemetry/hott.c b/src/main/telemetry/hott.c index 1580e80da..0142e3b53 100644 --- a/src/main/telemetry/hott.c +++ b/src/main/telemetry/hott.c @@ -423,16 +423,19 @@ static void hottCheckSerialData(uint32_t currentMicros) } } +static void workAroundForHottTelemetryOnUsart(serialPort_t *instance, portMode_t mode) { + closeSerialPort(hottPort); + hottPort = openSerialPort(instance->identifier, FUNCTION_TELEMETRY_HOTT, NULL, HOTT_BAUDRATE, mode, SERIAL_NOT_INVERTED); +} + static void hottSendTelemetryData(void) { if (!hottIsSending) { hottIsSending = true; // FIXME temorary workaround for HoTT not working on Hardware serial ports due to hardware/softserial serial port initialisation differences - if ((portConfig->identifier == SERIAL_PORT_SOFTSERIAL1) || (portConfig->identifier == SERIAL_PORT_SOFTSERIAL2)) - serialSetMode(hottPort, MODE_TX); - else { - closeSerialPort(hottPort); - hottPort = openSerialPort(portConfig->identifier, FUNCTION_TELEMETRY_HOTT, NULL, HOTT_BAUDRATE, MODE_TX, SERIAL_NOT_INVERTED); - } + if ((portConfig->identifier == SERIAL_PORT_USART1) || (portConfig->identifier == SERIAL_PORT_USART2) || (portConfig->identifier == SERIAL_PORT_USART3)) + workAroundForHottTelemetryOnUsart(hottPort, MODE_TX); + else + serialSetMode(hottPort, MODE_TX); hottMsgCrc = 0; return; } @@ -440,14 +443,11 @@ static void hottSendTelemetryData(void) { if (hottMsgRemainingBytesToSendCount == 0) { hottMsg = NULL; hottIsSending = false; - // FIXME temorary workaround for HoTT not working on Hardware serial ports due to hardware/softserial serial port initialisation differences - if ((portConfig->identifier == SERIAL_PORT_SOFTSERIAL1) || (portConfig->identifier == SERIAL_PORT_SOFTSERIAL2)) - serialSetMode(hottPort, MODE_RX); - else { - closeSerialPort(hottPort); - hottPort = openSerialPort(portConfig->identifier, FUNCTION_TELEMETRY_HOTT, NULL, HOTT_BAUDRATE, MODE_RX, SERIAL_NOT_INVERTED); - } + if ((portConfig->identifier == SERIAL_PORT_USART1) || (portConfig->identifier == SERIAL_PORT_USART2) || (portConfig->identifier == SERIAL_PORT_USART3)) + workAroundForHottTelemetryOnUsart(hottPort, MODE_RX); + else + serialSetMode(hottPort, MODE_RX); flushHottRxBuffer(); return; }