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
|
#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);
|
LL_USART_Enable(config->usart);
|
||||||
|
|
||||||
#ifdef USART_ISR_TEACK
|
#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), \
|
.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), \
|
.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) \
|
STM32_UART_IRQ_HANDLER_FUNC(index) \
|
||||||
}; \
|
}; \
|
||||||
\
|
\
|
||||||
|
|
|
@ -32,6 +32,10 @@ struct uart_stm32_config {
|
||||||
bool single_wire;
|
bool single_wire;
|
||||||
/* enable tx/rx pin swap */
|
/* enable tx/rx pin swap */
|
||||||
bool tx_rx_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;
|
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)
|
||||||
|
|
|
@ -14,6 +14,20 @@ properties:
|
||||||
clocks:
|
clocks:
|
||||||
required: true
|
required: true
|
||||||
|
|
||||||
|
tx-invert:
|
||||||
|
type: boolean
|
||||||
|
required: false
|
||||||
|
description: |
|
||||||
|
Invert the binary logic of tx pin. When enabled, physical logic levels are inverted and
|
||||||
|
we use 1=Low, 0=High instead of 1=High, 0=Low.
|
||||||
|
|
||||||
|
rx-invert:
|
||||||
|
type: boolean
|
||||||
|
required: false
|
||||||
|
description: |
|
||||||
|
Invert the binary logic of rx pin. When enabled, physical logic levels are inverted and
|
||||||
|
we use 1=Low, 0=High instead of 1=High, 0=Low.
|
||||||
|
|
||||||
pinctrl-0:
|
pinctrl-0:
|
||||||
required: true
|
required: true
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,20 @@ 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-invert:
|
||||||
|
type: boolean
|
||||||
|
required: false
|
||||||
|
description: |
|
||||||
|
Invert the binary logic of tx pin. When enabled, physical logic levels are inverted and
|
||||||
|
we use 1=Low, 0=High instead of 1=High, 0=Low.
|
||||||
|
|
||||||
|
rx-invert:
|
||||||
|
type: boolean
|
||||||
|
required: false
|
||||||
|
description: |
|
||||||
|
Invert the binary logic of rx pin. When enabled, physical logic levels are inverted and
|
||||||
|
we use 1=Low, 0=High instead of 1=High, 0=Low.
|
||||||
|
|
||||||
pinctrl-0:
|
pinctrl-0:
|
||||||
required: true
|
required: true
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,20 @@ properties:
|
||||||
description: |
|
description: |
|
||||||
Swap the TX and RX pins. Used in case of a cross-wired connection.
|
Swap the TX and RX pins. Used in case of a cross-wired connection.
|
||||||
|
|
||||||
|
tx-invert:
|
||||||
|
type: boolean
|
||||||
|
required: false
|
||||||
|
description: |
|
||||||
|
Invert the binary logic of tx pin. When enabled, physical logic levels are inverted and
|
||||||
|
we use 1=Low, 0=High instead of 1=High, 0=Low.
|
||||||
|
|
||||||
|
rx-invert:
|
||||||
|
type: boolean
|
||||||
|
required: false
|
||||||
|
description: |
|
||||||
|
Invert the binary logic of rx pin. When enabled, physical logic levels are inverted and
|
||||||
|
we use 1=Low, 0=High instead of 1=High, 0=Low.
|
||||||
|
|
||||||
pinctrl-0:
|
pinctrl-0:
|
||||||
required: true
|
required: true
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue