drivers: uart_stm32: Add support for tx/rx swap
Add a new boolean devicetree property `tx-rx-swap` to the st,stm32-usart binding, used to control TX/RX swap during device initialization. Signed-off-by: Alexander Mihajlovic <a@abxy.se>
This commit is contained in:
parent
dcaf8dab14
commit
4ff4991e16
3 changed files with 15 additions and 0 deletions
|
@ -473,6 +473,12 @@ static int uart_stm32_configure(const struct device *dev,
|
||||||
data->baud_rate = cfg->baudrate;
|
data->baud_rate = cfg->baudrate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef LL_USART_TXRX_SWAPPED
|
||||||
|
if (config->tx_rx_swap) {
|
||||||
|
LL_USART_SetTXRXSwap(config->usart, LL_USART_TXRX_SWAPPED);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
LL_USART_Enable(config->usart);
|
LL_USART_Enable(config->usart);
|
||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
|
@ -1715,6 +1721,7 @@ static const struct uart_stm32_config uart_stm32_cfg_##index = { \
|
||||||
.parity = DT_INST_ENUM_IDX_OR(index, parity, UART_CFG_PARITY_NONE), \
|
.parity = DT_INST_ENUM_IDX_OR(index, parity, UART_CFG_PARITY_NONE), \
|
||||||
.pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(index), \
|
.pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(index), \
|
||||||
.single_wire = DT_INST_PROP_OR(index, single_wire, false), \
|
.single_wire = DT_INST_PROP_OR(index, single_wire, false), \
|
||||||
|
.tx_rx_swap = DT_INST_PROP_OR(index, tx_rx_swap, false), \
|
||||||
STM32_UART_IRQ_HANDLER_FUNC(index) \
|
STM32_UART_IRQ_HANDLER_FUNC(index) \
|
||||||
}; \
|
}; \
|
||||||
\
|
\
|
||||||
|
|
|
@ -28,6 +28,8 @@ struct uart_stm32_config {
|
||||||
int parity;
|
int parity;
|
||||||
/* switch to enable single wire / half duplex feature */
|
/* switch to enable single wire / half duplex feature */
|
||||||
bool single_wire;
|
bool single_wire;
|
||||||
|
/* enable tx/rx pin swap */
|
||||||
|
bool tx_rx_swap;
|
||||||
const struct pinctrl_dev_config *pcfg;
|
const struct pinctrl_dev_config *pcfg;
|
||||||
#if defined(CONFIG_UART_INTERRUPT_DRIVEN) || defined(CONFIG_UART_ASYNC_API) || \
|
#if defined(CONFIG_UART_INTERRUPT_DRIVEN) || defined(CONFIG_UART_ASYNC_API) || \
|
||||||
defined(CONFIG_PM)
|
defined(CONFIG_PM)
|
||||||
|
|
|
@ -20,6 +20,12 @@ properties:
|
||||||
only TX pin is used afterwards and should be configured.
|
only TX pin is used afterwards and should be configured.
|
||||||
RX/TX conflicts must be handled on user side.
|
RX/TX conflicts must be handled on user side.
|
||||||
|
|
||||||
|
tx-rx-swap:
|
||||||
|
type: boolean
|
||||||
|
required: false
|
||||||
|
description: |
|
||||||
|
Swap the TX and RX pins. Used in case of a cross-wired connection.
|
||||||
|
|
||||||
pinctrl-0:
|
pinctrl-0:
|
||||||
required: true
|
required: true
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue