Remove STM32-specific RX flow control logic from the upper level serial driver to the lower level STM32 serial driver

This commit is contained in:
Gregory Nutt 2014-12-27 09:45:45 -06:00
parent 32fd858dc6
commit 33f7151cd9
3 changed files with 37 additions and 21 deletions

View File

@ -2151,23 +2151,39 @@ static bool up_rxflowcontrol(struct uart_dev_s *dev,
if (priv->iflow)
{
/* Disable Rx interrupt to prevent more data being from peripheral.
* When hardware RTS is enabled, this will prevent more data from
* coming in.
*
* This function is only called when UART recv buffer is full, that
* is: "dev->recv.head + 1 == dev->recv.tail".
*
* Logic in "uart_read" will automatically toggle Rx interrupts when
* buffer is read empty and thus we do not have to re-enable Rx
* interrupts in any other place.
*/
/* Is the RX buffer full? */
ie = priv->ie;
ie &= ~USART_CR1_RXNEIE;
up_restoreusartint(priv, ie);
if (upper)
{
/* Disable Rx interrupt to prevent more data being from
* peripheral. When hardware RTS is enabled, this will
* prevent more data from coming in.
*
* This function is only called when UART recv buffer is full,
* that is: "dev->recv.head + 1 == dev->recv.tail".
*
* Logic in "uart_read" will automatically toggle Rx interrupts
* when buffer is read empty and thus we do not have to re-
* enable Rx interrupts.
*/
return true;
ie = priv->ie;
ie &= ~USART_CR1_RXNEIE;
up_restoreusartint(priv, ie);
return true;
}
/* No.. The RX buffer is empty */
else
{
/* We might leave Rx interrupt disabled if full recv buffer was
* read empty. Enable Rx interrupt to make sure that more input is
* received.
*/
up_rxint(dev, true);
}
}
return false;

View File

@ -798,19 +798,19 @@ static ssize_t uart_read(FAR struct file *filep, FAR char *buffer, size_t buflen
if (nbuffered <= watermark)
{
/* Let the lower level driver know that the watermark level has been
* crossed.
* crossed. It will probably deactivate RX flow control.
*/
(void)uart_rxflowcontrol(dev, nbuffered, false);
}
#else
/* If the RX buffer empty */
if (rxbuf->head == rxbuf->tail)
{
/* We might leave Rx interrupt disabled if full recv buffer was read
* empty. Enable Rx interrupt to make sure that more input is received.
*/
/* Deactivate RX flow control. */
uart_enablerxint(dev);
(void)uart_rxflowcontrol(dev, 0, false);
}
#endif
#endif

View File

@ -186,7 +186,7 @@ void uart_recvchars(FAR uart_dev_t *dev)
if (nbuffered >= watermark)
{
/* Let the lower level driver know that the watermark level has been
* crossed.
* crossed. It will probably activate RX flow control.
*/
if (uart_rxflowcontrol(dev, nbuffered, true))