From e9a8dc7c6ecf9d3b642cb968c757b9c102bc7422 Mon Sep 17 00:00:00 2001 From: Jussi Kivilinna Date: Tue, 11 Apr 2017 06:39:27 -0600 Subject: [PATCH] STM32F7: serial: disallow broken configuration combination of CONFIG_STM32F7_FLOWCONTROL_BROKEN=y and CONFIG_SERIAL_IFLOWCONTROL_WATERMARKS not set. --- arch/arm/src/stm32f7/Kconfig | 2 +- arch/arm/src/stm32f7/stm32_serial.c | 63 +++++++++++++++++------------ 2 files changed, 39 insertions(+), 26 deletions(-) diff --git a/arch/arm/src/stm32f7/Kconfig b/arch/arm/src/stm32f7/Kconfig index d8eabdcd4b..2c21fadf61 100644 --- a/arch/arm/src/stm32f7/Kconfig +++ b/arch/arm/src/stm32f7/Kconfig @@ -1634,7 +1634,7 @@ config SERIAL_DISABLE_REORDERING config STM32F7_FLOWCONTROL_BROKEN bool "Use Software UART RTS flow control" - depends on STM32F7_USART + depends on STM32F7_USART && SERIAL_IFLOWCONTROL_WATERMARKS default n ---help--- Enable UART RTS flow control using Software. Because STM diff --git a/arch/arm/src/stm32f7/stm32_serial.c b/arch/arm/src/stm32f7/stm32_serial.c index ec97ec7096..ea67ddb4db 100644 --- a/arch/arm/src/stm32f7/stm32_serial.c +++ b/arch/arm/src/stm32f7/stm32_serial.c @@ -220,43 +220,56 @@ /* Warnings for potentially unsafe configuration combinations. */ +#if defined(CONFIG_STM32F7_FLOWCONTROL_BROKEN) && \ + !defined(CONFIG_SERIAL_IFLOWCONTROL_WATERMARKS) +# error "CONFIG_STM32F7_FLOWCONTROL_BROKEN requires \ + CONFIG_SERIAL_IFLOWCONTROL_WATERMARKS to be enabled." +#endif + +#ifndef CONFIG_STM32F7_FLOWCONTROL_BROKEN /* Combination of RXDMA + IFLOWCONTROL does not work as one might expect. * Since RXDMA uses circular DMA-buffer, DMA will always keep reading new * data from USART peripheral even if DMA buffer underruns. Thus this * combination only does following: RTS is asserted on USART setup and * deasserted on shutdown and does not perform actual RTS flow-control. + * + * With SW flow-control, RTS is asserted before UART receive buffer fully + * fills, thus preventing data loss if application is slow to process data + * from serial device node. However, if RxDMA interrupt is blocked for too + * long, data loss is still possible as SW flow-control would also be + * blocked. */ -#if defined(CONFIG_USART1_RXDMA) && defined(CONFIG_USART1_IFLOWCONTROL) -# warning "RXDMA and IFLOWCONTROL both enabled for USART1. \ - This combination can lead to data loss." -#endif +# if defined(CONFIG_USART1_RXDMA) && defined(CONFIG_USART1_IFLOWCONTROL) +# warning "RXDMA and IFLOWCONTROL both enabled for USART1. \ + This combination can lead to data loss." +# endif -#if defined(CONFIG_USART2_RXDMA) && defined(CONFIG_USART2_IFLOWCONTROL) -# warning "RXDMA and IFLOWCONTROL both enabled for USART2. \ - This combination can lead to data loss." -#endif +# if defined(CONFIG_USART2_RXDMA) && defined(CONFIG_USART2_IFLOWCONTROL) +# warning "RXDMA and IFLOWCONTROL both enabled for USART2. \ + This combination can lead to data loss." +# endif -#if defined(CONFIG_USART3_RXDMA) && defined(CONFIG_USART3_IFLOWCONTROL) -# warning "RXDMA and IFLOWCONTROL both enabled for USART3. \ - This combination can lead to data loss." -#endif +# if defined(CONFIG_USART3_RXDMA) && defined(CONFIG_USART3_IFLOWCONTROL) +# warning "RXDMA and IFLOWCONTROL both enabled for USART3. \ + This combination can lead to data loss." +# endif -#if defined(CONFIG_USART6_RXDMA) && defined(CONFIG_USART6_IFLOWCONTROL) -# warning "RXDMA and IFLOWCONTROL both enabled for USART6. \ - This combination can lead to data loss." -#endif +# if defined(CONFIG_USART6_RXDMA) && defined(CONFIG_USART6_IFLOWCONTROL) +# warning "RXDMA and IFLOWCONTROL both enabled for USART6. \ + This combination can lead to data loss." +# endif -#if defined(CONFIG_UART7_RXDMA) && defined(CONFIG_UART7_IFLOWCONTROL) -# warning "RXDMA and IFLOWCONTROL both enabled for UART7. \ - This combination can lead to data loss." -#endif - -#if defined(CONFIG_UART8_RXDMA) && defined(CONFIG_UART8_IFLOWCONTROL) -# warning "RXDMA and IFLOWCONTROL both enabled for UART8. \ - This combination can lead to data loss." -#endif +# if defined(CONFIG_UART7_RXDMA) && defined(CONFIG_UART7_IFLOWCONTROL) +# warning "RXDMA and IFLOWCONTROL both enabled for UART7. \ + This combination can lead to data loss." +# endif +# if defined(CONFIG_UART8_RXDMA) && defined(CONFIG_UART8_IFLOWCONTROL) +# warning "RXDMA and IFLOWCONTROL both enabled for UART8. \ + This combination can lead to data loss." +# endif +#endif /* CONFIG_STM32F7_FLOWCONTROL_BROKEN */ /**************************************************************************** * Private Types