serial: Remove confusing inline functions. Correct attribution for serial DMA logic

This commit is contained in:
Gregory Nutt
2015-11-15 08:39:01 -06:00
parent 7f1ac36194
commit ab9d124528
4 changed files with 78 additions and 160 deletions
+39 -79
View File
@@ -2,7 +2,7 @@
* drivers/serial/serial_dma.c
*
* Copyright (C) 2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
* Author: Max Neklyudov <macscomp@gmail.com>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -48,79 +48,6 @@
#ifdef CONFIG_SERIAL_DMA
/************************************************************************************
* Private Functions
************************************************************************************/
/************************************************************************************
* Name: uart_dorxflowcontrol
*
* Description:
* Handle RX flow control using watermark levels or not
*
************************************************************************************/
#ifdef CONFIG_SERIAL_IFLOWCONTROL
#ifdef CONFIG_SERIAL_IFLOWCONTROL_WATERMARKS
static inline bool uart_dorxflowcontrol(FAR uart_dev_t *dev,
FAR struct uart_buffer_s *rxbuf,
unsigned int watermark)
{
unsigned int nbuffered;
/* How many bytes are buffered */
if (rxbuf->head >= rxbuf->tail)
{
nbuffered = rxbuf->head - rxbuf->tail;
}
else
{
nbuffered = rxbuf->size - rxbuf->tail + rxbuf->head;
}
/* Is the level now above the watermark level that we need to report? */
if (nbuffered >= watermark)
{
/* Let the lower level driver know that the watermark level has been
* crossed. It will probably activate RX flow control.
*/
if (uart_rxflowcontrol(dev, nbuffered, true))
{
/* Low-level driver activated RX flow control, exit loop now. */
return true;
}
}
return false;
}
#else
static inline bool uart_dorxflowcontrol(FAR uart_dev_t *dev,
FAR struct uart_buffer_s *rxbuf,
bool is_full)
{
/* Check if RX buffer is full and allow serial low-level driver to pause
* processing. This allows proper utilization of hardware flow control.
*/
if (is_full)
{
if (uart_rxflowcontrol(dev, rxbuf->size, true))
{
/* Low-level driver activated RX flow control, exit loop now. */
return true;
}
}
return false;
}
#endif
#endif
/************************************************************************************
* Public Functions
************************************************************************************/
@@ -207,6 +134,7 @@ void uart_recvchars_dma(FAR uart_dev_t *dev)
FAR struct uart_dmaxfer_s *xfer = &dev->dmarx;
FAR struct uart_buffer_s *rxbuf = &dev->recv;
#ifdef CONFIG_SERIAL_IFLOWCONTROL_WATERMARKS
unsigned int nbuffered;
unsigned int watermark;
#endif
bool is_full;
@@ -227,14 +155,46 @@ void uart_recvchars_dma(FAR uart_dev_t *dev)
#ifdef CONFIG_SERIAL_IFLOWCONTROL
#ifdef CONFIG_SERIAL_IFLOWCONTROL_WATERMARKS
if (uart_dorxflowcontrol(dev, rxbuf, watermark))
/* How many bytes are buffered */
if (rxbuf->head >= rxbuf->tail)
{
return;
nbuffered = rxbuf->head - rxbuf->tail;
}
#else
if (uart_dorxflowcontrol(dev, rxbuf, is_full))
else
{
return;
nbuffered = rxbuf->size - rxbuf->tail + rxbuf->head;
}
/* Is the level now above the watermark level that we need to report? */
if (nbuffered >= watermark)
{
/* Let the lower level driver know that the watermark level has been
* crossed. It will probably activate RX flow control.
*/
if (uart_rxflowcontrol(dev, nbuffered, true))
{
/* Low-level driver activated RX flow control, return now. */
return;
}
}
#else
/* Check if RX buffer is full and allow serial low-level driver to pause
* processing. This allows proper utilization of hardware flow control.
*/
if (is_full)
{
if (uart_rxflowcontrol(dev, rxbuf->size, true))
{
/* Low-level driver activated RX flow control, return now. */
return;
}
}
#endif
#endif