Skip to content

Commit

Permalink
Add pinswap to all serialrx protocols
Browse files Browse the repository at this point in the history
  • Loading branch information
pmattila committed Jul 31, 2024
1 parent 71c59d3 commit 4d022ac
Show file tree
Hide file tree
Showing 11 changed files with 62 additions and 27 deletions.
4 changes: 3 additions & 1 deletion src/main/rx/crsf.c
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,9 @@ bool crsfRxInit(const rxConfig_t *rxConfig, rxRuntimeState_t *rxRuntimeState)
rxRuntimeState,
crsfBaudrate,
CRSF_PORT_MODE,
CRSF_PORT_OPTIONS | (rxConfig->serialrx_inverted ? SERIAL_INVERTED : 0)
CRSF_PORT_OPTIONS |
(rxConfig->serialrx_inverted ? SERIAL_INVERTED : SERIAL_NOT_INVERTED) |
(rxConfig->pinSwap ? SERIAL_PINSWAP : SERIAL_NOSWAP)
);

if (rssiSource == RSSI_SOURCE_NONE) {
Expand Down
6 changes: 3 additions & 3 deletions src/main/rx/fport.c
Original file line number Diff line number Diff line change
Expand Up @@ -409,9 +409,9 @@ bool fportRxInit(const rxConfig_t *rxConfig, rxRuntimeState_t *rxRuntimeState)
FPORT_BAUDRATE,
MODE_RXTX,
FPORT_PORT_OPTIONS |
(rxConfig->serialrx_inverted ? SERIAL_INVERTED : SERIAL_NOT_INVERTED) |
(rxConfig->halfDuplex ? SERIAL_BIDIR : SERIAL_UNIDIR) |
(rxConfig->pinSwap ? SERIAL_PINSWAP : SERIAL_NOSWAP)
(rxConfig->serialrx_inverted ? SERIAL_INVERTED : SERIAL_NOT_INVERTED) |
(rxConfig->halfDuplex ? SERIAL_BIDIR : SERIAL_UNIDIR) |
(rxConfig->pinSwap ? SERIAL_PINSWAP : SERIAL_NOSWAP)
);

if (fportPort) {
Expand Down
4 changes: 3 additions & 1 deletion src/main/rx/ghst.c
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,9 @@ bool ghstRxInit(const rxConfig_t *rxConfig, rxRuntimeState_t *rxRuntimeState)
NULL,
GHST_RX_BAUDRATE,
GHST_PORT_MODE,
GHST_PORT_OPTIONS | (rxConfig->serialrx_inverted ? SERIAL_INVERTED : 0)
GHST_PORT_OPTIONS |
(rxConfig->serialrx_inverted ? SERIAL_INVERTED : SERIAL_NOT_INVERTED) |
(rxConfig->pinSwap ? SERIAL_PINSWAP : SERIAL_NOSWAP)
);
serialPort->idleCallback = ghstIdle;

Expand Down
7 changes: 4 additions & 3 deletions src/main/rx/ibus.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,10 @@ bool ibusInit(const rxConfig_t *rxConfig, rxRuntimeState_t *rxRuntimeState)
NULL,
IBUS_BAUDRATE,
portShared ? MODE_RXTX : MODE_RX,
(rxConfig->serialrx_inverted ? SERIAL_INVERTED : SERIAL_NOT_INVERTED) |
(rxConfig->halfDuplex || portShared ? SERIAL_BIDIR : SERIAL_UNIDIR) |
(rxConfig->pinSwap ? SERIAL_PINSWAP : SERIAL_NOSWAP)
SERIAL_STOPBITS_1 | SERIAL_PARITY_NO |
(rxConfig->serialrx_inverted ? SERIAL_INVERTED : SERIAL_NOT_INVERTED) |
(rxConfig->halfDuplex || portShared ? SERIAL_BIDIR : SERIAL_UNIDIR) |
(rxConfig->pinSwap ? SERIAL_PINSWAP : SERIAL_NOSWAP)
);

#if defined(USE_TELEMETRY) && defined(USE_TELEMETRY_IBUS)
Expand Down
4 changes: 3 additions & 1 deletion src/main/rx/jetiexbus.c
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,9 @@ bool jetiExBusInit(const rxConfig_t *rxConfig, rxRuntimeState_t *rxRuntimeState)
NULL,
JETIEXBUS_BAUDRATE,
MODE_RXTX,
JETIEXBUS_OPTIONS | (rxConfig->serialrx_inverted ? SERIAL_INVERTED : 0) | SERIAL_BIDIR
JETIEXBUS_OPTIONS | SERIAL_BIDIR |
(rxConfig->serialrx_inverted ? SERIAL_INVERTED : SERIAL_NOT_INVERTED) |
(rxConfig->pinSwap ? SERIAL_PINSWAP : SERIAL_NOSWAP)
);
return jetiExBusPort != NULL;
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/rx/sbus.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,9 @@ bool sbusInit(const rxConfig_t *rxConfig, rxRuntimeState_t *rxRuntimeState)
sbusBaudRate,
portShared ? MODE_RXTX : MODE_RX,
SBUS_PORT_OPTIONS |
(rxConfig->serialrx_inverted ? SERIAL_NOT_INVERTED : SERIAL_INVERTED) |
(rxConfig->halfDuplex ? SERIAL_BIDIR : SERIAL_UNIDIR) |
(rxConfig->pinSwap ? SERIAL_PINSWAP : SERIAL_NOSWAP)
(rxConfig->serialrx_inverted ? SERIAL_NOT_INVERTED : SERIAL_INVERTED) |
(rxConfig->halfDuplex ? SERIAL_BIDIR : SERIAL_UNIDIR) |
(rxConfig->pinSwap ? SERIAL_PINSWAP : SERIAL_NOSWAP)
);

if (rxConfig->rssi_src_frame_errors) {
Expand Down
19 changes: 12 additions & 7 deletions src/main/rx/srxl2.c
Original file line number Diff line number Diff line change
Expand Up @@ -500,13 +500,18 @@ bool srxl2RxInit(const rxConfig_t *rxConfig, rxRuntimeState_t *rxRuntimeState)
return false;
}

portOptions_e options = SRXL2_PORT_OPTIONS |
(rxConfig->serialrx_inverted ? SERIAL_INVERTED : SERIAL_NOT_INVERTED) |
(rxConfig->halfDuplex ? SERIAL_BIDIR : SERIAL_UNIDIR) |
(rxConfig->pinSwap ? SERIAL_PINSWAP : SERIAL_NOSWAP);

serialPort = openSerialPort(portConfig->identifier, FUNCTION_RX_SERIAL, srxl2DataReceive,
NULL, SRXL2_PORT_BAUDRATE_DEFAULT, SRXL2_PORT_MODE, options);
serialPort = openSerialPort(
portConfig->identifier,
FUNCTION_RX_SERIAL,
srxl2DataReceive,
NULL,
SRXL2_PORT_BAUDRATE_DEFAULT,
SRXL2_PORT_MODE,
SRXL2_PORT_OPTIONS |
(rxConfig->serialrx_inverted ? SERIAL_INVERTED : SERIAL_NOT_INVERTED) |
(rxConfig->halfDuplex ? SERIAL_BIDIR : SERIAL_UNIDIR) |
(rxConfig->pinSwap ? SERIAL_PINSWAP : SERIAL_NOSWAP)
);

if (!serialPort) {
return false;
Expand Down
7 changes: 4 additions & 3 deletions src/main/rx/sumd.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,10 @@ bool sumdInit(const rxConfig_t *rxConfig, rxRuntimeState_t *rxRuntimeState)
NULL,
SUMD_BAUDRATE,
portShared ? MODE_RXTX : MODE_RX,
(rxConfig->serialrx_inverted ? SERIAL_INVERTED : SERIAL_NOT_INVERTED) |
(rxConfig->halfDuplex ? SERIAL_BIDIR : SERIAL_UNIDIR) |
(rxConfig->pinSwap ? SERIAL_PINSWAP : SERIAL_NOSWAP)
SERIAL_STOPBITS_1 | SERIAL_PARITY_NO |
(rxConfig->serialrx_inverted ? SERIAL_INVERTED : SERIAL_NOT_INVERTED) |
(rxConfig->halfDuplex ? SERIAL_BIDIR : SERIAL_UNIDIR) |
(rxConfig->pinSwap ? SERIAL_PINSWAP : SERIAL_NOSWAP)
);

#ifdef USE_TELEMETRY
Expand Down
13 changes: 12 additions & 1 deletion src/main/rx/sumh.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,18 @@ bool sumhInit(const rxConfig_t *rxConfig, rxRuntimeState_t *rxRuntimeState)
bool portShared = false;
#endif

sumhPort = openSerialPort(portConfig->identifier, FUNCTION_RX_SERIAL, sumhDataReceive, NULL, SUMH_BAUDRATE, portShared ? MODE_RXTX : MODE_RX, (rxConfig->serialrx_inverted ? SERIAL_INVERTED : 0));
sumhPort = openSerialPort(
portConfig->identifier,
FUNCTION_RX_SERIAL,
sumhDataReceive,
NULL,
SUMH_BAUDRATE,
portShared ? MODE_RXTX : MODE_RX,
SERIAL_STOPBITS_1 | SERIAL_PARITY_NO |
(rxConfig->serialrx_inverted ? SERIAL_INVERTED : SERIAL_NOT_INVERTED) |
(rxConfig->halfDuplex ? SERIAL_BIDIR : SERIAL_UNIDIR) |
(rxConfig->pinSwap ? SERIAL_PINSWAP : SERIAL_NOSWAP)
);

#ifdef USE_TELEMETRY
if (portShared) {
Expand Down
7 changes: 4 additions & 3 deletions src/main/rx/xbus.c
Original file line number Diff line number Diff line change
Expand Up @@ -314,9 +314,10 @@ bool xBusInit(const rxConfig_t *rxConfig, rxRuntimeState_t *rxRuntimeState)
NULL,
baudRate,
portShared ? MODE_RXTX : MODE_RX,
(rxConfig->serialrx_inverted ? SERIAL_INVERTED : SERIAL_NOT_INVERTED) |
(rxConfig->halfDuplex ? SERIAL_BIDIR : SERIAL_UNIDIR) |
(rxConfig->pinSwap ? SERIAL_PINSWAP : SERIAL_NOSWAP)
SERIAL_STOPBITS_1 | SERIAL_PARITY_NO |
(rxConfig->serialrx_inverted ? SERIAL_INVERTED : SERIAL_NOT_INVERTED) |
(rxConfig->halfDuplex ? SERIAL_BIDIR : SERIAL_UNIDIR) |
(rxConfig->pinSwap ? SERIAL_PINSWAP : SERIAL_NOSWAP)
);

#ifdef USE_TELEMETRY
Expand Down
12 changes: 11 additions & 1 deletion src/main/telemetry/ibus.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,17 @@ void configureIbusTelemetryPort(void)
return;
}

ibusSerialPort = openSerialPort(ibusSerialPortConfig->identifier, FUNCTION_TELEMETRY_IBUS, NULL, NULL, IBUS_BAUDRATE, IBUS_UART_MODE, SERIAL_BIDIR | (telemetryConfig()->telemetry_inverted ? SERIAL_INVERTED : SERIAL_NOT_INVERTED));
ibusSerialPort = openSerialPort(
ibusSerialPortConfig->identifier,
FUNCTION_TELEMETRY_IBUS,
NULL,
NULL,
IBUS_BAUDRATE,
IBUS_UART_MODE,
SERIAL_STOPBITS_1 | SERIAL_PARITY_NO | SERIAL_BIDIR |
(telemetryConfig()->telemetry_inverted ? SERIAL_INVERTED : SERIAL_NOT_INVERTED) |
(telemetryConfig()->pinSwap ? SERIAL_PINSWAP : SERIAL_NOSWAP)
);

if (!ibusSerialPort) {
return;
Expand Down

0 comments on commit 4d022ac

Please sign in to comment.