mirror of
https://github.com/apache/nuttx.git
synced 2026-08-25 07:27:11 +00:00
Unconfigure GPIO pins when closing a serial port to prevent back effects from back-powering on the TX pin. From Kosma Moczek
This commit is contained in:
parent
a095b1b260
commit
bfff6190d0
1 changed files with 32 additions and 0 deletions
|
|
@ -1594,6 +1594,38 @@ static void up_shutdown(struct uart_dev_s *dev)
|
|||
regval = up_serialin(priv, STM32_USART_CR1_OFFSET);
|
||||
regval &= ~(USART_CR1_UE | USART_CR1_TE | USART_CR1_RE);
|
||||
up_serialout(priv, STM32_USART_CR1_OFFSET, regval);
|
||||
|
||||
/* Release pins. "If the serial-attached device is powered down, the TX
|
||||
* pin causes back-powering, potentially confusing the device to the point
|
||||
* of complete lock-up."
|
||||
*
|
||||
* REVISIT: Is unconfiguring the pins appropriate for all device? If not,
|
||||
* then this may need to be a configuration option.
|
||||
*/
|
||||
|
||||
stm32_unconfiggpio(priv->tx_gpio);
|
||||
stm32_unconfiggpio(priv->rx_gpio);
|
||||
|
||||
#ifdef CONFIG_SERIAL_OFLOWCONTROL
|
||||
if (priv->cts_gpio != 0)
|
||||
{
|
||||
stm32_unconfiggpio(priv->cts_gpio);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SERIAL_IFLOWCONTROL
|
||||
if (priv->rts_gpio != 0)
|
||||
{
|
||||
stm32_unconfiggpio(priv->rts_gpio);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if HAVE_RS485
|
||||
if (priv->rs485_dir_gpio != 0)
|
||||
{
|
||||
stm32_unconfiggpio(priv->rs485_dir_gpio);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue