1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-19 22:35:23 +03:00

Make serial port option checks consistent

This commit is contained in:
Nicholas Sherlock 2015-03-16 00:25:58 +13:00
parent 159f57f583
commit 344e8fbf04
2 changed files with 5 additions and 5 deletions

View file

@ -52,7 +52,7 @@ void onSerialRxPinChange(timerCCHandlerRec_t *cbRec, captureCompare_t capture);
void setTxSignal(softSerial_t *softSerial, uint8_t state) void setTxSignal(softSerial_t *softSerial, uint8_t state)
{ {
if ((softSerial->port.options & SERIAL_INVERTED) == SERIAL_INVERTED) { if (softSerial->port.options & SERIAL_INVERTED) {
state = !state; 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) static void serialTimerRxConfig(const timerHardware_t *timerHardwarePtr, uint8_t reference, portOptions_t options)
{ {
// start bit is usually a FALLING signal // 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); timerChCCHandlerInit(&softSerialPorts[reference].edgeCb, onSerialRxPinChange);
timerChConfigCallbacks(timerHardwarePtr, &softSerialPorts[reference].edgeCb, NULL); timerChConfigCallbacks(timerHardwarePtr, &softSerialPorts[reference].edgeCb, NULL);
} }
@ -258,7 +258,7 @@ void prepareForNextRxByte(softSerial_t *softSerial)
serialICConfig( serialICConfig(
softSerial->rxTimerHardware->tim, softSerial->rxTimerHardware->tim,
softSerial->rxTimerHardware->channel, 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); UNUSED(capture);
softSerial_t *softSerial = container_of(cbRec, softSerial_t, edgeCb); 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) { if ((softSerial->port.mode & MODE_RX) == 0) {
return; return;

View file

@ -40,7 +40,7 @@ static void usartConfigurePinInversion(uartPort_t *uartPort) {
#if !defined(INVERTER) && !defined(STM32F303xC) #if !defined(INVERTER) && !defined(STM32F303xC)
UNUSED(uartPort); UNUSED(uartPort);
#else #else
bool inverted = (uartPort->port.options & SERIAL_INVERTED) == SERIAL_INVERTED; bool inverted = uartPort->port.options & SERIAL_INVERTED;
#ifdef INVERTER #ifdef INVERTER
if (inverted && uartPort->USARTx == INVERTER_USART) { if (inverted && uartPort->USARTx == INVERTER_USART) {