From 344e8fbf044217e5a9e0b949da0e6e3ecc700ccc Mon Sep 17 00:00:00 2001 From: Nicholas Sherlock Date: Mon, 16 Mar 2015 00:25:58 +1300 Subject: [PATCH] Make serial port option checks consistent --- src/main/drivers/serial_softserial.c | 8 ++++---- src/main/drivers/serial_uart.c | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/drivers/serial_softserial.c b/src/main/drivers/serial_softserial.c index e24d765896..2490c83499 100644 --- a/src/main/drivers/serial_softserial.c +++ b/src/main/drivers/serial_softserial.c @@ -52,7 +52,7 @@ void onSerialRxPinChange(timerCCHandlerRec_t *cbRec, captureCompare_t capture); void setTxSignal(softSerial_t *softSerial, uint8_t state) { - if ((softSerial->port.options & SERIAL_INVERTED) == SERIAL_INVERTED) { + if (softSerial->port.options & SERIAL_INVERTED) { state = !state; } @@ -122,7 +122,7 @@ static void serialICConfig(TIM_TypeDef *tim, uint8_t channel, uint16_t polarity) static void serialTimerRxConfig(const timerHardware_t *timerHardwarePtr, uint8_t reference, portOptions_t options) { // start bit is usually a FALLING signal - serialICConfig(timerHardwarePtr->tim, timerHardwarePtr->channel, (options & SERIAL_INVERTED) == SERIAL_INVERTED ? TIM_ICPolarity_Rising : TIM_ICPolarity_Falling); + serialICConfig(timerHardwarePtr->tim, timerHardwarePtr->channel, (options & SERIAL_INVERTED) ? TIM_ICPolarity_Rising : TIM_ICPolarity_Falling); timerChCCHandlerInit(&softSerialPorts[reference].edgeCb, onSerialRxPinChange); timerChConfigCallbacks(timerHardwarePtr, &softSerialPorts[reference].edgeCb, NULL); } @@ -258,7 +258,7 @@ void prepareForNextRxByte(softSerial_t *softSerial) serialICConfig( softSerial->rxTimerHardware->tim, softSerial->rxTimerHardware->channel, - (softSerial->port.options & SERIAL_INVERTED) == SERIAL_INVERTED ? TIM_ICPolarity_Rising : TIM_ICPolarity_Falling + (softSerial->port.options & SERIAL_INVERTED) ? TIM_ICPolarity_Rising : TIM_ICPolarity_Falling ); } } @@ -328,7 +328,7 @@ void onSerialRxPinChange(timerCCHandlerRec_t *cbRec, captureCompare_t capture) UNUSED(capture); softSerial_t *softSerial = container_of(cbRec, softSerial_t, edgeCb); - bool inverted = (softSerial->port.options & SERIAL_INVERTED) == SERIAL_INVERTED; + bool inverted = softSerial->port.options & SERIAL_INVERTED; if ((softSerial->port.mode & MODE_RX) == 0) { return; diff --git a/src/main/drivers/serial_uart.c b/src/main/drivers/serial_uart.c index 885460ea6e..bf2ca2a879 100644 --- a/src/main/drivers/serial_uart.c +++ b/src/main/drivers/serial_uart.c @@ -40,7 +40,7 @@ static void usartConfigurePinInversion(uartPort_t *uartPort) { #if !defined(INVERTER) && !defined(STM32F303xC) UNUSED(uartPort); #else - bool inverted = (uartPort->port.options & SERIAL_INVERTED) == SERIAL_INVERTED; + bool inverted = uartPort->port.options & SERIAL_INVERTED; #ifdef INVERTER if (inverted && uartPort->USARTx == INVERTER_USART) {