diff options
author | Kevin Hester <kevinh@geeksville.com> | 2014-04-16 10:01:13 -1000 |
---|---|---|
committer | Lorenz Meier <lm@inf.ethz.ch> | 2014-05-20 07:36:25 +0200 |
commit | e00c3872821e0914eef066138f3d7cc73a473d4d (patch) | |
tree | 6aa9e10798fde43aeedd0909dcfeda1d24620a36 /nuttx/drivers | |
parent | e0ea1b36bd01a84f291994328004b7e331009eea (diff) | |
download | px4-nuttx-e00c3872821e0914eef066138f3d7cc73a473d4d.tar.gz px4-nuttx-e00c3872821e0914eef066138f3d7cc73a473d4d.tar.bz2 px4-nuttx-e00c3872821e0914eef066138f3d7cc73a473d4d.zip |
stm32: add sw workaround for broken stm32 hw RTS implementation
adds support for manually asserting nRTS when the OS buffer is nearly full
and deasserting it when it has room again.
This makes the RTS pin actually work in a useful way (the stm32 hw
implementation is broken - it asserts nRTS as soon as more than one
character is received).
We assert nRTS from inside of up_recvchars. For deassertion we needed
a new callback from the general serial device layer when characters
have been dequed. onrxdeque was added to uart_ops_s for this purpose and
implemented (currently) only on the stm32.
Diffstat (limited to 'nuttx/drivers')
-rw-r--r-- | nuttx/drivers/serial/serial.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/nuttx/drivers/serial/serial.c b/nuttx/drivers/serial/serial.c index cbe502cc9..06a13620a 100644 --- a/nuttx/drivers/serial/serial.c +++ b/nuttx/drivers/serial/serial.c @@ -552,6 +552,8 @@ static ssize_t uart_read(FAR struct file *filep, FAR char *buffer, size_t buflen dev->recv.tail = tail; + uart_onrxdeque(dev); + #ifdef CONFIG_SERIAL_TERMIOS /* Do input processing if any is enabled */ @@ -1171,6 +1173,8 @@ static int uart_open(FAR struct file *filep) dev->recv.head = 0; dev->recv.tail = 0; + uart_onrxdeque(dev); + /* initialise termios state */ #ifdef CONFIG_SERIAL_TERMIOS @@ -1355,4 +1359,16 @@ void uart_connected(FAR uart_dev_t *dev, bool connected) #endif - +/************************************************************************************ + * Name: uart_numrxavail + * + * Description: + * This function returns the number of characters that are currently available for + * reading. + * + ************************************************************************************/ +ssize_t uart_numrxavail(FAR uart_dev_t *dev) +{ + struct uart_buffer_s *buf = &dev->recv; + return (buf->head >= buf->tail) ? buf->head - buf->tail : buf->size - buf->tail + buf->head; +} |