From 3edec35c519d617364d986a2f03f5c7b2a1d42de Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 6 Jun 2013 14:49:14 -0600 Subject: [PATCH] Add flow control support to the STM32 serial driver; Fix some issues with UART2 and 5. From Lorenz Meier and Mike Smith --- ChangeLog | 10 +- arch/arm/src/lpc17xx/Kconfig | 28 - arch/arm/src/lpc17xx/lpc17_lowputc.c | 2 +- arch/arm/src/lpc17xx/lpc17_serial.c | 10 +- arch/arm/src/lpc17xx/lpc17_serial.h | 14 +- arch/arm/src/stm32/stm32_serial.c | 260 ++++++-- drivers/serial/Kconfig | 863 ++++++++++++++++++--------- include/nuttx/serial/serial.h | 2 +- include/termios.h | 3 + 9 files changed, 831 insertions(+), 361 deletions(-) diff --git a/ChangeLog b/ChangeLog index f372a56e6c..9eaff080ec 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4912,5 +4912,13 @@ logic to enabled/disable SAM4L peripheral clocking (2013-6-5). * nuttx/arch/arm/src/sam34/chip/sam4l_bpm.h and sam4l_scif.h: Add register definitions for the SAM4L BMP and SCIF blocks (2013-6-6). - * nuttx/arch/arm/src/sam34/sam4l_clockconfig.c: New selects an + * nuttx/arch/arm/src/sam34/sam4l_clockconfig.c: Now selects an optimal power scaling mode (2013-6-6). + * modified: nuttx/arch/arm/src/stm32/stm32_serial.c +# modified: nuttx/drivers/serial/Kconfig +# modified: nuttx/include/nuttx/serial/serial.h +# modified: nuttx/include/termios.h +A:wq\ + +A + diff --git a/arch/arm/src/lpc17xx/Kconfig b/arch/arm/src/lpc17xx/Kconfig index 6f8967054c..ff383bae4a 100644 --- a/arch/arm/src/lpc17xx/Kconfig +++ b/arch/arm/src/lpc17xx/Kconfig @@ -335,20 +335,6 @@ config SERIAL_TERMIOS If this is not defined, then the terminal settings (baud, parity, etc). are not configurable at runtime; serial streams cannot be flushed, etc.. -config UART0_FLOWCONTROL - bool "UART0 flow control" - depends on LPC17_UART0 - default n - ---help--- - Enable UART0 flow control - -config UART1_FLOWCONTROL - bool "UART1 flow control" - depends on LPC17_UART1 - default n - ---help--- - Enable UART1 flow control - config UART1_RINGINDICATOR bool "UART1 ring indicator" depends on LPC17_UART1 @@ -356,20 +342,6 @@ config UART1_RINGINDICATOR ---help--- Enable UART1 ring indicator -config UART2_FLOWCONTROL - bool "UART0 flow control" - depends on LPC17_UART2 - default n - ---help--- - Enable UART2 flow control - -config UART3_FLOWCONTROL - bool "UART3 flow control" - depends on LPC17_UART3 - default n - ---help--- - Enable UART3 flow control - endmenu menu "ADC driver options" diff --git a/arch/arm/src/lpc17xx/lpc17_lowputc.c b/arch/arm/src/lpc17xx/lpc17_lowputc.c index 9ff0eab60c..3926c87126 100644 --- a/arch/arm/src/lpc17xx/lpc17_lowputc.c +++ b/arch/arm/src/lpc17xx/lpc17_lowputc.c @@ -359,7 +359,7 @@ void lpc17_lowsetup(void) #elif defined(CONFIG_UART1_SERIAL_CONSOLE) lpc17_configgpio(GPIO_UART1_TXD); lpc17_configgpio(GPIO_UART1_RXD); -#ifdef CONFIG_UART1_FLOWCONTROL +#if defined(CONFIG_UART1_IFLOWCONTROL) || defined(CONFIG_UART1_OFLOWCONTROL) lpc17_configgpio(GPIO_UART1_CTS); lpc17_configgpio(GPIO_UART1_DCD); lpc17_configgpio(GPIO_UART1_DSR); diff --git a/arch/arm/src/lpc17xx/lpc17_serial.c b/arch/arm/src/lpc17xx/lpc17_serial.c index 6bf519ac30..ed1a378147 100644 --- a/arch/arm/src/lpc17xx/lpc17_serial.c +++ b/arch/arm/src/lpc17xx/lpc17_serial.c @@ -736,7 +736,7 @@ static inline void lpc17_uart1config(void) lpc17_configgpio(GPIO_UART1_TXD); lpc17_configgpio(GPIO_UART1_RXD); -#ifdef CONFIG_UART1_FLOWCONTROL +#if defined(CONFIG_UART1_IFLOWCONTROL) || defined(CONFIG_UART1_OFLOWCONTROL) lpc17_configgpio(GPIO_UART1_CTS); lpc17_configgpio(GPIO_UART1_RTS); lpc17_configgpio(GPIO_UART1_DCD); @@ -943,10 +943,16 @@ static int up_setup(struct uart_dev_s *dev) /* Enable Auto-RTS and Auto-CS Flow Control in the Modem Control Register */ -#ifdef CONFIG_UART1_FLOWCONTROL +#if defined(CONFIG_UART1_IFLOWCONTROL) || defined(CONFIG_UART1_OFLOWCONTROL) if (priv->uartbase == LPC17_UART1_BASE) { +#if defined(CONFIG_UART1_IFLOWCONTROL) && defined(CONFIG_UART1_OFLOWCONTROL) up_serialout(priv, LPC17_UART_MCR_OFFSET, (UART_MCR_RTSEN|UART_MCR_CTSEN)); +#elif defined(CONFIG_UART1_IFLOWCONTROL) + up_serialout(priv, LPC17_UART_MCR_OFFSET, UART_MCR_RTSEN); +#else + up_serialout(priv, LPC17_UART_MCR_OFFSET, UART_MCR_CTSEN); +#endif } #endif diff --git a/arch/arm/src/lpc17xx/lpc17_serial.h b/arch/arm/src/lpc17xx/lpc17_serial.h index 95e8155de8..3db62f7f8a 100644 --- a/arch/arm/src/lpc17xx/lpc17_serial.h +++ b/arch/arm/src/lpc17xx/lpc17_serial.h @@ -1,7 +1,7 @@ /************************************************************************************ * arch/arm/src/lpc17xx/lpc17_serial.h * - * Copyright (C) 2010 Gregory Nutt. All rights reserved. + * Copyright (C) 2010, 2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -96,11 +96,15 @@ /* Check UART flow control (Only supported by UART1) */ -# undef CONFIG_UART0_FLOWCONTROL -# undef CONFIG_UART2_FLOWCONTROL -# undef CONFIG_UART3_FLOWCONTROL +# undef CONFIG_UART0_IFLOWCONTROL +# undef CONFIG_UART0_OFLOWCONTROL +# undef CONFIG_UART2_IFLOWCONTROL +# undef CONFIG_UART2_OFLOWCONTROL +# undef CONFIG_UART3_IFLOWCONTROL +# undef CONFIG_UART3_OFLOWCONTROL #ifndef CONFIG_LPC17_UART1 -# undef CONFIG_UART1_FLOWCONTROL +# undef CONFIG_UART1_IFLOWCONTROL +# undef CONFIG_UART1_OFLOWCONTROL #endif /* We cannot allow the DLM/DLL divisor to become to small or will will lose too diff --git a/arch/arm/src/stm32/stm32_serial.c b/arch/arm/src/stm32/stm32_serial.c index af95244f00..52a77e2558 100644 --- a/arch/arm/src/stm32/stm32_serial.c +++ b/arch/arm/src/stm32/stm32_serial.c @@ -257,11 +257,23 @@ struct up_dev_s uint8_t parity; /* 0=none, 1=odd, 2=even */ uint8_t bits; /* Number of bits (7 or 8) */ bool stopbits2; /* True: Configure with 2 stop bits instead of 1 */ +#ifdef CONFIG_SERIAL_IFLOWCONTROL + bool iflow; /* input flow control (RTS) enabled */ +#endif +#ifdef CONFIG_SERIAL_OFLOWCONTROL + bool oflow; /* output flow control (CTS) enabled */ +#endif uint32_t baud; /* Configured baud */ #else const uint8_t parity; /* 0=none, 1=odd, 2=even */ const uint8_t bits; /* Number of bits (7 or 8) */ const bool stopbits2; /* True: Configure with 2 stop bits instead of 1 */ +#ifdef CONFIG_SERIAL_IFLOWCONTROL + const bool iflow; /* input flow control (RTS) enabled */ +#endif +#ifdef CONFIG_SERIAL_OFLOWCONTROL + const bool oflow; /* output flow control (CTS) enabled */ +#endif const uint32_t baud; /* Configured baud */ #endif @@ -270,8 +282,12 @@ struct up_dev_s const uint32_t usartbase; /* Base address of USART registers */ const uint32_t tx_gpio; /* U[S]ART TX GPIO pin configuration */ const uint32_t rx_gpio; /* U[S]ART RX GPIO pin configuration */ +#ifdef CONFIG_SERIAL_IFLOWCONTROL const uint32_t rts_gpio; /* U[S]ART RTS GPIO pin configuration */ +#endif +#ifdef CONFIG_SERIAL_OFLOWCONTROL const uint32_t cts_gpio; /* U[S]ART CTS GPIO pin configuration */ +#endif #ifdef SERIAL_HAVE_DMA const unsigned int rxdma_channel; /* DMA channel assigned */ @@ -298,7 +314,7 @@ struct up_dev_s * Private Function Prototypes ****************************************************************************/ -static void up_setspeed(struct uart_dev_s *dev); +static void up_set_format(struct uart_dev_s *dev); static int up_setup(struct uart_dev_s *dev); static void up_shutdown(struct uart_dev_s *dev); static int up_attach(struct uart_dev_s *dev); @@ -492,15 +508,21 @@ static struct up_dev_s g_usart1priv = .parity = CONFIG_USART1_PARITY, .bits = CONFIG_USART1_BITS, .stopbits2 = CONFIG_USART1_2STOP, +#ifdef CONFIG_SERIAL_IFLOWCONTROL + .iflow = false, +#endif +#ifdef CONFIG_SERIAL_OFLOWCONTROL + .oflow = false, +#endif .baud = CONFIG_USART1_BAUD, .apbclock = STM32_PCLK2_FREQUENCY, .usartbase = STM32_USART1_BASE, .tx_gpio = GPIO_USART1_TX, .rx_gpio = GPIO_USART1_RX, -#ifdef GPIO_USART1_CTS +#if defined(CONFIG_SERIAL_OFLOWCONROL) && defined(CONFIG_USART1_OFLOWCONTROL) .cts_gpio = GPIO_USART1_CTS, #endif -#ifdef GPIO_USART1_RTS +#if defined(CONFIG_SERIAL_IFLOWCONROL) && defined(CONFIG_USART1_IFLOWCONTROL) .rts_gpio = GPIO_USART1_RTS, #endif #ifdef CONFIG_USART1_RXDMA @@ -552,15 +574,21 @@ static struct up_dev_s g_usart2priv = .parity = CONFIG_USART2_PARITY, .bits = CONFIG_USART2_BITS, .stopbits2 = CONFIG_USART2_2STOP, +#ifdef CONFIG_SERIAL_IFLOWCONTROL + .iflow = false, +#endif +#ifdef CONFIG_SERIAL_OFLOWCONTROL + .oflow = false, +#endif .baud = CONFIG_USART2_BAUD, .apbclock = STM32_PCLK1_FREQUENCY, .usartbase = STM32_USART2_BASE, .tx_gpio = GPIO_USART2_TX, .rx_gpio = GPIO_USART2_RX, -#ifdef GPIO_USART2_CTS +#if defined(CONFIG_SERIAL_OFLOWCONROL) && defined(CONFIG_USART2_OFLOWCONTROL) .cts_gpio = GPIO_USART2_CTS, #endif -#ifdef GPIO_USART2_RTS +#if defined(CONFIG_SERIAL_IFLOWCONROL) && defined(CONFIG_USART2_IFLOWCONTROL) .rts_gpio = GPIO_USART2_RTS, #endif #ifdef CONFIG_USART2_RXDMA @@ -612,15 +640,21 @@ static struct up_dev_s g_usart3priv = .parity = CONFIG_USART3_PARITY, .bits = CONFIG_USART3_BITS, .stopbits2 = CONFIG_USART3_2STOP, +#ifdef CONFIG_SERIAL_IFLOWCONTROL + .iflow = false, +#endif +#ifdef CONFIG_SERIAL_OFLOWCONTROL + .oflow = false, +#endif .baud = CONFIG_USART3_BAUD, .apbclock = STM32_PCLK1_FREQUENCY, .usartbase = STM32_USART3_BASE, .tx_gpio = GPIO_USART3_TX, .rx_gpio = GPIO_USART3_RX, -#ifdef GPIO_USART3_CTS +#if defined(CONFIG_SERIAL_OFLOWCONROL) && defined(CONFIG_USART3_OFLOWCONTROL) .cts_gpio = GPIO_USART3_CTS, #endif -#ifdef GPIO_USART3_RTS +#if defined(CONFIG_SERIAL_IFLOWCONROL) && defined(CONFIG_USART3_IFLOWCONTROL) .rts_gpio = GPIO_USART3_RTS, #endif #ifdef CONFIG_USART3_RXDMA @@ -672,16 +706,22 @@ static struct up_dev_s g_uart4priv = .parity = CONFIG_UART4_PARITY, .bits = CONFIG_UART4_BITS, .stopbits2 = CONFIG_UART4_2STOP, +#ifdef CONFIG_SERIAL_IFLOWCONTROL + .iflow = false, +#endif +#ifdef CONFIG_SERIAL_OFLOWCONTROL + .oflow = false, +#endif .baud = CONFIG_UART4_BAUD, .apbclock = STM32_PCLK1_FREQUENCY, .usartbase = STM32_UART4_BASE, .tx_gpio = GPIO_UART4_TX, .rx_gpio = GPIO_UART4_RX, -#ifdef GPIO_UART4_CTS - .cts_gpio = GPIO_UART4_CTS, +#ifdef CONFIG_SERIAL_OFLOWCONROL + .cts_gpio = 0, #endif -#ifdef GPIO_UART4_RTS - .rts_gpio = GPIO_UART4_RTS, +#ifdef CONFIG_SERIAL_IFLOWCONROL + .rts_gpio = 0, #endif #ifdef CONFIG_UART4_RXDMA .rxdma_channel = DMAMAP_UART4_RX, @@ -732,16 +772,22 @@ static struct up_dev_s g_uart5priv = .parity = CONFIG_UART5_PARITY, .bits = CONFIG_UART5_BITS, .stopbits2 = CONFIG_UART5_2STOP, +#ifdef CONFIG_SERIAL_IFLOWCONTROL + .iflow = false, +#endif +#ifdef CONFIG_SERIAL_OFLOWCONTROL + .oflow = false, +#endif .baud = CONFIG_UART5_BAUD, .apbclock = STM32_PCLK1_FREQUENCY, .usartbase = STM32_UART5_BASE, .tx_gpio = GPIO_UART5_TX, .rx_gpio = GPIO_UART5_RX, -#ifdef GPIO_UART5_CTS - .cts_gpio = GPIO_UART5_CTS, +#ifdef CONFIG_SERIAL_OFLOWCONROL + .cts_gpio = 0, #endif -#ifdef GPIO_UART5_RTS - .rts_gpio = GPIO_UART5_RTS, +#ifdef CONFIG_SERIAL_IFLOWCONROL + .rts_gpio = 0, #endif #ifdef CONFIG_UART5_RXDMA .rxdma_channel = DMAMAP_UART5_RX, @@ -792,15 +838,21 @@ static struct up_dev_s g_usart6priv = .parity = CONFIG_USART6_PARITY, .bits = CONFIG_USART6_BITS, .stopbits2 = CONFIG_USART6_2STOP, +#ifdef CONFIG_SERIAL_IFLOWCONTROL + .iflow = false, +#endif +#ifdef CONFIG_SERIAL_OFLOWCONTROL + .oflow = false, +#endif .baud = CONFIG_USART6_BAUD, .apbclock = STM32_PCLK2_FREQUENCY, .usartbase = STM32_USART6_BASE, .tx_gpio = GPIO_USART6_TX, .rx_gpio = GPIO_USART6_RX, -#ifdef GPIO_USART6_CTS +#if defined(CONFIG_SERIAL_OFLOWCONROL) && defined(CONFIG_USART6_OFLOWCONTROL) .cts_gpio = GPIO_USART6_CTS, #endif -#ifdef GPIO_USART6_RTS +#if defined(CONFIG_SERIAL_IFLOWCONROL) && defined(CONFIG_USART6_IFLOWCONTROL) .rts_gpio = GPIO_USART6_RTS, #endif #ifdef CONFIG_USART6_RXDMA @@ -857,10 +909,10 @@ static struct up_dev_s g_uart7priv = .usartbase = STM32_UART7_BASE, .tx_gpio = GPIO_UART7_TX, .rx_gpio = GPIO_UART7_RX, -#ifdef GPIO_UART7_CTS +#if defined(CONFIG_SERIAL_OFLOWCONROL) && defined(CONFIG_USART7_OFLOWCONTROL) .cts_gpio = GPIO_UART7_CTS, #endif -#ifdef GPIO_UART7_RTS +#if defined(CONFIG_SERIAL_IFLOWCONROL) && defined(CONFIG_USART7_IFLOWCONTROL) .rts_gpio = GPIO_UART7_RTS, #endif #ifdef CONFIG_UART7_RXDMA @@ -917,10 +969,10 @@ static struct up_dev_s g_uart8priv = .usartbase = STM32_UART8_BASE, .tx_gpio = GPIO_UART8_TX, .rx_gpio = GPIO_UART8_RX, -#ifdef GPIO_UART8_CTS +#if defined(CONFIG_SERIAL_OFLOWCONROL) && defined(CONFIG_USART8_OFLOWCONTROL) .cts_gpio = GPIO_UART8_CTS, #endif -#ifdef GPIO_UART8_RTS +#if defined(CONFIG_SERIAL_IFLOWCONROL) && defined(CONFIG_USART8_IFLOWCONTROL) .rts_gpio = GPIO_UART8_RTS, #endif #ifdef CONFIG_UART8_RXDMA @@ -1091,23 +1143,24 @@ static int up_dma_nextrx(struct up_dev_s *priv) #endif /**************************************************************************** - * Name: up_setspeed + * Name: up_set_format * * Description: - * Set the serial line speed. + * Set the serial line format and speed. * ****************************************************************************/ #ifndef CONFIG_SUPPRESS_UART_CONFIG -static void up_setspeed(struct uart_dev_s *dev) +static void up_set_format(struct uart_dev_s *dev) { -#ifdef CONFIG_STM32_STM32F30XX + struct up_dev_s *priv = (struct up_dev_s*)dev->priv; + uint32_t regval; +#ifdef CONFIG_STM32_STM32F30XX /* This first implementation is for U[S]ARTs that support oversampling * by 8 in additional to the standard oversampling by 16. */ - struct up_dev_s *priv = (struct up_dev_s*)dev->priv; uint32_t usartdiv8; uint32_t cr1; uint32_t brr; @@ -1163,7 +1216,6 @@ static void up_setspeed(struct uart_dev_s *dev) * dividers. */ - struct up_dev_s *priv = (struct up_dev_s*)dev->priv; uint32_t usartdiv32; uint32_t mantissa; uint32_t fraction; @@ -1197,10 +1249,60 @@ static void up_setspeed(struct uart_dev_s *dev) fraction = (usartdiv32 - (mantissa << 5) + 1) >> 1; brr |= fraction << USART_BRR_FRAC_SHIFT; up_serialout(priv, STM32_USART_BRR_OFFSET, brr); +#endif + + /* Configure parity mode */ + + regval = up_serialin(priv, STM32_USART_CR1_OFFSET); + regval &= ~(USART_CR1_PCE|USART_CR1_PS); + + if (priv->parity == 1) /* Odd parity */ + { + regval |= (USART_CR1_PCE|USART_CR1_PS); + } + else if (priv->parity == 2) /* Even parity */ + { + regval |= USART_CR1_PCE; + } + + up_serialout(priv, STM32_USART_CR1_OFFSET, regval); + + /* Configure STOP bits */ + + regval = up_serialin(priv, STM32_USART_CR2_OFFSET); + regval &= ~(USART_CR2_STOP_MASK); + + if (priv->stopbits2) + { + regval |= USART_CR2_STOP2; + } + + up_serialout(priv, STM32_USART_CR2_OFFSET, regval); + + /* Configure hardware flow control */ + + regval = up_serialin(priv, STM32_USART_CR3_OFFSET); + regval &= ~(USART_CR3_CTSE|USART_CR3_RTSE); + +#ifdef CONFIG_SERIAL_IFLOWCONTROL + if (priv->iflow && (priv->rts_gpio != 0)) + { + regval |= USART_CR3_RTSE; + } +#endif + +#ifdef CONFIG_SERIAL_OFLOWCONTROL + if (priv->oflow && (priv->cts_gpio != 0)) + { + regval |= USART_CR3_CTSE; + } +#endif + + up_serialout(priv, STM32_USART_CR3_OFFSET, regval); #endif } -#endif +#endif /* CONFIG_SUPPRESS_UART_CONFIG */ /**************************************************************************** * Name: up_setup @@ -1227,15 +1329,19 @@ static int up_setup(struct uart_dev_s *dev) stm32_configgpio(priv->tx_gpio); stm32_configgpio(priv->rx_gpio); +#ifdef CONFIG_SERIAL_OFLOWCONROL if (priv->cts_gpio != 0) { stm32_configgpio(priv->cts_gpio); } +#endif +#ifdef CONFIG_SERIAL_IFLOWCONROL if (priv->rts_gpio != 0) { stm32_configgpio(priv->rts_gpio); } +#endif #if HAVE_RS485 if (priv->rs485_dir_gpio != 0) @@ -1262,28 +1368,18 @@ static int up_setup(struct uart_dev_s *dev) up_serialout(priv, STM32_USART_CR2_OFFSET, regval); /* Configure CR1 */ - /* Clear M, PCE, PS, TE, REm and all interrupt enable bits */ + /* Clear M, TE, REm and all interrupt enable bits */ regval = up_serialin(priv, STM32_USART_CR1_OFFSET); - regval &= ~(USART_CR1_M|USART_CR1_PCE|USART_CR1_PS|USART_CR1_TE| - USART_CR1_RE|USART_CR1_ALLINTS); + regval &= ~(USART_CR1_M|USART_CR1_TE|USART_CR1_RE|USART_CR1_ALLINTS); - /* Configure word length and parity mode */ + /* Configure word length */ if (priv->bits == 9) /* Default: 1 start, 8 data, n stop */ { regval |= USART_CR1_M; /* 1 start, 9 data, n stop */ } - if (priv->parity == 1) /* Odd parity */ - { - regval |= (USART_CR1_PCE|USART_CR1_PS); - } - else if (priv->parity == 2) /* Even parity */ - { - regval |= USART_CR1_PCE; - } - up_serialout(priv, STM32_USART_CR1_OFFSET, regval); /* Configure CR3 */ @@ -1292,13 +1388,11 @@ static int up_setup(struct uart_dev_s *dev) regval = up_serialin(priv, STM32_USART_CR3_OFFSET); regval &= ~(USART_CR3_CTSIE|USART_CR3_CTSE|USART_CR3_RTSE|USART_CR3_EIE); - /* Configure hardware flow control -- Not yet supported */ - up_serialout(priv, STM32_USART_CR3_OFFSET, regval); - /* Configure the USART Baud Rate. */ + /* Configure the USART line format and speed. */ - up_setspeed(dev); + up_set_format(dev); /* Enable Rx, Tx, and the USART */ @@ -1306,8 +1400,6 @@ static int up_setup(struct uart_dev_s *dev) regval |= (USART_CR1_UE|USART_CR1_TE|USART_CR1_RE); up_serialout(priv, STM32_USART_CR1_OFFSET, regval); -#endif - /* Set up the cached interrupt enables value */ priv->ie = 0; @@ -1333,7 +1425,7 @@ static int up_dma_setup(struct uart_dev_s *dev) /* Do the basic UART setup first, unless we are the console */ if (!dev->isconsole) - { + { result = up_setup(dev); if (result != OK) { @@ -1665,7 +1757,7 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg) up_serialout(priv, STM32_USART_CR3_OFFSET, cr); } - break; + break; #endif #ifdef CONFIG_SERIAL_TERMIOS @@ -1679,12 +1771,25 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg) break; } - /* TODO: Other termios fields are not yet returned. - * Note that only cfsetospeed is not necessary because we have - * knowledge that only one speed is supported. + cfsetispeed(termiosp, priv->baud); + + /* Note that since we only support 8/9 bit modes and + * there is no way to report 9-bit mode, we always claim 8. */ - cfsetispeed(termiosp, priv->baud); + termiosp->c_cflag = + ((priv->parity != 0) ? PARENB : 0) | + ((priv->parity == 1) ? PARODD : 0) | + ((priv->stopbits2) ? CSTOPB : 0) | +#ifdef CONFIG_SERIAL_OFLOWCONTROL + ((priv->oflow) ? CCTS_OFLOW : 0) | +#endif +#ifdef CONFIG_SERIAL_IFLOWCONTROL + ((priv->iflow) ? CRTS_IFLOW : 0) | +#endif + CS8; + + /* TODO: CCTS_IFLOW, CCTS_OFLOW */ } break; @@ -1698,16 +1803,57 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg) break; } - /* TODO: Handle other termios settings. - * Note that only cfgetispeed is used besued we have knowledge + /* Perform some sanity checks before accepting any changes */ + + if (((termiosp->c_cflag & CSIZE) != CS8) +#ifdef CONFIG_SERIAL_IFLOWCONROL + || ((termiosp->c_cflag & CCTS_OFLOW) && (priv->cts_gpio == 0)) +#endif +#ifdef CONFIG_SERIAL_IFLOWCONROL + || ((termiosp->c_cflag & CRTS_IFLOW) && (priv->rts_gpio == 0)) +#endif + ) + { + ret = -EINVAL; + break; + } + + if (termiosp->c_cflag & PARENB) + { + priv->parity = (termiosp->c_cflag & PARODD) ? 1 : 2; + } + else + { + priv->parity = 0; + } + + priv->stopbits2 = (termiosp->c_cflag & CSTOPB) != 0; +#ifdef CONFIG_SERIAL_OFLOWCONTROL + priv->oflow = (termiosp->c_cflag & CCTS_OFLOW) != 0; +#endif +#ifdef CONFIG_SERIAL_IFLOWCONTROL + priv->iflow = (termiosp->c_cflag & CRTS_IFLOW) != 0; +#endif + + /* Note that since there is no way to request 9-bit mode + * and no way to support 5/6/7-bit modes, we ignore them + * all here. + */ + + /* Note that only cfgetispeed is used because we have knowledge * that only one speed is supported. */ priv->baud = cfgetispeed(termiosp); - up_setspeed(dev); + + /* effect the changes immediately - note that we do not implement + * TCSADRAIN / TCSAFLUSH + */ + + up_set_format(dev); } break; -#endif +#endif /* CONFIG_SERIAL_TERMIOS */ #ifdef CONFIG_USART_BREAKS case TIOCSBRK: /* BSD compatibility: Turn break on, unconditionally */ diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig index c013d281fb..8b5868d44f 100644 --- a/drivers/serial/Kconfig +++ b/drivers/serial/Kconfig @@ -66,6 +66,20 @@ config 16550_UART0_TXBUFSIZE ---help--- 16550 UART0 Tx buffer size. Default: 256 +config 16550_UART0_IFLOWCONTROL + bool "16550 UART0 RTS flow control" + default n + select SERIAL_IFLOWCONTROL + ---help--- + Enable 16550 UART0 RTS flow control + +config 16550_UART0_OFLOWCONTROL + bool "16550 UART0 CTS flow control" + default n + select SERIAL_OFLOWCONTROL + ---help--- + Enable 16550 UART0 CTS flow control + endif config 16550_UART1 @@ -116,6 +130,20 @@ config 16550_UART1_TXBUFSIZE ---help--- 16550 UART1 Tx buffer size. Default: 256 +config 16550_UART1_IFLOWCONTROL + bool "16550 UART1 RTS flow control" + default n + select SERIAL_IFLOWCONTROL + ---help--- + Enable 16550 UART1 RTS flow control + +config 16550_UART1_OFLOWCONTROL + bool "16550 UART1 CTS flow control" + default n + select SERIAL_OFLOWCONTROL + ---help--- + Enable 16550 UART1 CTS flow control + endif config 16550_UART2 @@ -166,6 +194,20 @@ config 16550_UART2_TXBUFSIZE ---help--- 16550 UART2 Tx buffer size. Default: 256 +config 16550_UART2_IFLOWCONTROL + bool "16550 UART2 RTS flow control" + default n + select SERIAL_IFLOWCONTROL + ---help--- + Enable 16550 UART2 RTS flow control + +config 16550_UART2_OFLOWCONTROL + bool "16550 UART2 CTS flow control" + default n + select SERIAL_OFLOWCONTROL + ---help--- + Enable 16550 UART2 CTS flow control + endif config 16550_UART3 @@ -216,6 +258,20 @@ config 16550_UART3_TXBUFSIZE ---help--- 16550 UART3 Tx buffer size. Default: 256 +config 16550_UART3_IFLOWCONTROL + bool "16550 UART3 RTS flow control" + default n + select SERIAL_IFLOWCONTROL + ---help--- + Enable 16550 UART3 RTS flow control + +config 16550_UART3_OFLOWCONTROL + bool "16550 UART3 CTS flow control" + default n + select SERIAL_OFLOWCONTROL + ---help--- + Enable 16550 UART3 CTS flow control + endif choice @@ -452,40 +508,54 @@ menu "UART Configuration" config UART_RXBUFSIZE int "Receive buffer size" default 256 - help - Characters are buffered as they are received. This specifies - the size of the receive buffer. + ---help--- + Characters are buffered as they are received. This specifies + the size of the receive buffer. config UART_TXBUFSIZE int "Transmit buffer size" default 256 - help - Characters are buffered before being sent. This specifies - the size of the transmit buffer. + ---help--- + Characters are buffered before being sent. This specifies + the size of the transmit buffer. config UART_BAUD int "BAUD rate" default 115200 - help - The configured BAUD of the UART. + ---help--- + The configured BAUD of the UART. config UART_BITS int "Character size" default 8 - help - The number of bits. Must be either 7 or 8. + ---help--- + The number of bits. Must be either 7 or 8. config UART_PARITY int "Parity setting" default 0 - help - 0=no parity, 1=odd parity, 2=even parity + ---help--- + 0=no parity, 1=odd parity, 2=even parity config UART_2STOP int "use 2 stop bits" default 0 - help - 1=Two stop bits + ---help--- + 1=Two stop bits + +config UART_IFLOWCONTROL + bool "UART RTS flow control" + default n + select SERIAL_IFLOWCONTROL + ---help--- + Enable UART RTS flow control + +config UART_OFLOWCONTROL + bool "UART CTS flow control" + default n + select SERIAL_OFLOWCONTROL + ---help--- + Enable UART CTS flow control endmenu @@ -495,40 +565,54 @@ menu "UART0 Configuration" config UART0_RXBUFSIZE int "Receive buffer size" default 256 - help - Characters are buffered as they are received. This specifies - the size of the receive buffer. + ---help--- + Characters are buffered as they are received. This specifies + the size of the receive buffer. config UART0_TXBUFSIZE int "Transmit buffer size" default 256 - help - Characters are buffered before being sent. This specifies - the size of the transmit buffer. + ---help--- + Characters are buffered before being sent. This specifies + the size of the transmit buffer. config UART0_BAUD int "BAUD rate" default 115200 - help - The configured BAUD of the UART. + ---help--- + The configured BAUD of the UART. config UART0_BITS int "Character size" default 8 - help - The number of bits. Must be either 7 or 8. + ---help--- + The number of bits. Must be either 7 or 8. config UART0_PARITY int "Parity setting" default 0 - help - 0=no parity, 1=odd parity, 2=even parity + ---help--- + 0=no parity, 1=odd parity, 2=even parity config UART0_2STOP int "use 2 stop bits" default 0 - help - 1=Two stop bits + ---help--- + 1=Two stop bits + +config UART0_IFLOWCONTROL + bool "UART0 RTS flow control" + default n + select SERIAL_IFLOWCONTROL + ---help--- + Enable UART0 RTS flow control + +config UART0_OFLOWCONTROL + bool "UART0 CTS flow control" + default n + select SERIAL_OFLOWCONTROL + ---help--- + Enable UART0 CTS flow control endmenu @@ -538,40 +622,54 @@ menu "USART0 Configuration" config USART0_RXBUFSIZE int "Receive buffer size" default 256 - help - Characters are buffered as they are received. This specifies - the size of the receive buffer. + ---help--- + Characters are buffered as they are received. This specifies + the size of the receive buffer. config USART0_TXBUFSIZE int "Transmit buffer size" default 256 - help - Characters are buffered before being sent. This specifies - the size of the transmit buffer. + ---help--- + Characters are buffered before being sent. This specifies + the size of the transmit buffer. config USART0_BAUD int "BAUD rate" default 115200 - help - The configured BAUD of the USART. + ---help--- + The configured BAUD of the USART. config USART0_BITS int "Character size" default 8 - help - The number of bits. Must be either 7 or 8. + ---help--- + The number of bits. Must be either 7 or 8. config USART0_PARITY int "Parity setting" default 0 - help - 0=no parity, 1=odd parity, 2=even parity + ---help--- + 0=no parity, 1=odd parity, 2=even parity config USART0_2STOP int "use 2 stop bits" default 0 - help - 1=Two stop bits + ---help--- + 1=Two stop bits + +config USART0_IFLOWCONTROL + bool "USART0 RTS flow control" + default n + select SERIAL_IFLOWCONTROL + ---help--- + Enable USART0 RTS flow control + +config USART0_OFLOWCONTROL + bool "USART0 CTS flow control" + default n + select SERIAL_OFLOWCONTROL + ---help--- + Enable USART0 CTS flow control endmenu @@ -581,40 +679,54 @@ menu "UART1 Configuration" config UART1_RXBUFSIZE int "Receive buffer size" default 256 - help - Characters are buffered as they are received. This specifies - the size of the receive buffer. + ---help--- + Characters are buffered as they are received. This specifies + the size of the receive buffer. config UART1_TXBUFSIZE int "Transmit buffer size" default 256 - help - Characters are buffered before being sent. This specifies - the size of the transmit buffer. + ---help--- + Characters are buffered before being sent. This specifies + the size of the transmit buffer. config UART1_BAUD int "BAUD rate" default 115200 - help - The configured BAUD of the UART. + ---help--- + The configured BAUD of the UART. config UART1_BITS int "Character size" default 8 - help - The number of bits. Must be either 7 or 8. + ---help--- + The number of bits. Must be either 7 or 8. config UART1_PARITY int "Parity setting" default 0 - help - 0=no parity, 1=odd parity, 2=even parity + ---help--- + 0=no parity, 1=odd parity, 2=even parity config UART1_2STOP int "Uses 2 stop bits" default 0 - help - 1=Two stop bits + ---help--- + 1=Two stop bits + +config UART1_IFLOWCONTROL + bool "UART1 RTS flow control" + default n + select SERIAL_IFLOWCONTROL + ---help--- + Enable UART1 RTS flow control + +config UART1_OFLOWCONTROL + bool "UART1 CTS flow control" + default n + select SERIAL_OFLOWCONTROL + ---help--- + Enable UART1 CTS flow control endmenu @@ -624,40 +736,54 @@ menu "USART1 Configuration" config USART1_RXBUFSIZE int "Receive buffer size" default 256 - help - Characters are buffered as they are received. This specifies - the size of the receive buffer. + ---help--- + Characters are buffered as they are received. This specifies + the size of the receive buffer. config USART1_TXBUFSIZE int "Transmit buffer size" default 256 - help - Characters are buffered before being sent. This specifies - the size of the transmit buffer. + ---help--- + Characters are buffered before being sent. This specifies + the size of the transmit buffer. config USART1_BAUD int "BAUD rate" default 115200 - help - The configured BAUD of the USART. + ---help--- + The configured BAUD of the USART. config USART1_BITS int "Character size" default 8 - help - The number of bits. Must be either 7 or 8. + ---help--- + The number of bits. Must be either 7 or 8. config USART1_PARITY int "Parity setting" default 0 - help - 0=no parity, 1=odd parity, 2=even parity + ---help--- + 0=no parity, 1=odd parity, 2=even parity config USART1_2STOP int "Uses 2 stop bits" default 0 - help - 1=Two stop bits + ---help--- + 1=Two stop bits + +config USART1_IFLOWCONTROL + bool "USART1 RTS flow control" + default n + select SERIAL_IFLOWCONTROL + ---help--- + Enable USART1 RTS flow control + +config USART1_OFLOWCONTROL + bool "USART1 CTS flow control" + default n + select SERIAL_OFLOWCONTROL + ---help--- + Enable USART1 CTS flow control endmenu @@ -667,40 +793,54 @@ menu "UART2 Configuration" config UART2_RXBUFSIZE int "Receive buffer size" default 256 - help - Characters are buffered as they are received. This specifies - the size of the receive buffer. + ---help--- + Characters are buffered as they are received. This specifies + the size of the receive buffer. config UART2_TXBUFSIZE int "Transmit buffer size" default 256 - help - Characters are buffered before being sent. This specifies - the size of the transmit buffer. + ---help--- + Characters are buffered before being sent. This specifies + the size of the transmit buffer. config UART2_BAUD int "BAUD rate" default 115200 - help - The configured BAUD of the UART. + ---help--- + The configured BAUD of the UART. config UART2_BITS int "Character size" default 8 - help - The number of bits. Must be either 7 or 8. + ---help--- + The number of bits. Must be either 7 or 8. config UART2_PARITY int "Parity setting" default 0 - help - 0=no parity, 1=odd parity, 2=even parity + ---help--- + 0=no parity, 1=odd parity, 2=even parity config UART2_2STOP int "Uses 2 stop bits" default 0 - help - 1=Two stop bits + ---help--- + 1=Two stop bits + +config UART2_IFLOWCONTROL + bool "UART2 RTS flow control" + default n + select SERIAL_IFLOWCONTROL + ---help--- + Enable UART2 RTS flow control + +config UART2_OFLOWCONTROL + bool "UART2 CTS flow control" + default n + select SERIAL_OFLOWCONTROL + ---help--- + Enable UART2 CTS flow control endmenu @@ -710,40 +850,54 @@ menu "USART2 Configuration" config USART2_RXBUFSIZE int "Receive buffer size" default 256 - help - Characters are buffered as they are received. This specifies - the size of the receive buffer. + ---help--- + Characters are buffered as they are received. This specifies + the size of the receive buffer. config USART2_TXBUFSIZE int "Transmit buffer size" default 256 - help - Characters are buffered before being sent. This specifies - the size of the transmit buffer. + ---help--- + Characters are buffered before being sent. This specifies + the size of the transmit buffer. config USART2_BAUD int "BAUD rate" default 115200 - help - The configured BAUD of the USART. + ---help--- + The configured BAUD of the USART. config USART2_BITS int "Character size" default 8 - help - The number of bits. Must be either 7 or 8. + ---help--- + The number of bits. Must be either 7 or 8. config USART2_PARITY int "Parity setting" default 0 - help - 0=no parity, 1=odd parity, 2=even parity + ---help--- + 0=no parity, 1=odd parity, 2=even parity config USART2_2STOP int "Uses 2 stop bits" default 0 - help - 1=Two stop bits + ---help--- + 1=Two stop bits + +config USART2_IFLOWCONTROL + bool "USART2 RTS flow control" + default n + select SERIAL_IFLOWCONTROL + ---help--- + Enable USART2 RTS flow control + +config USART2_OFLOWCONTROL + bool "USART2 CTS flow control" + default n + select SERIAL_OFLOWCONTROL + ---help--- + Enable USART2 CTS flow control endmenu @@ -753,40 +907,54 @@ menu "UART3 Configuration" config UART3_RXBUFSIZE int "Receive buffer size" default 256 - help - Characters are buffered as they are received. This specifies - the size of the receive buffer. + ---help--- + Characters are buffered as they are received. This specifies + the size of the receive buffer. config UART3_TXBUFSIZE int "Transmit buffer size" default 256 - help - Characters are buffered before being sent. This specifies - the size of the transmit buffer. + ---help--- + Characters are buffered before being sent. This specifies + the size of the transmit buffer. config UART3_BAUD int "BAUD rate" default 115200 - help - The configured BAUD of the UART. + ---help--- + The configured BAUD of the UART. config UART3_BITS int "Character size" default 8 - help - The number of bits. Must be either 7 or 8. + ---help--- + The number of bits. Must be either 7 or 8. config UART3_PARITY int "Parity setting" default 0 - help - 0=no parity, 1=odd parity, 2=even parity + ---help--- + 0=no parity, 1=odd parity, 2=even parity config UART3_2STOP int "Uses 2 stop bits" default 0 - help - 1=Two stop bits + ---help--- + 1=Two stop bits + +config UART3_IFLOWCONTROL + bool "UART3 RTS flow control" + default n + select SERIAL_IFLOWCONTROL + ---help--- + Enable UART3 RTS flow control + +config UART3_OFLOWCONTROL + bool "UART3 CTS flow control" + default n + select SERIAL_OFLOWCONTROL + ---help--- + Enable UART3 CTS flow control endmenu @@ -796,40 +964,54 @@ menu "USART3 Configuration" config USART3_RXBUFSIZE int "Receive buffer size" default 256 - help - Characters are buffered as they are received. This specifies - the size of the receive buffer. + ---help--- + Characters are buffered as they are received. This specifies + the size of the receive buffer. config USART3_TXBUFSIZE int "Transmit buffer size" default 256 - help - Characters are buffered before being sent. This specifies - the size of the transmit buffer. + ---help--- + Characters are buffered before being sent. This specifies + the size of the transmit buffer. config USART3_BAUD int "BAUD rate" default 115200 - help - The configured BAUD of the USART. + ---help--- + The configured BAUD of the USART. config USART3_BITS int "Character size" default 8 - help - The number of bits. Must be either 7 or 8. + ---help--- + The number of bits. Must be either 7 or 8. config USART3_PARITY int "Parity setting" default 0 - help - 0=no parity, 1=odd parity, 2=even parity + ---help--- + 0=no parity, 1=odd parity, 2=even parity config USART3_2STOP int "Uses 2 stop bits" default 0 - help - 1=Two stop bits + ---help--- + 1=Two stop bits + +config USART3_IFLOWCONTROL + bool "USART3 RTS flow control" + default n + select SERIAL_IFLOWCONTROL + ---help--- + Enable USART3 RTS flow control + +config USART3_OFLOWCONTROL + bool "USART3 CTS flow control" + default n + select SERIAL_OFLOWCONTROL + ---help--- + Enable USART3 CTS flow control endmenu @@ -839,40 +1021,54 @@ menu "UART4 Configuration" config UART4_RXBUFSIZE int "Receive buffer size" default 256 - help - Characters are buffered as they are received. This specifies - the size of the receive buffer. + ---help--- + Characters are buffered as they are received. This specifies + the size of the receive buffer. config UART4_TXBUFSIZE int "Transmit buffer size" default 256 - help - Characters are buffered before being sent. This specifies - the size of the transmit buffer. + ---help--- + Characters are buffered before being sent. This specifies + the size of the transmit buffer. config UART4_BAUD int "BAUD rate" default 115200 - help - The configured BAUD of the UART. + ---help--- + The configured BAUD of the UART. config UART4_BITS int "Character size" default 8 - help - The number of bits. Must be either 7 or 8. + ---help--- + The number of bits. Must be either 7 or 8. config UART4_PARITY int "Parity setting" default 0 - help - 0=no parity, 1=odd parity, 2=even parity + ---help--- + 0=no parity, 1=odd parity, 2=even parity config UART4_2STOP int "Uses 2 stop bits" default 0 - help - 1=Two stop bits + ---help--- + 1=Two stop bits + +config UART4_IFLOWCONTROL + bool "UART4 RTS flow control" + default n + select SERIAL_IFLOWCONTROL + ---help--- + Enable UART4 RTS flow control + +config UART4_OFLOWCONTROL + bool "UART4 CTS flow control" + default n + select SERIAL_OFLOWCONTROL + ---help--- + Enable UART4 CTS flow control endmenu @@ -882,40 +1078,54 @@ menu "USART4 Configuration" config USART4_RXBUFSIZE int "Receive buffer size" default 256 - help - Characters are buffered as they are received. This specifies - the size of the receive buffer. + ---help--- + Characters are buffered as they are received. This specifies + the size of the receive buffer. config USART4_TXBUFSIZE int "Transmit buffer size" default 256 - help - Characters are buffered before being sent. This specifies - the size of the transmit buffer. + ---help--- + Characters are buffered before being sent. This specifies + the size of the transmit buffer. config USART4_BAUD int "BAUD rate" default 115200 - help - The configured BAUD of the USART. + ---help--- + The configured BAUD of the USART. config USART4_BITS int "Character size" default 8 - help - The number of bits. Must be either 7 or 8. + ---help--- + The number of bits. Must be either 7 or 8. config USART4_PARITY int "Parity setting" default 0 - help - 0=no parity, 1=odd parity, 2=even parity + ---help--- + 0=no parity, 1=odd parity, 2=even parity config USART4_2STOP int "Uses 2 stop bits" default 0 - help - 1=Two stop bits + ---help--- + 1=Two stop bits + +config USART4_IFLOWCONTROL + bool "USART4 RTS flow control" + default n + select SERIAL_IFLOWCONTROL + ---help--- + Enable USART4 RTS flow control + +config USART4_OFLOWCONTROL + bool "USART4 CTS flow control" + default n + select SERIAL_OFLOWCONTROL + ---help--- + Enable USART4 CTS flow control endmenu @@ -925,40 +1135,54 @@ menu "UART5 Configuration" config UART5_RXBUFSIZE int "Receive buffer size" default 256 - help - Characters are buffered as they are received. This specifies - the size of the receive buffer. + ---help--- + Characters are buffered as they are received. This specifies + the size of the receive buffer. config UART5_TXBUFSIZE int "Transmit buffer size" default 256 - help - Characters are buffered before being sent. This specifies - the size of the transmit buffer. + ---help--- + Characters are buffered before being sent. This specifies + the size of the transmit buffer. config UART5_BAUD int "BAUD rate" default 115200 - help - The configured BAUD of the UART. + ---help--- + The configured BAUD of the UART. config UART5_BITS int "Character size" default 8 - help - The number of bits. Must be either 7 or 8. + ---help--- + The number of bits. Must be either 7 or 8. config UART5_PARITY int "Parity setting" default 0 - help - 0=no parity, 1=odd parity, 2=even parity + ---help--- + 0=no parity, 1=odd parity, 2=even parity config UART5_2STOP int "Uses 2 stop bits" default 0 - help - 1=Two stop bits + ---help--- + 1=Two stop bits + +config UART5_IFLOWCONTROL + bool "UART5 RTS flow control" + default n + select SERIAL_IFLOWCONTROL + ---help--- + Enable UART5 RTS flow control + +config UART5_OFLOWCONTROL + bool "UART5 CTS flow control" + default n + select SERIAL_OFLOWCONTROL + ---help--- + Enable UART5 CTS flow control endmenu @@ -968,40 +1192,54 @@ menu "USART5 Configuration" config USART5_RXBUFSIZE int "Receive buffer size" default 256 - help - Characters are buffered as they are received. This specifies - the size of the receive buffer. + ---help--- + Characters are buffered as they are received. This specifies + the size of the receive buffer. config USART5_TXBUFSIZE int "Transmit buffer size" default 256 - help - Characters are buffered before being sent. This specifies - the size of the transmit buffer. + ---help--- + Characters are buffered before being sent. This specifies + the size of the transmit buffer. config USART5_BAUD int "BAUD rate" default 115200 - help - The configured BAUD of the USART. + ---help--- + The configured BAUD of the USART. config USART5_BITS int "Character size" default 8 - help - The number of bits. Must be either 7 or 8. + ---help--- + The number of bits. Must be either 7 or 8. config USART5_PARITY int "Parity setting" default 0 - help - 0=no parity, 1=odd parity, 2=even parity + ---help--- + 0=no parity, 1=odd parity, 2=even parity config USART5_2STOP int "Uses 2 stop bits" default 0 - help - 1=Two stop bits + ---help--- + 1=Two stop bits + +config USART5_IFLOWCONTROL + bool "USART5 RTS flow control" + default n + select SERIAL_IFLOWCONTROL + ---help--- + Enable USART5 RTS flow control + +config USART5_OFLOWCONTROL + bool "USART5 CTS flow control" + default n + select SERIAL_OFLOWCONTROL + ---help--- + Enable USART5 CTS flow control endmenu @@ -1011,40 +1249,54 @@ menu "USART6 Configuration" config USART6_RXBUFSIZE int "Receive buffer size" default 256 - help - Characters are buffered as they are received. This specifies - the size of the receive buffer. + ---help--- + Characters are buffered as they are received. This specifies + the size of the receive buffer. config USART6_TXBUFSIZE int "Transmit buffer size" default 256 - help - Characters are buffered before being sent. This specifies - the size of the transmit buffer. + ---help--- + Characters are buffered before being sent. This specifies + the size of the transmit buffer. config USART6_BAUD int "BAUD rate" default 115200 - help - The configured BAUD of the USART. + ---help--- + The configured BAUD of the USART. config USART6_BITS int "Character size" default 8 - help - The number of bits. Must be either 7 or 8. + ---help--- + The number of bits. Must be either 7 or 8. config USART6_PARITY int "Parity setting" default 0 - help - 0=no parity, 1=odd parity, 2=even parity + ---help--- + 0=no parity, 1=odd parity, 2=even parity config USART6_2STOP int "Uses 2 stop bits" default 0 - help - 1=Two stop bits + ---help--- + 1=Two stop bits + +config USART6_IFLOWCONTROL + bool "UART6 RTS flow control" + default n + select SERIAL_IFLOWCONTROL + ---help--- + Enable USART6 RTS flow control + +config USART6_OFLOWCONTROL + bool "USART6 CTS flow control" + default n + select SERIAL_OFLOWCONTROL + ---help--- + Enable USART6 CTS flow control endmenu @@ -1054,40 +1306,54 @@ menu "UART6 Configuration" config UART6_RXBUFSIZE int "Receive buffer size" default 256 - help - Characters are buffered as they are received. This specifies - the size of the receive buffer. + ---help--- + Characters are buffered as they are received. This specifies + the size of the receive buffer. config UART6_TXBUFSIZE int "Transmit buffer size" default 256 - help - Characters are buffered before being sent. This specifies - the size of the transmit buffer. + ---help--- + Characters are buffered before being sent. This specifies + the size of the transmit buffer. config UART6_BAUD int "BAUD rate" default 115200 - help - The configured BAUD of the UART. + ---help--- + The configured BAUD of the UART. config UART6_BITS int "Character size" default 8 - help - The number of bits. Must be either 7 or 8. + ---help--- + The number of bits. Must be either 7 or 8. config UART6_PARITY int "Parity setting" default 0 - help - 0=no parity, 1=odd parity, 2=even parity + ---help--- + 0=no parity, 1=odd parity, 2=even parity config UART6_2STOP int "Uses 2 stop bits" default 0 - help - 1=Two stop bits + ---help--- + 1=Two stop bits + +config UART6_IFLOWCONTROL + bool "UART6 RTS flow control" + default n + select SERIAL_IFLOWCONTROL + ---help--- + Enable UART6 RTS flow control + +config UART6_OFLOWCONTROL + bool "UART6 CTS flow control" + default n + select SERIAL_OFLOWCONTROL + ---help--- + Enable UART6 CTS flow control endmenu @@ -1097,40 +1363,54 @@ menu "USART7 Configuration" config USART7_RXBUFSIZE int "Receive buffer size" default 256 - help - Characters are buffered as they are received. This specifies - the size of the receive buffer. + ---help--- + Characters are buffered as they are received. This specifies + the size of the receive buffer. config USART7_TXBUFSIZE int "Transmit buffer size" default 256 - help - Characters are buffered before being sent. This specifies - the size of the transmit buffer. + ---help--- + Characters are buffered before being sent. This specifies + the size of the transmit buffer. config USART7_BAUD int "BAUD rate" default 115200 - help - The configured BAUD of the USART. + ---help--- + The configured BAUD of the USART. config USART7_BITS int "Character size" default 8 - help - The number of bits. Must be either 7 or 8. + ---help--- + The number of bits. Must be either 7 or 8. config USART7_PARITY int "Parity setting" default 0 - help - 0=no parity, 1=odd parity, 2=even parity + ---help--- + 0=no parity, 1=odd parity, 2=even parity config USART7_2STOP int "Uses 2 stop bits" default 0 - help - 1=Two stop bits + ---help--- + 1=Two stop bits + +config USART7_IFLOWCONTROL + bool "USART7 RTS flow control" + default n + select SERIAL_IFLOWCONTROL + ---help--- + Enable USART7 RTS flow control + +config USART7_OFLOWCONTROL + bool "USART7 CTS flow control" + default n + select SERIAL_OFLOWCONTROL + ---help--- + Enable USART7 CTS flow control endmenu @@ -1140,40 +1420,54 @@ menu "UART7 Configuration" config UART7_RXBUFSIZE int "Receive buffer size" default 256 - help - Characters are buffered as they are received. This specifies - the size of the receive buffer. + ---help--- + Characters are buffered as they are received. This specifies + the size of the receive buffer. config UART7_TXBUFSIZE int "Transmit buffer size" default 256 - help - Characters are buffered before being sent. This specifies - the size of the transmit buffer. + ---help--- + Characters are buffered before being sent. This specifies + the size of the transmit buffer. config UART7_BAUD int "BAUD rate" default 115200 - help - The configured BAUD of the UART. + ---help--- + The configured BAUD of the UART. config UART7_BITS int "Character size" default 8 - help - The number of bits. Must be either 7 or 8. + ---help--- + The number of bits. Must be either 7 or 8. config UART7_PARITY int "Parity setting" default 0 - help - 0=no parity, 1=odd parity, 2=even parity + ---help--- + 0=no parity, 1=odd parity, 2=even parity config UART7_2STOP int "Uses 2 stop bits" default 0 - help - 1=Two stop bits + ---help--- + 1=Two stop bits + +config UART7_IFLOWCONTROL + bool "UART7 RTS flow control" + default n + select SERIAL_IFLOWCONTROL + ---help--- + Enable UART7 RTS flow control + +config UART7_OFLOWCONTROL + bool "UART7 CTS flow control" + default n + select SERIAL_OFLOWCONTROL + ---help--- + Enable UART7 CTS flow control endmenu @@ -1183,40 +1477,54 @@ menu "USART8 Configuration" config USART8_RXBUFSIZE int "Receive buffer size" default 256 - help - Characters are buffered as they are received. This specifies - the size of the receive buffer. + ---help--- + Characters are buffered as they are received. This specifies + the size of the receive buffer. config USART8_TXBUFSIZE int "Transmit buffer size" default 256 - help - Characters are buffered before being sent. This specifies - the size of the transmit buffer. + ---help--- + Characters are buffered before being sent. This specifies + the size of the transmit buffer. config USART8_BAUD int "BAUD rate" default 115200 - help - The configured BAUD of the USART. + ---help--- + The configured BAUD of the USART. config USART8_BITS int "Character size" default 8 - help - The number of bits. Must be either 7 or 8. + ---help--- + The number of bits. Must be either 7 or 8. config USART8_PARITY int "Parity setting" default 0 - help - 0=no parity, 1=odd parity, 2=even parity + ---help--- + 0=no parity, 1=odd parity, 2=even parity config USART8_2STOP int "Uses 2 stop bits" default 0 - help - 1=Two stop bits + ---help--- + 1=Two stop bits + +config USART8_IFLOWCONTROL + bool "USART8 RTS flow control" + default n + select SERIAL_IFLOWCONTROL + ---help--- + Enable USART8 RTS flow control + +config USART8_OFLOWCONTROL + bool "USART8 CTS flow control" + default n + select SERIAL_OFLOWCONTROL + ---help--- + Enable USART8 CTS flow control endmenu @@ -1226,39 +1534,62 @@ menu "UART8 Configuration" config UART8_RXBUFSIZE int "Receive buffer size" default 256 - help - Characters are buffered as they are received. This specifies - the size of the receive buffer. + ---help--- + Characters are buffered as they are received. This specifies + the size of the receive buffer. config UART8_TXBUFSIZE int "Transmit buffer size" default 256 - help - Characters are buffered before being sent. This specifies - the size of the transmit buffer. + ---help--- + Characters are buffered before being sent. This specifies + the size of the transmit buffer. config UART8_BAUD int "BAUD rate" default 115200 - help - The configured BAUD of the UART. + ---help--- + The configured BAUD of the UART. config UART8_BITS int "Character size" default 8 - help - The number of bits. Must be either 7 or 8. + ---help--- + The number of bits. Must be either 7 or 8. config UART8_PARITY int "Parity setting" default 0 - help - 0=no parity, 1=odd parity, 2=even parity + ---help--- + 0=no parity, 1=odd parity, 2=even parity config UART8_2STOP int "Uses 2 stop bits" default 0 - help - 1=Two stop bits + ---help--- + 1=Two stop bits + +config UART8_IFLOWCONTROL + bool "UART8 RTS flow control" + default n + select SERIAL_IFLOWCONTROL + ---help--- + Enable UART8 RTS flow control + +config UART8_OFLOWCONTROL + bool "UART8 CTS flow control" + default n + select SERIAL_OFLOWCONTROL + ---help--- + Enable UART8 CTS flow control endmenu + +config SERIAL_IFLOWCONTROL + bool + default n + +config SERIAL_OFLOWCONTROL + bool + default n + diff --git a/include/nuttx/serial/serial.h b/include/nuttx/serial/serial.h index 57bcf1f272..3c1de2225e 100644 --- a/include/nuttx/serial/serial.h +++ b/include/nuttx/serial/serial.h @@ -278,7 +278,7 @@ void uart_recvchars(FAR uart_dev_t *dev); * Name: uart_datareceived * * Description: - * This function is called from uart_recvchars when new serial data is place in + * This function is called from uart_recvchars when new serial data is place in * the driver's circular buffer. This function will wake-up any stalled read() * operations that are waiting for incoming data. * diff --git a/include/termios.h b/include/termios.h index 2e1c38fc26..95b20a3d36 100644 --- a/include/termios.h +++ b/include/termios.h @@ -109,6 +109,9 @@ #define PARODD (1 << 5) /* Bit 5: Odd parity, else even */ #define HUPCL (1 << 6) /* Bit 6: Hang up on last close */ #define CLOCAL (1 << 7) /* Bit 7: Ignore modem status lines */ +#define CCTS_OFLOW (1 << 8) /* Bit 8: CTS flow control of output */ +#define CRTSCTS CCTS_OFLOW +#define CRTS_IFLOW (1 << 9) /* Bit 9: RTS flow control of input */ /* Local Modes (c_lflag in the termios structure) */