Remove BOTHER

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4972 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2012-07-24 15:10:21 +00:00
parent 9dee8a084d
commit 272a475b52
8 changed files with 105 additions and 104 deletions

View File

@ -3054,8 +3054,10 @@
standard) c_ispeed and c_ospeed baud values may be accessed directly.
* arch/arm/src/stm32/stm32_serial.c: Add minimal termios support for the STM32
(BOTHER style baud settings only). Contributed by Mike Smith.
* configs/lpc4343-xplorer/src: Clean up SPIFI-library based build to that it
actually works.
* arch/arm/src/lpc43xx/lpc43_spifi.c: Add support for verification to writes.
Add debug option to dump buffers. Several bugfixes... almost works.
* configs/lpc4343-xplorer/src: Clean up SPIFI-library based build to that it
actually works.
* arch/arm/src/lpc43xx/lpc43_spifi.c: Add support for verification to writes.
Add debug option to dump buffers. Several bugfixes... almost works.
* include/termios.h, lib/termios/*, and arch/arm/src/stm32/stm32_serial.c: :
BOTHER is gone again.

View File

@ -1248,15 +1248,9 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg)
break;
}
/* TODO: (1) Note that only the BOTHER baud is returned; (2) Other
* termios fields are not yet initialized. Here we also exploit the
* internal knowledge that ctfsetospeed() is equivalent to
* cfsetispeed().
*/
/* TODO: Other termios fields are not yet returned. */
cfsetispeed(termiosp, BOTHER);
termiosp->c_ispeed = priv->baud;
termiosp->c_ospeed = priv->baud;
termiosp->c_speed = priv->baud;
}
break;
@ -1270,19 +1264,9 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg)
break;
}
/* TODO: Only the BOTHER speed setting is supported. Here we
* also exploit the internal knowledge that ctfgetospeed() is
* equivalent to cfgetispeed().
*/
/* TODO: Handle other termios settings. */
if (cfgetospeed(termiosp) != BOTHER ||
termiosp->c_ispeed != termiosp->c_ospeed)
{
ret = -ENOSYS;
break;
}
priv->baud = termiosp->c_ispeed;
priv->baud = termiosp->c_speed;
up_setspeed(dev);
}
break;

View File

@ -1107,7 +1107,7 @@ CONFIG_EXAMPLE_BUTTONS_NAME1="SW2"
# examples/modbus
#
# CONFIG_EXAMPLES_MODBUS_PORT, Default 0 (for /dev/ttyS0)
# CONFIG_EXAMPLES_MODBUS_BAUD, Default 38400
# CONFIG_EXAMPLES_MODBUS_BAUD, Default B38400
# CONFIG_EXAMPLES_MODBUS_PARITY, Default MB_PAR_EVEN
#
# CONFIG_EXAMPLES_MODBUS_REG_INPUT_START, Default 1000
@ -1116,7 +1116,7 @@ CONFIG_EXAMPLE_BUTTONS_NAME1="SW2"
# CONFIG_EXAMPLES_MODBUS_REG_HOLDING_NREGS, Default 130
#
CONFIG_EXAMPLES_MODBUS_PORT=1
CONFIG_EXAMPLES_MODBUS_BAUD=9600
CONFIG_EXAMPLES_MODBUS_BAUD=B9600
#
# Settings for examples/usbserial

View File

@ -98,19 +98,17 @@
/* Control Modes (c_cflag in the termios structure) */
#define CBAUD (0x0f) /* Bits 0-3: baud */
#define CBAUDEX (1 << 4) /* Bit 4: Extended baud */
#define CSIZE (3 << 5) /* Bits 5-6: Character size: */
# define CS5 (0 << 5) /* 5 bits */
# define CS6 (1 << 5) /* 6 bits */
# define CS7 (2 << 5) /* 7 bits */
# define CS8 (3 << 5) /* 8 bits */
#define CSTOPB (1 << 7) /* Bit 7: Send two stop bits, else one */
#define CREAD (1 << 8) /* Bit 8: Enable receiver */
#define PARENB (1 << 9) /* Bit 9: Parity enable */
#define PARODD (1 << 10) /* Bit 10: Odd parity, else even */
#define HUPCL (1 << 11) /* Bit 11: Hang up on last close */
#define CLOCAL (1 << 12) /* Bit 12: Ignore modem status lines */
#define CSIZE (3 << 0) /* Bits 0-1: Character size: */
# define CS5 (0 << 0) /* 5 bits */
# define CS6 (1 << 0) /* 6 bits */
# define CS7 (2 << 0) /* 7 bits */
# define CS8 (3 << 0) /* 8 bits */
#define CSTOPB (1 << 2) /* Bit 2: Send two stop bits, else one */
#define CREAD (1 << 3) /* Bit 3: Enable receiver */
#define PARENB (1 << 4) /* Bit 4: Parity enable */
#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 */
/* Local Modes (c_lflag in the termios structure) */
@ -142,41 +140,38 @@
/* Baud Rate Selection. */
#define B0 (0x00) /* Hang up */
#define B50 (0x01) /* 50 baud */
#define B75 (0x02) /* 75 baud */
#define B110 (0x03) /* 110 baud */
#define B134 (0x04) /* 134.5 baud */
#define B150 (0x05) /* 150 baud */
#define B200 (0x06) /* 200 baud */
#define B300 (0x07) /* 300 baud */
#define B600 (0x08) /* 600 baud */
#define B1200 (0x09) /* 1,200 baud */
#define B1800 (0x0a) /* 1,800 baud */
#define B2400 (0x0b) /* 2,400 baud */
#define B4800 (0x0c) /* 4,800 baud */
#define B9600 (0x0d) /* 9,600 baud */
#define B19200 (0x0e) /* 19,200 baud */
#define B38400 (0x0f) /* 38,400 baud */
#define B0 0 /* Hang up */
#define B50 50 /* 50 baud */
#define B75 75 /* 75 baud */
#define B110 110 /* 110 baud */
#define B134 134 /* 134.5 baud */
#define B150 150 /* 150 baud */
#define B200 200 /* 200 baud */
#define B300 300 /* 300 baud */
#define B600 600 /* 600 baud */
#define B1200 1200 /* 1,200 baud */
#define B1800 1800 /* 1,800 baud */
#define B2400 2400 /* 2,400 baud */
#define B4800 4800 /* 4,800 baud */
#define B9600 9600 /* 9,600 baud */
#define B19200 19200 /* 19,200 baud */
#define B38400 38400 /* 38,400 baud */
/* "Extended" baud rates above 37K include the CBAUDEX bit */
#define BOTHER (CBAUDEX | 0x00) /* Use baud values in c_ispeed and c_ospeed */
#define B57600 (CBAUDEX | 0x01) /* 57,600 baud */
#define B115200 (CBAUDEX | 0x02) /* 115,200 baud */
#define B128000 (CBAUDEX | 0x03) /* 128,000 baud */
#define B230400 (CBAUDEX | 0x04) /* 230,400 baud */
#define B256000 (CBAUDEX | 0x05) /* 256,000 baud */
#define B460800 (CBAUDEX | 0x06) /* 460,800 baud */
#define B500000 (CBAUDEX | 0x07) /* 500,000 baud */
#define B576000 (CBAUDEX | 0x08) /* 576,000 baud */
#define B921600 (CBAUDEX | 0x09) /* 921,600 baud */
#define B1000000 (CBAUDEX | 0x0a) /* 1,000,000 baud */
#define B1152000 (CBAUDEX | 0x0b) /* 1,152,000 baud */
#define B1500000 (CBAUDEX | 0x0c) /* 1,500,000 baud */
#define B2000000 (CBAUDEX | 0x0d) /* 2,000,000 baud */
#define B2500000 (CBAUDEX | 0x0e) /* 2,500,000 baud */
#define B3000000 (CBAUDEX | 0x0f) /* 3,000,000 baud */
#define B57600 57600 /* 57,600 baud */
#define B115200 115200 /* 115,200 baud */
#define B128000 128000 /* 128,000 baud */
#define B230400 230400 /* 230,400 baud */
#define B256000 256000 /* 256,000 baud */
#define B460800 460800 /* 460,800 baud */
#define B500000 500000 /* 500,000 baud */
#define B576000 576000 /* 576,000 baud */
#define B921600 921600 /* 921,600 baud */
#define B1000000 1000000 /* 1,000,000 baud */
#define B1152000 1152000 /* 1,152,000 baud */
#define B1500000 1500000 /* 1,500,000 baud */
#define B2000000 2000000 /* 2,000,000 baud */
#define B2500000 2500000 /* 2,500,000 baud */
#define B3000000 3000000 /* 3,000,000 baud */
/* Attribute Selection (used with tcsetattr()) */
@ -222,10 +217,12 @@ struct termios
tcflag_t c_lflag; /* Local modes */
cc_t c_cc[NCCS]; /* Control chars */
/* If CBAUD == BOTHER, then these fields hold the input/output BAUD. */
/* Implementation specific fields. For portability reasons, these fields
* should not be accessed directly, but rather through only through the
* cf[set|get][o|i]speed() POSIX interfaces.
*/
speed_t c_ispeed; /* Input speed (non-POSIX)*/
speed_t c_ospeed; /* Output speed (non-POSIX) */
const speed_t c_speed; /* Input/output speed (non-POSIX)*/
};
/****************************************************************************

View File

@ -65,15 +65,17 @@
*
* Descripton:
* The cfgetispeed() function shall extract the input baud rate from the
* termios structure to which the termios_p argument points.
* termios structure to which the termiosp argument points.
*
* This function shall return exactly the value in the termios data
* structure, without interpretation.
*
* NOTE 1: NuttX does not not control input/output baud rates independently
* Hense, this function is *identical* to cfgetospeed.
* NOTE 2: If this function returns BOTHER and the more flexible input
* speed can be obtained from the Linux-like c_ispeed field.
* NOTE 2. In Nuttx, the speed_t is defined to be uint32_t and the baud
* encodings of termios.h are the actual baud values themselves. Therefore,
* any baud value may be returned here... not just those enumerated in
* termios.h
*
* Input Parameters:
* termiosp - The termiosp argument is a pointer to a termios structure.
@ -83,8 +85,8 @@
*
****************************************************************************/
speed_t cfgetispeed(const struct termios *termios_p)
speed_t cfgetispeed(FAR const struct termios *termiosp)
{
DEBUGASSERT(termios_p);
return (termios_p->c_cflag & (CBAUD | CBAUDEX));
DEBUGASSERT(termiosp);
return termiosp->c_speed;
}

View File

@ -65,15 +65,17 @@
*
* Descripton:
* The cfgetospeed() function shall extract the output baud rate from the
* termios structure to which the termios_p argument points.
* termios structure to which the termiosp argument points.
*
* This function shall return exactly the value in the termios data
* structure, without interpretation.
*
* NOTE 1: NuttX does not not control input/output baud rates independently
* Hense, this function is *identical* to cfgetispeed.
* NOTE 2: If this function returns BOTHER and the more flexible input
* speed can be obtained from the Linux-like c_ospeed field.
* NOTE 2. In Nuttx, the speed_t is defined to be uint32_t and the baud
* encodings of termios.h are the actual baud values themselves. Therefore,
* any baud value may be returned here... not just those enumerated in
* termios.h
*
* Input Parameters:
* termiosp - The termiosp argument is a pointer to a termios structure.
@ -83,8 +85,8 @@
*
****************************************************************************/
speed_t cfgetospeed(const struct termios *termios_p)
speed_t cfgetospeed(FAR const struct termios *termiosp)
{
DEBUGASSERT(termios_p);
return (termios_p->c_cflag & (CBAUD | CBAUDEX));
DEBUGASSERT(termiosp);
return termiosp->c_speed;
}

View File

@ -66,15 +66,19 @@
*
* Descripton:
* The cfsetispeed() function sets the input baud rate stored in the
* structure pointed to by termios_p to speed.
* structure pointed to by termiosp to speed.
*
* There is no effect on the baud rates set in the hardware until a
* subsequent successful call to tcsetattr() on the same termios structure.
*
* NOTE 1: NuttX does not not control input/output baud rates independently
* Hense, this function is *identical* to cfsetospeed.
* NOTE 2: If the specia value BOTHER is used, then the actual input baud
* must also be provided in the (non-standard) c_ispeed field.
* NOTE 2. In Nuttx, the speed_t is defined to be uint32_t and the baud
* encodings of termios.h are the actual baud values themselves. Therefore,
* any baud value can be provided as the speed argument here. However, if
* you do so, your code will *NOT* be portable to other environments where
* speed_t is smaller and where the termios.h baud values are encoded! To
* avoid portability issues, use the baud definitions in termios.h!
*
* Input Parameters:
* termiosp - The termiosp argument is a pointer to a termios structure.
@ -86,11 +90,14 @@
*
****************************************************************************/
int cfsetispeed(struct termios *termios_p, speed_t speed)
int cfsetispeed(FAR struct termios *termiosp, speed_t speed)
{
DEBUGASSERT(termios_p);
speed &= (CBAUD | CBAUDEX);
termios_p->c_cflag &= ~(CBAUD | CBAUDEX);
termios_p->c_cflag |= speed;
FAR speed_t *speedp;
DEBUGASSERT(termiosp);
speedp = (FAR speed_t *)&termiosp->c_speed;
*speedp = speed;
return OK;
}

View File

@ -66,15 +66,19 @@
*
* Descripton:
* The cfsetospeed() function sets the output baud rate stored in the
* structure pointed to by termios_p to speed.
* structure pointed to by termiosp to speed.
*
* There is no effect on the baud rates set in the hardware until a
* subsequent successful call to tcsetattr() on the same termios structure.
*
* NOTE 1: NuttX does not not control input/output baud rates independently
* Hense, this function is *identical* to cfsetispeed.
* NOTE 2: If the specia value BOTHER is used, then the actual input baud
* must also be provided in the (non-standard) c_ospeed field.
* NOTE 2. In Nuttx, the speed_t is defined to be uint32_t and the baud
* encodings of termios.h are the actual baud values themselves. Therefore,
* any baud value can be provided as the speed argument here. However, if
* you do so, your code will *NOT* be portable to other environments where
* speed_t is smaller and where the termios.h baud values are encoded! To
* avoid portability issues, use the baud definitions in termios.h!
*
* Input Parameters:
* termiosp - The termiosp argument is a pointer to a termios structure.
@ -86,11 +90,14 @@
*
****************************************************************************/
int cfsetospeed(struct termios *termios_p, speed_t speed)
int cfsetospeed(struct termios *termiosp, speed_t speed)
{
DEBUGASSERT(termios_p);
speed &= (CBAUD | CBAUDEX);
termios_p->c_cflag &= ~(CBAUD | CBAUDEX);
termios_p->c_cflag |= speed;
FAR speed_t *speedp;
DEBUGASSERT(termiosp);
speedp = (FAR speed_t *)&termiosp->c_speed;
*speedp = speed;
return OK;
}