diff options
author | Gregory Nutt <gnutt@nuttx.org> | 2014-06-30 08:02:26 -0600 |
---|---|---|
committer | Gregory Nutt <gnutt@nuttx.org> | 2014-06-30 08:02:26 -0600 |
commit | 8e09f670c055c55ef865b74d25a77b47c1cf6267 (patch) | |
tree | 291d9bbe02fa04b0e04718f7585c1d7f28c18969 | |
parent | ef98463e77068dfee3ae9cb340eaf6ff6ce50922 (diff) | |
download | px4-nuttx-8e09f670c055c55ef865b74d25a77b47c1cf6267.tar.gz px4-nuttx-8e09f670c055c55ef865b74d25a77b47c1cf6267.tar.bz2 px4-nuttx-8e09f670c055c55ef865b74d25a77b47c1cf6267.zip |
Unconfigure GPIO pins when closing a serial port to prevent back effects from back-powering on the TX pin. From Kosma Moczek
-rw-r--r-- | nuttx/arch/arm/src/stm32/stm32_serial.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/nuttx/arch/arm/src/stm32/stm32_serial.c b/nuttx/arch/arm/src/stm32/stm32_serial.c index ae078bc2a..f5c4ce06d 100644 --- a/nuttx/arch/arm/src/stm32/stm32_serial.c +++ b/nuttx/arch/arm/src/stm32/stm32_serial.c @@ -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 } /**************************************************************************** |