From ad447766ff261f69cbc893f9ccdc5fdaaaf719ce Mon Sep 17 00:00:00 2001 From: patacongo Date: Sun, 10 Feb 2013 00:46:27 +0000 Subject: [PATCH] Fix a readline bug. If a NUL is received, it would return end-of-file git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5633 42af7a65-404d-4744-a932-0658087f49c3 --- ChangeLog | 2 ++ arch/arm/src/stm32/stm32_serial.c | 2 ++ configs/stm32f3discovery/nsh/defconfig | 19 +++++++------------ drivers/serial/serial.c | 8 +++++--- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index c1766a609d..79e2723cec 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4175,3 +4175,5 @@ example "+-" would look weird. From Petteri Aimonen. * mm/mm_mallinfo.c: Take MM semaphore in mm_mallinfo. From Petteri Aimonen. + * configs/stm32f3discovery/nsh/defconfig: Disable SPI. It is nto + used. diff --git a/arch/arm/src/stm32/stm32_serial.c b/arch/arm/src/stm32/stm32_serial.c index 18e65f1d9a..327e515b5f 100644 --- a/arch/arm/src/stm32/stm32_serial.c +++ b/arch/arm/src/stm32/stm32_serial.c @@ -981,6 +981,8 @@ static void up_setspeed(struct uart_dev_s *dev) } else { + DEBUGASSERT(usartdiv8 >= 8); + /* Perform mysterious operations on bits 0-3 */ brr = ((usartdiv8 & 0xfff0) | ((usartdiv8 & 0x000f) >> 1)); diff --git a/configs/stm32f3discovery/nsh/defconfig b/configs/stm32f3discovery/nsh/defconfig index 4b81a70ad6..1913ab95cc 100644 --- a/configs/stm32f3discovery/nsh/defconfig +++ b/configs/stm32f3discovery/nsh/defconfig @@ -166,7 +166,7 @@ CONFIG_STM32_STM32F30XX=y # CONFIG_STM32_IWDG is not set CONFIG_STM32_PWR=y # CONFIG_STM32_SDIO is not set -CONFIG_STM32_SPI1=y +# CONFIG_STM32_SPI1 is not set # CONFIG_STM32_SPI2 is not set CONFIG_STM32_SYSCFG=y # CONFIG_STM32_TIM1 is not set @@ -184,7 +184,6 @@ CONFIG_STM32_SYSCFG=y CONFIG_STM32_USART2=y CONFIG_STM32_USB=y # CONFIG_STM32_WWDG is not set -CONFIG_STM32_SPI=y # # Alternate Pin Mapping @@ -203,16 +202,15 @@ CONFIG_STM32_USART=y # CONFIG_USART2_RS485 is not set # CONFIG_STM32_USART_SINGLEWIRE is not set -# -# SPI Configuration -# -# CONFIG_STM32_SPI_INTERRUPTS is not set -# CONFIG_STM32_SPI_DMA is not set - # # USB Host Configuration # +# +# USB Device Configuration +# +# CONFIG_STM32_USB_ITRMP is not set + # # External Memory Configuration # @@ -345,10 +343,7 @@ CONFIG_DEV_NULL=y # CONFIG_PWM is not set # CONFIG_I2C is not set CONFIG_ARCH_HAVE_I2CRESET=y -CONFIG_SPI=y -# CONFIG_SPI_OWNBUS is not set -CONFIG_SPI_EXCHANGE=y -# CONFIG_SPI_CMDDATA is not set +# CONFIG_SPI is not set # CONFIG_RTC is not set # CONFIG_WATCHDOG is not set # CONFIG_ANALOG is not set diff --git a/drivers/serial/serial.c b/drivers/serial/serial.c index aaec712024..e723fb336e 100644 --- a/drivers/serial/serial.c +++ b/drivers/serial/serial.c @@ -528,7 +528,7 @@ static ssize_t uart_read(FAR struct file *filep, FAR char *buffer, size_t buflen * return what we have. */ - else if (filep->f_oflags & O_NONBLOCK) + else if ((filep->f_oflags & O_NONBLOCK) != 0) { /* If nothing was transferred, then return the -EAGAIN * error (not zero which means end of file). @@ -560,7 +560,7 @@ static ssize_t uart_read(FAR struct file *filep, FAR char *buffer, size_t buflen * wait. */ - else if (filep->f_oflags & O_NONBLOCK) + else if ((filep->f_oflags & O_NONBLOCK) != 0) { /* Break out of the loop returning -EAGAIN */ @@ -1109,7 +1109,9 @@ void uart_connected(FAR uart_dev_t *dev, bool connected) { irqstate_t flags; - /* Is the device disconnected? */ + /* Is the device disconnected? Interrupts are disabled because this + * function may be called from interrupt handling logic. + */ flags = irqsave(); dev->disconnected = !connected;