Fix disappearing start bit in SERIAL_BIDIR case.

This commit is contained in:
jflyper 2017-11-26 02:20:02 +09:00
parent 9e06c65fc1
commit fe7cfbdc30
1 changed files with 7 additions and 6 deletions

View File

@ -161,11 +161,7 @@ static void serialInputPortDeActivate(softSerial_t *softSerial)
TIM_CCxCmd(softSerial->timerHardware->tim, softSerial->timerHardware->channel, TIM_CCx_Disable);
#endif
#ifdef STM32F1
IOConfigGPIO(softSerial->rxIO, IOCFG_IN_FLOATING);
#else
IOConfigGPIOAF(softSerial->rxIO, IOCFG_IN_FLOATING, softSerial->timerHardware->alternateFunction);
#endif
softSerial->rxActive = false;
}
@ -380,10 +376,15 @@ void processTxState(softSerial_t *softSerial)
// Half-duplex: Deactivate receiver, activate transmitter
serialInputPortDeActivate(softSerial);
serialOutputPortActivate(softSerial);
}
// Start sending on next bit timing, as port manipulation takes time,
// and continuing here may cause bit period to decrease causing sampling errors
// at the receiver under high rates.
// Note that there will be (little less than) 1-bit delay; take it as "turn around time".
// XXX We may be able to reload counter and continue. (Future work.)
return;
}
}
if (softSerial->bitsLeftToTransmit) {
mask = softSerial->internalTxBuffer & 1;