mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-23 00:05:33 +03:00
Tri-state USART TX output if load due to powered down peripheral is detected (#12760)
Tri-state USART TX output if loaded due to powered down peripheral being detected
This commit is contained in:
parent
cbaf9b0265
commit
4dc04d6a33
11 changed files with 239 additions and 28 deletions
|
@ -279,6 +279,8 @@ uartPort_t *serialUART(UARTDevice_e device, uint32_t baudRate, portMode_e mode,
|
|||
s->port.rxBufferSize = hardware->rxBufferSize;
|
||||
s->port.txBufferSize = hardware->txBufferSize;
|
||||
|
||||
s->checkUsartTxOutput = checkUsartTxOutput;
|
||||
|
||||
#ifdef USE_DMA
|
||||
uartConfigureDma(uartdev);
|
||||
#endif
|
||||
|
@ -292,6 +294,8 @@ uartPort_t *serialUART(UARTDevice_e device, uint32_t baudRate, portMode_e mode,
|
|||
IO_t txIO = IOGetByTag(uartdev->tx.pin);
|
||||
IO_t rxIO = IOGetByTag(uartdev->rx.pin);
|
||||
|
||||
uartdev->txPinState = TX_PIN_IGNORE;
|
||||
|
||||
if ((options & SERIAL_BIDIR) && txIO) {
|
||||
ioConfig_t ioCfg = IO_CONFIG(
|
||||
((options & SERIAL_INVERTED) || (options & SERIAL_BIDIR_PP) || (options & SERIAL_BIDIR_PP_PD)) ? GPIO_MODE_AF_PP : GPIO_MODE_AF_OD,
|
||||
|
@ -304,7 +308,14 @@ uartPort_t *serialUART(UARTDevice_e device, uint32_t baudRate, portMode_e mode,
|
|||
} else {
|
||||
if ((mode & MODE_TX) && txIO) {
|
||||
IOInit(txIO, OWNER_SERIAL_TX, RESOURCE_INDEX(device));
|
||||
IOConfigGPIOAF(txIO, IOCFG_AF_PP, uartdev->tx.af);
|
||||
|
||||
if ((options & SERIAL_INVERTED) == SERIAL_NOT_INVERTED) {
|
||||
uartdev->txPinState = TX_PIN_ACTIVE;
|
||||
// Switch TX to an input with pullup so it's state can be monitored
|
||||
uartTxMonitor(s);
|
||||
} else {
|
||||
IOConfigGPIOAF(txIO, IOCFG_AF_PP, uartdev->tx.af);
|
||||
}
|
||||
}
|
||||
|
||||
if ((mode & MODE_RX) && rxIO) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue