drivers: serial: add pin inversion to stm32 u(s)art
Additional properties are added to stm32 u(s)art to allow for signal inversion. Signed-off-by: Jonathan Hahn <Jonathan.Hahn@t-online.de>
This commit is contained in:
parent
c065b0ff96
commit
05cc2e1ac3
5 changed files with 60 additions and 0 deletions
|
@ -1639,6 +1639,18 @@ static int uart_stm32_init(const struct device *dev)
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef LL_USART_RXPIN_LEVEL_INVERTED
|
||||
if (config->rx_invert) {
|
||||
LL_USART_SetRXPinLevel(config->usart, LL_USART_RXPIN_LEVEL_INVERTED);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef LL_USART_TXPIN_LEVEL_INVERTED
|
||||
if (config->tx_invert) {
|
||||
LL_USART_SetTXPinLevel(config->usart, LL_USART_TXPIN_LEVEL_INVERTED);
|
||||
}
|
||||
#endif
|
||||
|
||||
LL_USART_Enable(config->usart);
|
||||
|
||||
#ifdef USART_ISR_TEACK
|
||||
|
@ -1751,6 +1763,8 @@ static const struct uart_stm32_config uart_stm32_cfg_##index = { \
|
|||
.pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(index), \
|
||||
.single_wire = DT_INST_PROP_OR(index, single_wire, false), \
|
||||
.tx_rx_swap = DT_INST_PROP_OR(index, tx_rx_swap, false), \
|
||||
.rx_invert = DT_INST_PROP(index, rx_invert), \
|
||||
.tx_invert = DT_INST_PROP(index, tx_invert), \
|
||||
STM32_UART_IRQ_HANDLER_FUNC(index) \
|
||||
}; \
|
||||
\
|
||||
|
|
|
@ -32,6 +32,10 @@ struct uart_stm32_config {
|
|||
bool single_wire;
|
||||
/* enable tx/rx pin swap */
|
||||
bool tx_rx_swap;
|
||||
/* enable rx pin inversion */
|
||||
bool rx_invert;
|
||||
/* enable tx pin inversion */
|
||||
bool tx_invert;
|
||||
const struct pinctrl_dev_config *pcfg;
|
||||
#if defined(CONFIG_UART_INTERRUPT_DRIVEN) || defined(CONFIG_UART_ASYNC_API) || \
|
||||
defined(CONFIG_PM)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue