mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-22 07:45:29 +03:00
UART enable disable f4 (#13019)
Enable/disable the F4/AT32 UART TX before changing the TX pin mode
This commit is contained in:
parent
a54bc47e1b
commit
807a7229c9
2 changed files with 14 additions and 0 deletions
|
@ -197,6 +197,10 @@ bool checkUsartTxOutput(uartPort_t *s)
|
||||||
// Enable USART TX output
|
// Enable USART TX output
|
||||||
uart->txPinState = TX_PIN_ACTIVE;
|
uart->txPinState = TX_PIN_ACTIVE;
|
||||||
IOConfigGPIOAF(txIO, IOCFG_AF_PP, uart->tx.af);
|
IOConfigGPIOAF(txIO, IOCFG_AF_PP, uart->tx.af);
|
||||||
|
|
||||||
|
// Enable the UART transmitter
|
||||||
|
usart_transmitter_enable(s->USARTx, true);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
// TX line is pulled low so don't enable USART TX
|
// TX line is pulled low so don't enable USART TX
|
||||||
|
@ -214,6 +218,9 @@ void uartTxMonitor(uartPort_t *s)
|
||||||
if (uart->txPinState == TX_PIN_ACTIVE) {
|
if (uart->txPinState == TX_PIN_ACTIVE) {
|
||||||
IO_t txIO = IOGetByTag(uart->tx.pin);
|
IO_t txIO = IOGetByTag(uart->tx.pin);
|
||||||
|
|
||||||
|
// Disable the UART transmitter
|
||||||
|
usart_transmitter_enable(s->USARTx, false);
|
||||||
|
|
||||||
// Switch TX to an input with pullup so it's state can be monitored
|
// Switch TX to an input with pullup so it's state can be monitored
|
||||||
uart->txPinState = TX_PIN_MONITOR;
|
uart->txPinState = TX_PIN_MONITOR;
|
||||||
IOConfigGPIO(txIO, IOCFG_IPU);
|
IOConfigGPIO(txIO, IOCFG_IPU);
|
||||||
|
|
|
@ -232,6 +232,10 @@ bool checkUsartTxOutput(uartPort_t *s)
|
||||||
// Enable USART TX output
|
// Enable USART TX output
|
||||||
uart->txPinState = TX_PIN_ACTIVE;
|
uart->txPinState = TX_PIN_ACTIVE;
|
||||||
IOConfigGPIOAF(txIO, IOCFG_AF_PP, uart->hardware->af);
|
IOConfigGPIOAF(txIO, IOCFG_AF_PP, uart->hardware->af);
|
||||||
|
|
||||||
|
// Enable the UART transmitter
|
||||||
|
SET_BIT(s->USARTx->CR1, USART_CR1_TE);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
// TX line is pulled low so don't enable USART TX
|
// TX line is pulled low so don't enable USART TX
|
||||||
|
@ -249,6 +253,9 @@ void uartTxMonitor(uartPort_t *s)
|
||||||
if (uart->txPinState == TX_PIN_ACTIVE) {
|
if (uart->txPinState == TX_PIN_ACTIVE) {
|
||||||
IO_t txIO = IOGetByTag(uart->tx.pin);
|
IO_t txIO = IOGetByTag(uart->tx.pin);
|
||||||
|
|
||||||
|
// Disable the UART transmitter
|
||||||
|
CLEAR_BIT(s->USARTx->CR1, USART_CR1_TE);
|
||||||
|
|
||||||
// Switch TX to an input with pullup so it's state can be monitored
|
// Switch TX to an input with pullup so it's state can be monitored
|
||||||
uart->txPinState = TX_PIN_MONITOR;
|
uart->txPinState = TX_PIN_MONITOR;
|
||||||
IOConfigGPIO(txIO, IOCFG_IPU);
|
IOConfigGPIO(txIO, IOCFG_IPU);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue