LPC17xx serial now supports minimal termios ioctls; serial driver ioctl methods should not set errno variable
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4994 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
113b421e60
commit
50dd2866eb
@ -3091,4 +3091,9 @@
|
||||
IOPORT register.
|
||||
* lib/string/lib_memchr.c: Add support for memchr() (contributed by Mike Smith)
|
||||
* lib/string/lib_memccpy.c: Add support for memcpy()
|
||||
* arch/arm/src/lpc17xx/lpc17_serial.c: Now supports ioctl commands to change
|
||||
the baud using tcsetattr() (contributed by Chris Taglia).
|
||||
* arch/*/src/*_serial.c: Fix ioctl method return values. Theses methods
|
||||
should return a negated errno value; they should not set the errno
|
||||
variable.
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
/****************************************************************************
|
||||
* c5471/c5471_serial.c
|
||||
*
|
||||
* Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
* Copyright (C) 2007-2009, 2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@ -625,8 +625,7 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg)
|
||||
struct up_dev_s *user = (struct up_dev_s*)arg;
|
||||
if (!user)
|
||||
{
|
||||
*get_errno_ptr() = EINVAL;
|
||||
ret = ERROR;
|
||||
ret = -EINVAL;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -653,8 +652,7 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg)
|
||||
break;
|
||||
|
||||
default:
|
||||
*get_errno_ptr() = ENOTTY;
|
||||
ret = ERROR;
|
||||
ret = -ENOTTY;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
/**************************************************************************
|
||||
* c5471/c5471_watchdog.c
|
||||
*
|
||||
* Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
* Copyright (C) 2007, 2009, 2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@ -302,8 +302,7 @@ static int wdt_ioctl(FAR struct file *filp, int cmd, unsigned long arg)
|
||||
break;
|
||||
|
||||
default:
|
||||
*get_errno_ptr() = ENOTTY;
|
||||
return ERROR;
|
||||
return -ENOTTY;
|
||||
}
|
||||
|
||||
return OK;
|
||||
@ -319,7 +318,7 @@ static int wdt_open(struct file *filep)
|
||||
|
||||
if (g_wdtopen)
|
||||
{
|
||||
*get_errno_ptr() = EBUSY;
|
||||
return -EBUSY;
|
||||
}
|
||||
|
||||
/* This will automatically load the timer with its max
|
||||
|
@ -712,8 +712,7 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg)
|
||||
struct up_dev_s *user = (struct up_dev_s*)arg;
|
||||
if (!user)
|
||||
{
|
||||
*get_errno_ptr() = EINVAL;
|
||||
ret = ERROR;
|
||||
ret = -EINVAL;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -740,8 +739,7 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg)
|
||||
break;
|
||||
|
||||
default:
|
||||
*get_errno_ptr() = ENOTTY;
|
||||
ret = ERROR;
|
||||
ret = -ENOTTY;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -765,8 +765,7 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg)
|
||||
struct up_dev_s *user = (struct up_dev_s*)arg;
|
||||
if (!user)
|
||||
{
|
||||
*get_errno_ptr() = EINVAL;
|
||||
ret = ERROR;
|
||||
ret = -EINVAL;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -776,8 +775,7 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg)
|
||||
break;
|
||||
|
||||
default:
|
||||
*get_errno_ptr() = ENOTTY;
|
||||
ret = ERROR;
|
||||
ret = -ENOTTY;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -47,6 +47,9 @@
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
#ifdef CONFIG_SERIAL_TERMIOS
|
||||
# include <termios.h>
|
||||
#endif
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/arch.h>
|
||||
@ -136,14 +139,17 @@ struct uart_ops_s g_uart_ops =
|
||||
static char g_uart0rxbuffer[CONFIG_UART0_RXBUFSIZE];
|
||||
static char g_uart0txbuffer[CONFIG_UART0_TXBUFSIZE];
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_LPC17_UART1
|
||||
static char g_uart1rxbuffer[CONFIG_UART1_RXBUFSIZE];
|
||||
static char g_uart1txbuffer[CONFIG_UART1_TXBUFSIZE];
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_LPC17_UART2
|
||||
static char g_uart2rxbuffer[CONFIG_UART2_RXBUFSIZE];
|
||||
static char g_uart2txbuffer[CONFIG_UART2_TXBUFSIZE];
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_LPC17_UART3
|
||||
static char g_uart3rxbuffer[CONFIG_UART3_RXBUFSIZE];
|
||||
static char g_uart3txbuffer[CONFIG_UART3_TXBUFSIZE];
|
||||
@ -273,16 +279,16 @@ static uart_dev_t g_uart3port =
|
||||
|
||||
#ifdef HAVE_CONSOLE
|
||||
# if defined(CONFIG_UART0_SERIAL_CONSOLE)
|
||||
# define CONSOLE_DEV g_uart0port /* UART0=console */
|
||||
# define TTYS0_DEV g_uart0port /* UART0=ttyS0 */
|
||||
# define CONSOLE_DEV g_uart0port /* UART0=console */
|
||||
# define TTYS0_DEV g_uart0port /* UART0=ttyS0 */
|
||||
# ifdef CONFIG_LPC17_UART1
|
||||
# define TTYS1_DEV g_uart1port /* UART0=ttyS0;UART1=ttyS1 */
|
||||
# define TTYS1_DEV g_uart1port /* UART0=ttyS0;UART1=ttyS1 */
|
||||
# ifdef CONFIG_LPC17_UART2
|
||||
# define TTYS2_DEV g_uart2port /* UART0=ttyS0;UART1=ttyS1;UART2=ttyS2 */
|
||||
# define TTYS2_DEV g_uart2port /* UART0=ttyS0;UART1=ttyS1;UART2=ttyS2 */
|
||||
# ifdef CONFIG_LPC17_UART3
|
||||
# define TTYS3_DEV g_uart3port /* UART0=ttyS0;UART1=ttyS1;UART2=ttyS2;UART3=ttyS3 */
|
||||
# define TTYS3_DEV g_uart3port /* UART0=ttyS0;UART1=ttyS1;UART2=ttyS2;UART3=ttyS3 */
|
||||
# else
|
||||
# undef TTYS3_DEV /* UART0=ttyS0;UART1=ttyS1;UART2=ttyS;No ttyS3 */
|
||||
# undef TTYS3_DEV /* UART0=ttyS0;UART1=ttyS1;UART2=ttyS;No ttyS3 */
|
||||
# endif
|
||||
# else
|
||||
# ifdef CONFIG_LPC17_UART3
|
||||
@ -294,18 +300,18 @@ static uart_dev_t g_uart3port =
|
||||
# endif
|
||||
# else
|
||||
# ifdef CONFIG_LPC17_UART2
|
||||
# define TTYS1_DEV g_uart2port /* UART0=ttyS0;UART2=ttyS1;No ttyS3 */
|
||||
# define TTYS1_DEV g_uart2port /* UART0=ttyS0;UART2=ttyS1;No ttyS3 */
|
||||
# ifdef CONFIG_LPC17_UART3
|
||||
# define TTYS2_DEV g_uart3port /* UART0=ttyS0;UART2=ttyS1;UART3=ttyS2;No ttyS3 */
|
||||
# define TTYS2_DEV g_uart3port /* UART0=ttyS0;UART2=ttyS1;UART3=ttyS2;No ttyS3 */
|
||||
# else
|
||||
# undef TTYS2_DEV /* UART0=ttyS0;UART2=ttyS1;No ttyS2;No ttyS3 */
|
||||
# undef TTYS2_DEV /* UART0=ttyS0;UART2=ttyS1;No ttyS2;No ttyS3 */
|
||||
# endif
|
||||
# undef TTYS3_DEV /* No ttyS3 */
|
||||
# undef TTYS3_DEV /* No ttyS3 */
|
||||
# else
|
||||
# ifdef CONFIG_LPC17_UART3
|
||||
# define TTYS1_DEV g_uart3port /* UART0=ttyS0;UART3=ttyS1;No ttyS2;No ttyS3 */
|
||||
# define TTYS1_DEV g_uart3port /* UART0=ttyS0;UART3=ttyS1;No ttyS2;No ttyS3 */
|
||||
# else
|
||||
# undef TTYS1_DEV /* UART0=ttyS0;No ttyS1;No ttyS2;No ttyS3 */
|
||||
# undef TTYS1_DEV /* UART0=ttyS0;No ttyS1;No ttyS2;No ttyS3 */
|
||||
# endif
|
||||
# undef TTYS2_DEV /* No ttyS2 */
|
||||
# undef TTYS3_DEV /* No ttyS3 */
|
||||
@ -372,100 +378,100 @@ static uart_dev_t g_uart3port =
|
||||
# endif
|
||||
# else
|
||||
# ifdef CONFIG_LPC17_UART1
|
||||
# define TTYS1_DEV g_uart1port /* UART2=ttyS0;UART1=ttyS1 */
|
||||
# define TTYS1_DEV g_uart1port /* UART2=ttyS0;UART1=ttyS1 */
|
||||
# ifdef CONFIG_LPC17_UART3
|
||||
# define TTYS2_DEV g_uart3port /* UART2=ttyS0;UART1=ttyS1;UART3=ttyS2 */
|
||||
# define TTYS2_DEV g_uart3port /* UART2=ttyS0;UART1=ttyS1;UART3=ttyS2 */
|
||||
# else
|
||||
# undef TTYS2_DEV /* UART2=ttyS0;UART1=ttyS1;No ttyS2;No ttyS3 */
|
||||
# undef TTYS2_DEV /* UART2=ttyS0;UART1=ttyS1;No ttyS2;No ttyS3 */
|
||||
# endif
|
||||
# undef TTYS3_DEV /* No ttyS3 */
|
||||
# undef TTYS3_DEV /* No ttyS3 */
|
||||
# else
|
||||
# ifdef CONFIG_LPC17_UART3
|
||||
# define TTYS1_DEV g_uart3port /* UART2=ttyS0;UART3=ttyS1;No ttyS3 */
|
||||
# define TTYS1_DEV g_uart3port /* UART2=ttyS0;UART3=ttyS1;No ttyS3 */
|
||||
# else
|
||||
# undef TTYS1_DEV /* UART2=ttyS0;No ttyS1;No ttyS2;No ttyS3 */
|
||||
# undef TTYS1_DEV /* UART2=ttyS0;No ttyS1;No ttyS2;No ttyS3 */
|
||||
# endif
|
||||
# undef TTYS2_DEV /* No ttyS2 */
|
||||
# undef TTYS3_DEV /* No ttyS3 */
|
||||
# undef TTYS2_DEV /* No ttyS2 */
|
||||
# undef TTYS3_DEV /* No ttyS3 */
|
||||
# endif
|
||||
# endif
|
||||
# elif defined(CONFIG_UART3_SERIAL_CONSOLE)
|
||||
# define CONSOLE_DEV g_uart3port /* UART3=console */
|
||||
# define TTYS0_DEV g_uart3port /* UART3=ttyS0 */
|
||||
# define CONSOLE_DEV g_uart3port /* UART3=console */
|
||||
# define TTYS0_DEV g_uart3port /* UART3=ttyS0 */
|
||||
# ifdef CONFIG_LPC17_UART0
|
||||
# define TTYS1_DEV g_uart0port /* UART3=ttyS0;UART0=ttyS1 */
|
||||
# define TTYS1_DEV g_uart0port /* UART3=ttyS0;UART0=ttyS1 */
|
||||
# ifdef CONFIG_LPC17_UART1
|
||||
# define TTYS2_DEV g_uart1port /* UART3=ttyS0;UART0=ttyS1;UART1=ttyS2 */
|
||||
# define TTYS2_DEV g_uart1port /* UART3=ttyS0;UART0=ttyS1;UART1=ttyS2 */
|
||||
# ifdef CONFIG_LPC17_UART2
|
||||
# define TTYS3_DEV g_uart2port /* UART3=ttyS0;UART0=ttyS1;UART1=ttyS2;UART2=ttyS3 */
|
||||
# define TTYS3_DEV g_uart2port /* UART3=ttyS0;UART0=ttyS1;UART1=ttyS2;UART2=ttyS3 */
|
||||
# else
|
||||
# undef TTYS3_DEV /* UART3=ttyS0;UART0=ttyS1;UART1=ttyS;No ttyS3 */
|
||||
# undef TTYS3_DEV /* UART3=ttyS0;UART0=ttyS1;UART1=ttyS;No ttyS3 */
|
||||
# endif
|
||||
# else
|
||||
# ifdef CONFIG_LPC17_UART2
|
||||
# define TTYS2_DEV g_uart2port /* UART3=ttyS0;UART0=ttyS1;UART2=ttys2;No ttyS3 */
|
||||
# define TTYS2_DEV g_uart2port /* UART3=ttyS0;UART0=ttyS1;UART2=ttys2;No ttyS3 */
|
||||
# else
|
||||
# undef TTYS2_DEV /* UART3=ttyS0;UART0=ttyS1;No ttyS2;No ttyS3 */
|
||||
# undef TTYS2_DEV /* UART3=ttyS0;UART0=ttyS1;No ttyS2;No ttyS3 */
|
||||
# endif
|
||||
# undef TTYS3_DEV /* No ttyS3 */
|
||||
# undef TTYS3_DEV /* No ttyS3 */
|
||||
# endif
|
||||
# else
|
||||
# ifdef CONFIG_LPC17_UART1
|
||||
# define TTYS1_DEV g_uart1port /* UART3=ttyS0;UART1=ttyS1 */
|
||||
# define TTYS1_DEV g_uart1port /* UART3=ttyS0;UART1=ttyS1 */
|
||||
# ifdef CONFIG_LPC17_UART2
|
||||
# define TTYS2_DEV g_uart2port /* UART3=ttyS0;UART1=ttyS1;UART2=ttyS2;No ttyS3 */
|
||||
# define TTYS2_DEV g_uart2port /* UART3=ttyS0;UART1=ttyS1;UART2=ttyS2;No ttyS3 */
|
||||
# else
|
||||
# undef TTYS2_DEV /* UART3=ttyS0;UART1=ttyS1;No ttyS2;No ttyS3 */
|
||||
# undef TTYS2_DEV /* UART3=ttyS0;UART1=ttyS1;No ttyS2;No ttyS3 */
|
||||
# endif
|
||||
# undef TTYS3_DEV /* No ttyS3 */
|
||||
# undef TTYS3_DEV /* No ttyS3 */
|
||||
# else
|
||||
# ifdef CONFIG_LPC17_UART2
|
||||
# define TTYS1_DEV g_uart2port /* UART3=ttyS0;UART2=ttyS1;No ttyS3;No ttyS3 */
|
||||
# undef TTYS3_DEV /* UART3=ttyS0;UART2=ttyS1;No ttyS2;No ttyS3 */
|
||||
# define TTYS1_DEV g_uart2port /* UART3=ttyS0;UART2=ttyS1;No ttyS3;No ttyS3 */
|
||||
# undef TTYS3_DEV /* UART3=ttyS0;UART2=ttyS1;No ttyS2;No ttyS3 */
|
||||
# else
|
||||
# undef TTYS1_DEV /* UART3=ttyS0;No ttyS1;No ttyS2;No ttyS3 */
|
||||
# undef TTYS1_DEV /* UART3=ttyS0;No ttyS1;No ttyS2;No ttyS3 */
|
||||
# endif
|
||||
# undef TTYS2_DEV /* No ttyS2 */
|
||||
# undef TTYS3_DEV /* No ttyS3 */
|
||||
# undef TTYS2_DEV /* No ttyS2 */
|
||||
# undef TTYS3_DEV /* No ttyS3 */
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
#else /* No console */
|
||||
# define TTYS0_DEV g_uart0port /* UART0=ttyS0 */
|
||||
# define TTYS0_DEV g_uart0port /* UART0=ttyS0 */
|
||||
# ifdef CONFIG_LPC17_UART1
|
||||
# define TTYS1_DEV g_uart1port /* UART0=ttyS0;UART1=ttyS1 */
|
||||
# define TTYS1_DEV g_uart1port /* UART0=ttyS0;UART1=ttyS1 */
|
||||
# ifdef CONFIG_LPC17_UART2
|
||||
# define TTYS2_DEV g_uart2port /* UART0=ttyS0;UART1=ttyS1;UART2=ttyS2 */
|
||||
# define TTYS2_DEV g_uart2port /* UART0=ttyS0;UART1=ttyS1;UART2=ttyS2 */
|
||||
# ifdef CONFIG_LPC17_UART3
|
||||
# define TTYS3_DEV g_uart3port /* UART0=ttyS0;UART1=ttyS1;UART2=ttyS2;UART3=ttyS3 */
|
||||
# define TTYS3_DEV g_uart3port /* UART0=ttyS0;UART1=ttyS1;UART2=ttyS2;UART3=ttyS3 */
|
||||
# else
|
||||
# undef TTYS3_DEV /* UART0=ttyS0;UART1=ttyS1;UART2=ttyS;No ttyS3 */
|
||||
# undef TTYS3_DEV /* UART0=ttyS0;UART1=ttyS1;UART2=ttyS;No ttyS3 */
|
||||
# endif
|
||||
# else
|
||||
# ifdef CONFIG_LPC17_UART3
|
||||
# define TTYS2_DEV g_uart3port /* UART0=ttyS0;UART1=ttyS1;UART3=ttys2;No ttyS3 */
|
||||
# define TTYS2_DEV g_uart3port /* UART0=ttyS0;UART1=ttyS1;UART3=ttys2;No ttyS3 */
|
||||
# else
|
||||
# undef TTYS2_DEV /* UART0=ttyS0;UART1=ttyS1;No ttyS2;No ttyS3 */
|
||||
# undef TTYS2_DEV /* UART0=ttyS0;UART1=ttyS1;No ttyS2;No ttyS3 */
|
||||
# endif
|
||||
# undef TTYS3_DEV /* No ttyS3 */
|
||||
# undef TTYS3_DEV /* No ttyS3 */
|
||||
# endif
|
||||
# else
|
||||
# ifdef CONFIG_LPC17_UART2
|
||||
# define TTYS1_DEV g_uart2port /* UART0=ttyS0;UART2=ttyS1;No ttyS3 */
|
||||
# define TTYS1_DEV g_uart2port /* UART0=ttyS0;UART2=ttyS1;No ttyS3 */
|
||||
# ifdef CONFIG_LPC17_UART3
|
||||
# define TTYS2_DEV g_uart3port /* UART0=ttyS0;UART2=ttyS1;UART3=ttyS2;No ttyS3 */
|
||||
# define TTYS2_DEV g_uart3port /* UART0=ttyS0;UART2=ttyS1;UART3=ttyS2;No ttyS3 */
|
||||
# else
|
||||
# undef TTYS2_DEV /* UART0=ttyS0;UART2=ttyS1;No ttyS2;No ttyS3 */
|
||||
# undef TTYS2_DEV /* UART0=ttyS0;UART2=ttyS1;No ttyS2;No ttyS3 */
|
||||
# endif
|
||||
# undef TTYS3_DEV /* No ttyS3 */
|
||||
# undef TTYS3_DEV /* No ttyS3 */
|
||||
# else
|
||||
# ifdef CONFIG_LPC17_UART3
|
||||
# define TTYS1_DEV g_uart3port /* UART0=ttyS0;UART3=ttyS1;No ttyS2;No ttyS3 */
|
||||
# define TTYS1_DEV g_uart3port /* UART0=ttyS0;UART3=ttyS1;No ttyS2;No ttyS3 */
|
||||
# else
|
||||
# undef TTYS1_DEV /* UART0=ttyS0;No ttyS1;No ttyS2;No ttyS3 */
|
||||
# undef TTYS1_DEV /* UART0=ttyS0;No ttyS1;No ttyS2;No ttyS3 */
|
||||
# endif
|
||||
# undef TTYS2_DEV /* No ttyS2 */
|
||||
# undef TTYS3_DEV /* No ttyS3 */
|
||||
# undef TTYS2_DEV /* No ttyS2 */
|
||||
# undef TTYS3_DEV /* No ttyS3 */
|
||||
# endif
|
||||
# endif
|
||||
#endif /*HAVE_CONSOLE*/
|
||||
@ -524,6 +530,7 @@ static inline void up_restoreuartint(struct up_dev_s *priv, uint32_t ier)
|
||||
static inline void up_enablebreaks(struct up_dev_s *priv, bool enable)
|
||||
{
|
||||
uint32_t lcr = up_serialin(priv, LPC17_UART_LCR_OFFSET);
|
||||
|
||||
if (enable)
|
||||
{
|
||||
lcr |= UART_LCR_BRK;
|
||||
@ -532,6 +539,7 @@ static inline void up_enablebreaks(struct up_dev_s *priv, bool enable)
|
||||
{
|
||||
lcr &= ~UART_LCR_BRK;
|
||||
}
|
||||
|
||||
up_serialout(priv, LPC17_UART_LCR_OFFSET, lcr);
|
||||
}
|
||||
|
||||
@ -793,7 +801,6 @@ static inline uint32_t lpc17_uartdl(uint32_t baud, uint8_t divcode)
|
||||
|
||||
switch (divcode)
|
||||
{
|
||||
|
||||
case SYSCON_PCLKSEL_CCLK4: /* PCLK_peripheral = CCLK/4 */
|
||||
num = (LPC17_CCLK / 4);
|
||||
break;
|
||||
@ -811,6 +818,7 @@ static inline uint32_t lpc17_uartdl(uint32_t baud, uint8_t divcode)
|
||||
num = (LPC17_CCLK / 8);
|
||||
break;
|
||||
}
|
||||
|
||||
return num / (baud << 4);
|
||||
}
|
||||
|
||||
@ -950,6 +958,7 @@ static int up_attach(struct uart_dev_s *dev)
|
||||
|
||||
up_enable_irq(priv->irq);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -1121,18 +1130,17 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg)
|
||||
{
|
||||
case TIOCSERGSTRUCT:
|
||||
{
|
||||
struct up_dev_s *user = (struct up_dev_s*)arg;
|
||||
if (!user)
|
||||
{
|
||||
*get_errno_ptr() = EINVAL;
|
||||
ret = ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy(user, dev, sizeof(struct up_dev_s));
|
||||
}
|
||||
}
|
||||
break;
|
||||
struct up_dev_s *user = (struct up_dev_s*)arg;
|
||||
if (!user)
|
||||
{
|
||||
ret = -EINVAL;
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy(user, dev, sizeof(struct up_dev_s));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case TIOCSBRK: /* BSD compatibility: Turn break on, unconditionally */
|
||||
{
|
||||
@ -1151,9 +1159,68 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg)
|
||||
}
|
||||
break;
|
||||
|
||||
#ifdef CONFIG_SERIAL_TERMIOS
|
||||
case TCGETS:
|
||||
{
|
||||
struct termios *termiosp = (struct termios*)arg;
|
||||
|
||||
if (!termiosp)
|
||||
{
|
||||
ret = -EINVAL;
|
||||
break;
|
||||
}
|
||||
|
||||
/* TODO: Other termios fields are not yet returned.
|
||||
* Note that cfsetospeed is not necessary because we have
|
||||
* knowledge that only one speed is supported.
|
||||
* Both cfset(i|o)speed() translate to cfsetspeed.
|
||||
*/
|
||||
|
||||
cfsetispeed(termiosp, priv->baud);
|
||||
}
|
||||
break;
|
||||
|
||||
case TCSETS:
|
||||
{
|
||||
struct termios *termiosp = (struct termios*)arg;
|
||||
uint32_t lcr; /* Holds current values of line control register */
|
||||
uint16_t dl; /* Divisor latch */
|
||||
|
||||
if (!termiosp)
|
||||
{
|
||||
ret = -EINVAL;
|
||||
break;
|
||||
}
|
||||
|
||||
/* TODO: Handle other termios settings.
|
||||
* Note that only cfgetispeed is used because we have knowledge
|
||||
* that only one speed is supported.
|
||||
*/
|
||||
|
||||
/* Get the c_speed field in the termios struct */
|
||||
|
||||
priv->baud = cfgetispeed(termiosp);
|
||||
|
||||
/* DLAB open latch */
|
||||
|
||||
lcr = getreg32(priv->uartbase + LPC17_UART_LCR_OFFSET);
|
||||
up_serialout(priv, LPC17_UART_LCR_OFFSET, (lcr | UART_LCR_DLAB));
|
||||
|
||||
/* Set the BAUD divisor */
|
||||
|
||||
dl = lpc17_uartdl(priv->baud, priv->cclkdiv);
|
||||
up_serialout(priv, LPC17_UART_DLM_OFFSET, dl >> 8);
|
||||
up_serialout(priv, LPC17_UART_DLL_OFFSET, dl & 0xff);
|
||||
|
||||
/* Clear DLAB */
|
||||
|
||||
up_serialout(priv, LPC17_UART_LCR_OFFSET, lcr);
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
*get_errno_ptr() = ENOTTY;
|
||||
ret = ERROR;
|
||||
ret = -ENOTTY;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1201,6 +1268,7 @@ static void up_rxint(struct uart_dev_s *dev, bool enable)
|
||||
{
|
||||
priv->ier &= ~UART_IER_RBRIE;
|
||||
}
|
||||
|
||||
up_serialout(priv, LPC17_UART_IER_OFFSET, priv->ier);
|
||||
}
|
||||
|
||||
@ -1264,6 +1332,7 @@ static void up_txint(struct uart_dev_s *dev, bool enable)
|
||||
priv->ier &= ~UART_IER_THREIE;
|
||||
up_serialout(priv, LPC17_UART_IER_OFFSET, priv->ier);
|
||||
}
|
||||
|
||||
irqrestore(flags);
|
||||
}
|
||||
|
||||
|
@ -574,8 +574,7 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg)
|
||||
struct up_dev_s *user = (struct up_dev_s*)arg;
|
||||
if (!user)
|
||||
{
|
||||
*get_errno_ptr() = EINVAL;
|
||||
ret = ERROR;
|
||||
ret = -EINVAL;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -602,8 +601,7 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg)
|
||||
break;
|
||||
|
||||
default:
|
||||
*get_errno_ptr() = ENOTTY;
|
||||
ret = ERROR;
|
||||
ret = -ENOTTY;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
*
|
||||
* Copyright (C) 2010 Rommel Marcelo. All rights reserved.
|
||||
* Author: Rommel Marcelo
|
||||
* With updates by: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* This file is part of the NuttX RTOS and based on the lpc2148 port:
|
||||
*
|
||||
@ -696,8 +697,7 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg)
|
||||
struct up_dev_s *user = (struct up_dev_s *)arg;
|
||||
if (!user)
|
||||
{
|
||||
*get_errno_ptr() = EINVAL;
|
||||
ret = ERROR;
|
||||
ret = -EINVAL;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -726,8 +726,7 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg)
|
||||
break;
|
||||
|
||||
default:
|
||||
*get_errno_ptr() = ENOTTY;
|
||||
ret = ERROR;
|
||||
ret = -ENOTTY;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1085,8 +1085,7 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg)
|
||||
struct up_dev_s *user = (struct up_dev_s*)arg;
|
||||
if (!user)
|
||||
{
|
||||
*get_errno_ptr() = EINVAL;
|
||||
ret = ERROR;
|
||||
ret = -EINVAL;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1170,8 +1169,7 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg)
|
||||
#endif
|
||||
|
||||
default:
|
||||
*get_errno_ptr() = ENOTTY;
|
||||
ret = ERROR;
|
||||
ret = -ENOTTY;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -519,8 +519,7 @@ static int z16f_txinterrupt(int irq, void *context)
|
||||
|
||||
static int z16f_ioctl(struct file *filep, int cmd, unsigned long arg)
|
||||
{
|
||||
*get_errno_ptr() = ENOTTY;
|
||||
return ERROR;
|
||||
return -ENOTTY;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -525,8 +525,7 @@ static int ez80_interrrupt(int irq, void *context)
|
||||
|
||||
static int ez80_ioctl(struct file *filep, int cmd, unsigned long arg)
|
||||
{
|
||||
*get_errno_ptr() = ENOTTY;
|
||||
return ERROR;
|
||||
return -ENOTTY;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -581,8 +581,7 @@ static int z8_txinterrupt(int irq, FAR void *context)
|
||||
|
||||
static int z8_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
||||
{
|
||||
*get_errno_ptr() = ENOTTY;
|
||||
return ERROR;
|
||||
return -ENOTTY;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
Loading…
Reference in New Issue
Block a user