serial: Remove confusing inline functions. Correct attribution for serial DMA logic
This commit is contained in:
parent
7f1ac36194
commit
ab9d124528
2
arch
2
arch
@ -1 +1 @@
|
||||
Subproject commit e2ea7cb875351c6354ab956f40f830f8510e64b9
|
||||
Subproject commit 2ed5f475b11e34cd926c9591892d149d622e872f
|
@ -43,7 +43,6 @@ ifeq ($(CONFIG_SERIAL_DMA),y)
|
||||
CSRCS += serial_dma.c
|
||||
endif
|
||||
|
||||
|
||||
ifeq ($(CONFIG_16550_UART),y)
|
||||
CSRCS += uart_16550.c
|
||||
endif
|
||||
|
@ -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
|
||||
|
@ -46,79 +46,6 @@
|
||||
|
||||
#include <nuttx/serial/serial.h>
|
||||
|
||||
/************************************************************************************
|
||||
* 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
|
||||
************************************************************************************/
|
||||
@ -199,7 +126,6 @@ void uart_recvchars(FAR uart_dev_t *dev)
|
||||
unsigned int status;
|
||||
int nexthead = rxbuf->head + 1;
|
||||
uint16_t nbytes = 0;
|
||||
bool is_full;
|
||||
|
||||
if (nexthead >= rxbuf->size)
|
||||
{
|
||||
@ -218,19 +144,52 @@ void uart_recvchars(FAR uart_dev_t *dev)
|
||||
|
||||
while (uart_rxavailable(dev))
|
||||
{
|
||||
is_full = (nexthead == rxbuf->tail);
|
||||
bool is_full = (nexthead == rxbuf->tail);
|
||||
char ch;
|
||||
|
||||
#ifdef CONFIG_SERIAL_IFLOWCONTROL
|
||||
#ifdef CONFIG_SERIAL_IFLOWCONTROL_WATERMARKS
|
||||
if (uart_dorxflowcontrol(dev, rxbuf, watermark))
|
||||
unsigned int nbuffered;
|
||||
|
||||
/* How many bytes are buffered */
|
||||
|
||||
if (rxbuf->head >= rxbuf->tail)
|
||||
{
|
||||
break;
|
||||
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. */
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (uart_dorxflowcontrol(dev, rxbuf, 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)
|
||||
{
|
||||
break;
|
||||
if (uart_rxflowcontrol(dev, rxbuf->size, true))
|
||||
{
|
||||
/* Low-level driver activated RX flow control, exit loop now. */
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user