stm32f7:serial fix coding standard violation
This commit is contained in:
parent
7ef4f53dff
commit
acb90ea449
@ -1,4 +1,4 @@
|
|||||||
/****************************************************************************
|
/**************************************************************************************************
|
||||||
* arch/arm/src/stm32f7/stm32_serial.c
|
* arch/arm/src/stm32f7/stm32_serial.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2015-2019 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2015-2019 Gregory Nutt. All rights reserved.
|
||||||
@ -32,11 +32,11 @@
|
|||||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
**************************************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************
|
/**************************************************************************************************
|
||||||
* Included Files
|
* Included Files
|
||||||
****************************************************************************/
|
**************************************************************************************************/
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
@ -70,11 +70,11 @@
|
|||||||
|
|
||||||
#include <arch/board/board.h>
|
#include <arch/board/board.h>
|
||||||
|
|
||||||
/****************************************************************************
|
/**************************************************************************************************
|
||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
****************************************************************************/
|
**************************************************************************************************/
|
||||||
|
|
||||||
/* Some sanity checks *******************************************************/
|
/* Some sanity checks *****************************************************************************/
|
||||||
|
|
||||||
/* Total number of possible serial devices */
|
/* Total number of possible serial devices */
|
||||||
|
|
||||||
@ -431,9 +431,9 @@
|
|||||||
# endif
|
# endif
|
||||||
#endif /* CONFIG_STM32F7_FLOWCONTROL_BROKEN */
|
#endif /* CONFIG_STM32F7_FLOWCONTROL_BROKEN */
|
||||||
|
|
||||||
/****************************************************************************
|
/**************************************************************************************************
|
||||||
* Private Types
|
* Private Types
|
||||||
****************************************************************************/
|
**************************************************************************************************/
|
||||||
|
|
||||||
struct up_dev_s
|
struct up_dev_s
|
||||||
{
|
{
|
||||||
@ -497,24 +497,24 @@ struct up_dev_s
|
|||||||
|
|
||||||
#ifdef SERIAL_HAVE_TXDMA
|
#ifdef SERIAL_HAVE_TXDMA
|
||||||
const unsigned int txdma_channel; /* DMA channel assigned */
|
const unsigned int txdma_channel; /* DMA channel assigned */
|
||||||
DMA_HANDLE txdma; /* currently-open trasnmit DMA stream */
|
DMA_HANDLE txdma; /* currently-open trasnmit DMA stream */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* RX DMA state */
|
/* RX DMA state */
|
||||||
|
|
||||||
#ifdef SERIAL_HAVE_RXDMA
|
#ifdef SERIAL_HAVE_RXDMA
|
||||||
const unsigned int rxdma_channel; /* DMA channel assigned */
|
const unsigned int rxdma_channel; /* DMA channel assigned */
|
||||||
DMA_HANDLE rxdma; /* currently-open receive DMA stream */
|
DMA_HANDLE rxdma; /* currently-open receive DMA stream */
|
||||||
bool rxenable; /* DMA-based reception en/disable */
|
bool rxenable; /* DMA-based reception en/disable */
|
||||||
#ifdef CONFIG_PM
|
#ifdef CONFIG_PM
|
||||||
bool rxdmasusp; /* Rx DMA suspended */
|
bool rxdmasusp; /* Rx DMA suspended */
|
||||||
#endif
|
#endif
|
||||||
uint32_t rxdmanext; /* Next byte in the DMA buffer to be read */
|
uint32_t rxdmanext; /* Next byte in the DMA buffer to be read */
|
||||||
#ifdef CONFIG_ARMV7M_DCACHE
|
#ifdef CONFIG_ARMV7M_DCACHE
|
||||||
uint32_t rxdmaavail; /* Number of bytes available without need to
|
uint32_t rxdmaavail; /* Number of bytes available without need to
|
||||||
* to invalidate the data cache */
|
* to invalidate the data cache */
|
||||||
#endif
|
#endif
|
||||||
char *const rxfifo; /* Receive DMA buffer */
|
char *const rxfifo; /* Receive DMA buffer */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_RS485
|
#ifdef HAVE_RS485
|
||||||
@ -533,9 +533,9 @@ struct pm_config_s
|
|||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/**************************************************************************************************
|
||||||
* Private Function Prototypes
|
* Private Function Prototypes
|
||||||
****************************************************************************/
|
**************************************************************************************************/
|
||||||
|
|
||||||
#ifndef CONFIG_SUPPRESS_UART_CONFIG
|
#ifndef CONFIG_SUPPRESS_UART_CONFIG
|
||||||
static void up_set_format(struct uart_dev_s *dev);
|
static void up_set_format(struct uart_dev_s *dev);
|
||||||
@ -591,9 +591,9 @@ static int up_pm_prepare(struct pm_callback_s *cb, int domain,
|
|||||||
enum pm_state_e pmstate);
|
enum pm_state_e pmstate);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/**************************************************************************************************
|
||||||
* Private Data
|
* Private Data
|
||||||
****************************************************************************/
|
**************************************************************************************************/
|
||||||
|
|
||||||
#if !defined(SERIAL_HAVE_ONLY_DMA)
|
#if !defined(SERIAL_HAVE_ONLY_DMA)
|
||||||
static const struct uart_ops_s g_uart_ops =
|
static const struct uart_ops_s g_uart_ops =
|
||||||
@ -1366,22 +1366,22 @@ static struct pm_config_s g_serialpm =
|
|||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/**************************************************************************************************
|
||||||
* Private Functions
|
* Private Functions
|
||||||
****************************************************************************/
|
**************************************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************
|
/**************************************************************************************************
|
||||||
* Name: up_serialin
|
* Name: up_serialin
|
||||||
****************************************************************************/
|
**************************************************************************************************/
|
||||||
|
|
||||||
static inline uint32_t up_serialin(struct up_dev_s *priv, int offset)
|
static inline uint32_t up_serialin(struct up_dev_s *priv, int offset)
|
||||||
{
|
{
|
||||||
return getreg32(priv->usartbase + offset);
|
return getreg32(priv->usartbase + offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/**************************************************************************************************
|
||||||
* Name: up_serialout
|
* Name: up_serialout
|
||||||
****************************************************************************/
|
**************************************************************************************************/
|
||||||
|
|
||||||
static inline void up_serialout(struct up_dev_s *priv, int offset,
|
static inline void up_serialout(struct up_dev_s *priv, int offset,
|
||||||
uint32_t value)
|
uint32_t value)
|
||||||
@ -1389,9 +1389,9 @@ static inline void up_serialout(struct up_dev_s *priv, int offset,
|
|||||||
putreg32(value, priv->usartbase + offset);
|
putreg32(value, priv->usartbase + offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/**************************************************************************************************
|
||||||
* Name: up_setusartint
|
* Name: up_setusartint
|
||||||
****************************************************************************/
|
**************************************************************************************************/
|
||||||
|
|
||||||
static inline void up_setusartint(struct up_dev_s *priv, uint16_t ie)
|
static inline void up_setusartint(struct up_dev_s *priv, uint16_t ie)
|
||||||
{
|
{
|
||||||
@ -1414,9 +1414,9 @@ static inline void up_setusartint(struct up_dev_s *priv, uint16_t ie)
|
|||||||
up_serialout(priv, STM32_USART_CR3_OFFSET, cr);
|
up_serialout(priv, STM32_USART_CR3_OFFSET, cr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/**************************************************************************************************
|
||||||
* Name: up_restoreusartint
|
* Name: up_restoreusartint
|
||||||
****************************************************************************/
|
**************************************************************************************************/
|
||||||
|
|
||||||
static void up_restoreusartint(struct up_dev_s *priv, uint16_t ie)
|
static void up_restoreusartint(struct up_dev_s *priv, uint16_t ie)
|
||||||
{
|
{
|
||||||
@ -1429,9 +1429,9 @@ static void up_restoreusartint(struct up_dev_s *priv, uint16_t ie)
|
|||||||
leave_critical_section(flags);
|
leave_critical_section(flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/**************************************************************************************************
|
||||||
* Name: up_disableusartint
|
* Name: up_disableusartint
|
||||||
****************************************************************************/
|
**************************************************************************************************/
|
||||||
|
|
||||||
static void up_disableusartint(struct up_dev_s *priv, uint16_t *ie)
|
static void up_disableusartint(struct up_dev_s *priv, uint16_t *ie)
|
||||||
{
|
{
|
||||||
@ -1481,14 +1481,14 @@ static void up_disableusartint(struct up_dev_s *priv, uint16_t *ie)
|
|||||||
leave_critical_section(flags);
|
leave_critical_section(flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/**************************************************************************************************
|
||||||
* Name: up_dma_nextrx
|
* Name: up_dma_nextrx
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Returns the index into the RX FIFO where the DMA will place the next
|
* Returns the index into the RX FIFO where the DMA will place the next
|
||||||
* byte that it receives.
|
* byte that it receives.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
**************************************************************************************************/
|
||||||
|
|
||||||
#ifdef SERIAL_HAVE_RXDMA
|
#ifdef SERIAL_HAVE_RXDMA
|
||||||
static int up_dma_nextrx(struct up_dev_s *priv)
|
static int up_dma_nextrx(struct up_dev_s *priv)
|
||||||
@ -1501,13 +1501,13 @@ static int up_dma_nextrx(struct up_dev_s *priv)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/**************************************************************************************************
|
||||||
* Name: up_set_format
|
* Name: up_set_format
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Set the serial line format and speed.
|
* Set the serial line format and speed.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
**************************************************************************************************/
|
||||||
|
|
||||||
#ifndef CONFIG_SUPPRESS_UART_CONFIG
|
#ifndef CONFIG_SUPPRESS_UART_CONFIG
|
||||||
static void up_set_format(struct uart_dev_s *dev)
|
static void up_set_format(struct uart_dev_s *dev)
|
||||||
@ -1657,13 +1657,13 @@ static void up_set_format(struct uart_dev_s *dev)
|
|||||||
}
|
}
|
||||||
#endif /* CONFIG_SUPPRESS_UART_CONFIG */
|
#endif /* CONFIG_SUPPRESS_UART_CONFIG */
|
||||||
|
|
||||||
/****************************************************************************
|
/**************************************************************************************************
|
||||||
* Name: up_setsuspend
|
* Name: up_setsuspend
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Suspend or resume serial peripheral.
|
* Suspend or resume serial peripheral.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
**************************************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_PM
|
#ifdef CONFIG_PM
|
||||||
static void up_setsuspend(struct uart_dev_s *dev, bool suspend)
|
static void up_setsuspend(struct uart_dev_s *dev, bool suspend)
|
||||||
@ -1769,13 +1769,13 @@ static void up_setsuspend(struct uart_dev_s *dev, bool suspend)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/**************************************************************************************************
|
||||||
* Name: up_pm_setsuspend
|
* Name: up_pm_setsuspend
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Suspend or resume serial peripherals for/from deep-sleep/stop modes.
|
* Suspend or resume serial peripherals for/from deep-sleep/stop modes.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
**************************************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_PM
|
#ifdef CONFIG_PM
|
||||||
static void up_pm_setsuspend(bool suspend)
|
static void up_pm_setsuspend(bool suspend)
|
||||||
@ -1805,7 +1805,7 @@ static void up_pm_setsuspend(bool suspend)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/**************************************************************************************************
|
||||||
* Name: up_set_apb_clock
|
* Name: up_set_apb_clock
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
@ -1815,7 +1815,7 @@ static void up_pm_setsuspend(bool suspend)
|
|||||||
* dev - A reference to the UART driver state structure
|
* dev - A reference to the UART driver state structure
|
||||||
* on - Enable clock if 'on' is 'true' and disable if 'false'
|
* on - Enable clock if 'on' is 'true' and disable if 'false'
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
**************************************************************************************************/
|
||||||
|
|
||||||
static void up_set_apb_clock(struct uart_dev_s *dev, bool on)
|
static void up_set_apb_clock(struct uart_dev_s *dev, bool on)
|
||||||
{
|
{
|
||||||
@ -1891,14 +1891,14 @@ static void up_set_apb_clock(struct uart_dev_s *dev, bool on)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/**************************************************************************************************
|
||||||
* Name: up_setup
|
* Name: up_setup
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Configure the USART baud, bits, parity, etc. This method is called the
|
* Configure the USART baud, bits, parity, etc. This method is called the
|
||||||
* first time that the serial port is opened.
|
* first time that the serial port is opened.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
**************************************************************************************************/
|
||||||
|
|
||||||
static int up_setup(struct uart_dev_s *dev)
|
static int up_setup(struct uart_dev_s *dev)
|
||||||
{
|
{
|
||||||
@ -2008,14 +2008,14 @@ static int up_setup(struct uart_dev_s *dev)
|
|||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/**************************************************************************************************
|
||||||
* Name: up_dma_setup
|
* Name: up_dma_setup
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Configure the USART baud, bits, parity, etc. This method is called the
|
* Configure the USART baud, bits, parity, etc. This method is called the
|
||||||
* first time that the serial port is opened.
|
* first time that the serial port is opened.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
**************************************************************************************************/
|
||||||
|
|
||||||
#if defined(SERIAL_HAVE_RXDMA) || defined(SERIAL_HAVE_TXDMA)
|
#if defined(SERIAL_HAVE_RXDMA) || defined(SERIAL_HAVE_TXDMA)
|
||||||
static int up_dma_setup(struct uart_dev_s *dev)
|
static int up_dma_setup(struct uart_dev_s *dev)
|
||||||
@ -2088,14 +2088,14 @@ static int up_dma_setup(struct uart_dev_s *dev)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/**************************************************************************************************
|
||||||
* Name: up_shutdown
|
* Name: up_shutdown
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Disable the USART. This method is called when the serial
|
* Disable the USART. This method is called when the serial
|
||||||
* port is closed
|
* port is closed
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
**************************************************************************************************/
|
||||||
|
|
||||||
static void up_shutdown(struct uart_dev_s *dev)
|
static void up_shutdown(struct uart_dev_s *dev)
|
||||||
{
|
{
|
||||||
@ -2153,14 +2153,14 @@ static void up_shutdown(struct uart_dev_s *dev)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/**************************************************************************************************
|
||||||
* Name: up_dma_shutdown
|
* Name: up_dma_shutdown
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Disable the USART. This method is called when the serial
|
* Disable the USART. This method is called when the serial
|
||||||
* port is closed
|
* port is closed
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
**************************************************************************************************/
|
||||||
|
|
||||||
#if defined(SERIAL_HAVE_RXDMA) || defined(SERIAL_HAVE_TXDMA)
|
#if defined(SERIAL_HAVE_RXDMA) || defined(SERIAL_HAVE_TXDMA)
|
||||||
static void up_dma_shutdown(struct uart_dev_s *dev)
|
static void up_dma_shutdown(struct uart_dev_s *dev)
|
||||||
@ -2201,7 +2201,7 @@ static void up_dma_shutdown(struct uart_dev_s *dev)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/**************************************************************************************************
|
||||||
* Name: up_attach
|
* Name: up_attach
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
@ -2215,7 +2215,7 @@ static void up_dma_shutdown(struct uart_dev_s *dev)
|
|||||||
* interrupts are not enabled until the txint() and rxint() methods are
|
* interrupts are not enabled until the txint() and rxint() methods are
|
||||||
* called.
|
* called.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
**************************************************************************************************/
|
||||||
|
|
||||||
static int up_attach(struct uart_dev_s *dev)
|
static int up_attach(struct uart_dev_s *dev)
|
||||||
{
|
{
|
||||||
@ -2237,7 +2237,7 @@ static int up_attach(struct uart_dev_s *dev)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/**************************************************************************************************
|
||||||
* Name: up_detach
|
* Name: up_detach
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
@ -2245,7 +2245,7 @@ static int up_attach(struct uart_dev_s *dev)
|
|||||||
* closed normally just before the shutdown method is called. The exception
|
* closed normally just before the shutdown method is called. The exception
|
||||||
* is the serial console which is never shutdown.
|
* is the serial console which is never shutdown.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
**************************************************************************************************/
|
||||||
|
|
||||||
static void up_detach(struct uart_dev_s *dev)
|
static void up_detach(struct uart_dev_s *dev)
|
||||||
{
|
{
|
||||||
@ -2254,7 +2254,7 @@ static void up_detach(struct uart_dev_s *dev)
|
|||||||
irq_detach(priv->irq);
|
irq_detach(priv->irq);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/**************************************************************************************************
|
||||||
* Name: up_interrupt
|
* Name: up_interrupt
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
@ -2264,7 +2264,7 @@ static void up_detach(struct uart_dev_s *dev)
|
|||||||
* interrupt handling logic must be able to map the 'irq' number into the
|
* interrupt handling logic must be able to map the 'irq' number into the
|
||||||
* appropriate uart_dev_s structure in order to call these functions.
|
* appropriate uart_dev_s structure in order to call these functions.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
**************************************************************************************************/
|
||||||
|
|
||||||
static int up_interrupt(int irq, void *context, FAR void *arg)
|
static int up_interrupt(int irq, void *context, FAR void *arg)
|
||||||
{
|
{
|
||||||
@ -2372,13 +2372,13 @@ static int up_interrupt(int irq, void *context, FAR void *arg)
|
|||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/**************************************************************************************************
|
||||||
* Name: up_ioctl
|
* Name: up_ioctl
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* All ioctl calls will be routed through this method
|
* All ioctl calls will be routed through this method
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
**************************************************************************************************/
|
||||||
|
|
||||||
static int up_ioctl(struct file *filep, int cmd, unsigned long arg)
|
static int up_ioctl(struct file *filep, int cmd, unsigned long arg)
|
||||||
{
|
{
|
||||||
@ -2437,15 +2437,13 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg)
|
|||||||
|
|
||||||
if ((arg & SER_SINGLEWIRE_ENABLED) != 0)
|
if ((arg & SER_SINGLEWIRE_ENABLED) != 0)
|
||||||
{
|
{
|
||||||
uint32_t gpio_val = (arg & SER_SINGLEWIRE_PUSHPULL) ==
|
uint32_t gpio_val = (arg & SER_SINGLEWIRE_PUSHPULL) == SER_SINGLEWIRE_PUSHPULL ?
|
||||||
SER_SINGLEWIRE_PUSHPULL ?
|
GPIO_PUSHPULL : GPIO_OPENDRAIN;
|
||||||
GPIO_PUSHPULL : GPIO_OPENDRAIN;
|
gpio_val |= (arg & SER_SINGLEWIRE_PULL_MASK) == SER_SINGLEWIRE_PULLUP ?
|
||||||
gpio_val |= (arg & SER_SINGLEWIRE_PULL_MASK) ==
|
GPIO_PULLUP : GPIO_FLOAT;
|
||||||
SER_SINGLEWIRE_PULLUP ? GPIO_PULLUP : GPIO_FLOAT;
|
gpio_val |= (arg & SER_SINGLEWIRE_PULL_MASK) == SER_SINGLEWIRE_PULLDOWN ?
|
||||||
gpio_val |= (arg & SER_SINGLEWIRE_PULL_MASK) ==
|
GPIO_PULLDOWN : GPIO_FLOAT;
|
||||||
SER_SINGLEWIRE_PULLDOWN ? GPIO_PULLDOWN : GPIO_FLOAT;
|
stm32_configgpio((priv->tx_gpio & ~(GPIO_PUPD_MASK | GPIO_OPENDRAIN)) | gpio_val);
|
||||||
stm32_configgpio((priv->tx_gpio &
|
|
||||||
~(GPIO_PUPD_MASK | GPIO_OPENDRAIN)) | gpio_val);
|
|
||||||
cr |= USART_CR3_HDSEL;
|
cr |= USART_CR3_HDSEL;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -2733,7 +2731,7 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/**************************************************************************************************
|
||||||
* Name: up_receive
|
* Name: up_receive
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
@ -2741,7 +2739,7 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg)
|
|||||||
* character from the USART. Error bits associated with the
|
* character from the USART. Error bits associated with the
|
||||||
* receipt are provided in the return 'status'.
|
* receipt are provided in the return 'status'.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
**************************************************************************************************/
|
||||||
|
|
||||||
#ifndef SERIAL_HAVE_ONLY_RXDMA
|
#ifndef SERIAL_HAVE_ONLY_RXDMA
|
||||||
static int up_receive(struct uart_dev_s *dev, unsigned int *status)
|
static int up_receive(struct uart_dev_s *dev, unsigned int *status)
|
||||||
@ -2764,13 +2762,13 @@ static int up_receive(struct uart_dev_s *dev, unsigned int *status)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/**************************************************************************************************
|
||||||
* Name: up_rxint
|
* Name: up_rxint
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Call to enable or disable RX interrupts
|
* Call to enable or disable RX interrupts
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
**************************************************************************************************/
|
||||||
|
|
||||||
#ifndef SERIAL_HAVE_ONLY_RXDMA
|
#ifndef SERIAL_HAVE_ONLY_RXDMA
|
||||||
static void up_rxint(struct uart_dev_s *dev, bool enable)
|
static void up_rxint(struct uart_dev_s *dev, bool enable)
|
||||||
@ -2822,13 +2820,13 @@ static void up_rxint(struct uart_dev_s *dev, bool enable)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/**************************************************************************************************
|
||||||
* Name: up_rxavailable
|
* Name: up_rxavailable
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Return true if the receive register is not empty
|
* Return true if the receive register is not empty
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
**************************************************************************************************/
|
||||||
|
|
||||||
#ifndef SERIAL_HAVE_ONLY_RXDMA
|
#ifndef SERIAL_HAVE_ONLY_RXDMA
|
||||||
static bool up_rxavailable(struct uart_dev_s *dev)
|
static bool up_rxavailable(struct uart_dev_s *dev)
|
||||||
@ -2838,7 +2836,7 @@ static bool up_rxavailable(struct uart_dev_s *dev)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/**************************************************************************************************
|
||||||
* Name: up_rxflowcontrol
|
* Name: up_rxflowcontrol
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
@ -2859,7 +2857,7 @@ static bool up_rxavailable(struct uart_dev_s *dev)
|
|||||||
* Returned Value:
|
* Returned Value:
|
||||||
* true if RX flow control activated.
|
* true if RX flow control activated.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
**************************************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_SERIAL_IFLOWCONTROL
|
#ifdef CONFIG_SERIAL_IFLOWCONTROL
|
||||||
static bool up_rxflowcontrol(struct uart_dev_s *dev,
|
static bool up_rxflowcontrol(struct uart_dev_s *dev,
|
||||||
@ -2934,7 +2932,7 @@ static bool up_rxflowcontrol(struct uart_dev_s *dev,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/**************************************************************************************************
|
||||||
* Name: up_dma_receive
|
* Name: up_dma_receive
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
@ -2942,7 +2940,7 @@ static bool up_rxflowcontrol(struct uart_dev_s *dev,
|
|||||||
* character from the USART. Error bits associated with the
|
* character from the USART. Error bits associated with the
|
||||||
* receipt are provided in the return 'status'.
|
* receipt are provided in the return 'status'.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
**************************************************************************************************/
|
||||||
|
|
||||||
#ifdef SERIAL_HAVE_RXDMA
|
#ifdef SERIAL_HAVE_RXDMA
|
||||||
static int up_dma_receive(struct uart_dev_s *dev, unsigned int *status)
|
static int up_dma_receive(struct uart_dev_s *dev, unsigned int *status)
|
||||||
@ -3019,13 +3017,13 @@ static int up_dma_receive(struct uart_dev_s *dev, unsigned int *status)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/**************************************************************************************************
|
||||||
* Name: up_dma_reenable
|
* Name: up_dma_reenable
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Call to re-enable RX DMA.
|
* Call to re-enable RX DMA.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
**************************************************************************************************/
|
||||||
|
|
||||||
#if defined(SERIAL_HAVE_RXDMA) && defined(CONFIG_PM)
|
#if defined(SERIAL_HAVE_RXDMA) && defined(CONFIG_PM)
|
||||||
static void up_dma_reenable(struct up_dev_s *priv)
|
static void up_dma_reenable(struct up_dev_s *priv)
|
||||||
@ -3060,13 +3058,13 @@ static void up_dma_reenable(struct up_dev_s *priv)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/**************************************************************************************************
|
||||||
* Name: up_dma_rxint
|
* Name: up_dma_rxint
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Call to enable or disable RX interrupts
|
* Call to enable or disable RX interrupts
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
**************************************************************************************************/
|
||||||
|
|
||||||
#ifdef SERIAL_HAVE_RXDMA
|
#ifdef SERIAL_HAVE_RXDMA
|
||||||
static void up_dma_rxint(struct uart_dev_s *dev, bool enable)
|
static void up_dma_rxint(struct uart_dev_s *dev, bool enable)
|
||||||
@ -3085,13 +3083,13 @@ static void up_dma_rxint(struct uart_dev_s *dev, bool enable)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/**************************************************************************************************
|
||||||
* Name: up_dma_rxavailable
|
* Name: up_dma_rxavailable
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Return true if the receive register is not empty
|
* Return true if the receive register is not empty
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
**************************************************************************************************/
|
||||||
|
|
||||||
#ifdef SERIAL_HAVE_RXDMA
|
#ifdef SERIAL_HAVE_RXDMA
|
||||||
static bool up_dma_rxavailable(struct uart_dev_s *dev)
|
static bool up_dma_rxavailable(struct uart_dev_s *dev)
|
||||||
@ -3106,14 +3104,14 @@ static bool up_dma_rxavailable(struct uart_dev_s *dev)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/**************************************************************************************************
|
||||||
* Name: up_dma_txcallback
|
* Name: up_dma_txcallback
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* This function clears dma buffer at complete of DMA transfer and wakes up
|
* This function clears dma buffer at complete of DMA transfer and wakes up
|
||||||
* threads waiting for space in buffer.
|
* threads waiting for space in buffer.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
**************************************************************************************************/
|
||||||
|
|
||||||
#ifdef SERIAL_HAVE_TXDMA
|
#ifdef SERIAL_HAVE_TXDMA
|
||||||
static void up_dma_txcallback(DMA_HANDLE handle, uint8_t status, void *arg)
|
static void up_dma_txcallback(DMA_HANDLE handle, uint8_t status, void *arg)
|
||||||
@ -3143,13 +3141,13 @@ static void up_dma_txcallback(DMA_HANDLE handle, uint8_t status, void *arg)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/**************************************************************************************************
|
||||||
* Name: up_dma_txavailable
|
* Name: up_dma_txavailable
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Informs DMA that Tx data is available and is ready for transfer.
|
* Informs DMA that Tx data is available and is ready for transfer.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
**************************************************************************************************/
|
||||||
|
|
||||||
#ifdef SERIAL_HAVE_TXDMA
|
#ifdef SERIAL_HAVE_TXDMA
|
||||||
static void up_dma_txavailable(struct uart_dev_s *dev)
|
static void up_dma_txavailable(struct uart_dev_s *dev)
|
||||||
@ -3165,14 +3163,14 @@ static void up_dma_txavailable(struct uart_dev_s *dev)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/**************************************************************************************************
|
||||||
* Name: up_dma_send
|
* Name: up_dma_send
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Called (usually) from the interrupt level to start DMA transfer.
|
* Called (usually) from the interrupt level to start DMA transfer.
|
||||||
* (Re-)Configures DMA Stream updating buffer and buffer length.
|
* (Re-)Configures DMA Stream updating buffer and buffer length.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
**************************************************************************************************/
|
||||||
|
|
||||||
#ifdef SERIAL_HAVE_TXDMA
|
#ifdef SERIAL_HAVE_TXDMA
|
||||||
static void up_dma_send(struct uart_dev_s *dev)
|
static void up_dma_send(struct uart_dev_s *dev)
|
||||||
@ -3206,13 +3204,13 @@ static void up_dma_send(struct uart_dev_s *dev)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/**************************************************************************************************
|
||||||
* Name: up_send
|
* Name: up_send
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* This method will send one byte on the USART
|
* This method will send one byte on the USART
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
**************************************************************************************************/
|
||||||
|
|
||||||
static void up_send(struct uart_dev_s *dev, int ch)
|
static void up_send(struct uart_dev_s *dev, int ch)
|
||||||
{
|
{
|
||||||
@ -3228,13 +3226,13 @@ static void up_send(struct uart_dev_s *dev, int ch)
|
|||||||
up_serialout(priv, STM32_USART_TDR_OFFSET, (uint32_t)ch);
|
up_serialout(priv, STM32_USART_TDR_OFFSET, (uint32_t)ch);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/**************************************************************************************************
|
||||||
* Name: up_dma_txint
|
* Name: up_dma_txint
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Call to enable or disable TX interrupts from the UART.
|
* Call to enable or disable TX interrupts from the UART.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
**************************************************************************************************/
|
||||||
|
|
||||||
#ifdef SERIAL_HAVE_TXDMA
|
#ifdef SERIAL_HAVE_TXDMA
|
||||||
static void up_dma_txint(struct uart_dev_s *dev, bool enable)
|
static void up_dma_txint(struct uart_dev_s *dev, bool enable)
|
||||||
@ -3250,13 +3248,13 @@ static void up_dma_txint(struct uart_dev_s *dev, bool enable)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/**************************************************************************************************
|
||||||
* Name: up_txint
|
* Name: up_txint
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Call to enable or disable TX interrupts
|
* Call to enable or disable TX interrupts
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
**************************************************************************************************/
|
||||||
|
|
||||||
static void up_txint(struct uart_dev_s *dev, bool enable)
|
static void up_txint(struct uart_dev_s *dev, bool enable)
|
||||||
{
|
{
|
||||||
@ -3317,13 +3315,13 @@ static void up_txint(struct uart_dev_s *dev, bool enable)
|
|||||||
leave_critical_section(flags);
|
leave_critical_section(flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/**************************************************************************************************
|
||||||
* Name: up_txready
|
* Name: up_txready
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Return true if the transmit data register is empty
|
* Return true if the transmit data register is empty
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
**************************************************************************************************/
|
||||||
|
|
||||||
static bool up_txready(struct uart_dev_s *dev)
|
static bool up_txready(struct uart_dev_s *dev)
|
||||||
{
|
{
|
||||||
@ -3331,14 +3329,14 @@ static bool up_txready(struct uart_dev_s *dev)
|
|||||||
return ((up_serialin(priv, STM32_USART_ISR_OFFSET) & USART_ISR_TXE) != 0);
|
return ((up_serialin(priv, STM32_USART_ISR_OFFSET) & USART_ISR_TXE) != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/**************************************************************************************************
|
||||||
* Name: up_dma_rxcallback
|
* Name: up_dma_rxcallback
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* This function checks the current DMA state and calls the generic
|
* This function checks the current DMA state and calls the generic
|
||||||
* serial stack when bytes appear to be available.
|
* serial stack when bytes appear to be available.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
**************************************************************************************************/
|
||||||
|
|
||||||
#ifdef SERIAL_HAVE_RXDMA
|
#ifdef SERIAL_HAVE_RXDMA
|
||||||
static void up_dma_rxcallback(DMA_HANDLE handle, uint8_t status, void *arg)
|
static void up_dma_rxcallback(DMA_HANDLE handle, uint8_t status, void *arg)
|
||||||
@ -3370,7 +3368,7 @@ static void up_dma_rxcallback(DMA_HANDLE handle, uint8_t status, void *arg)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/**************************************************************************************************
|
||||||
* Name: up_pm_notify
|
* Name: up_pm_notify
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
@ -3390,7 +3388,7 @@ static void up_dma_rxcallback(DMA_HANDLE handle, uint8_t status, void *arg)
|
|||||||
* consumption state when when it returned OK to the prepare() call.
|
* consumption state when when it returned OK to the prepare() call.
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
**************************************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_PM
|
#ifdef CONFIG_PM
|
||||||
static void up_pm_notify(struct pm_callback_s *cb, int domain,
|
static void up_pm_notify(struct pm_callback_s *cb, int domain,
|
||||||
@ -3431,7 +3429,7 @@ static void up_pm_notify(struct pm_callback_s *cb, int domain,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/**************************************************************************************************
|
||||||
* Name: up_pm_prepare
|
* Name: up_pm_prepare
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
@ -3462,7 +3460,7 @@ static void up_pm_notify(struct pm_callback_s *cb, int domain,
|
|||||||
* return non-zero values when reverting back to higher power
|
* return non-zero values when reverting back to higher power
|
||||||
* consumption modes!
|
* consumption modes!
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
**************************************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_PM
|
#ifdef CONFIG_PM
|
||||||
static int up_pm_prepare(struct pm_callback_s *cb, int domain,
|
static int up_pm_prepare(struct pm_callback_s *cb, int domain,
|
||||||
@ -3545,13 +3543,13 @@ static int up_pm_prepare(struct pm_callback_s *cb, int domain,
|
|||||||
#endif /* HAVE_UART */
|
#endif /* HAVE_UART */
|
||||||
#endif /* USE_SERIALDRIVER */
|
#endif /* USE_SERIALDRIVER */
|
||||||
|
|
||||||
/****************************************************************************
|
/**************************************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
**************************************************************************************************/
|
||||||
|
|
||||||
#ifdef USE_SERIALDRIVER
|
#ifdef USE_SERIALDRIVER
|
||||||
|
|
||||||
/****************************************************************************
|
/**************************************************************************************************
|
||||||
* Name: arm_earlyserialinit
|
* Name: arm_earlyserialinit
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
@ -3559,7 +3557,7 @@ static int up_pm_prepare(struct pm_callback_s *cb, int domain,
|
|||||||
* serial console will be available during bootup. This must be called
|
* serial console will be available during bootup. This must be called
|
||||||
* before arm_serialinit.
|
* before arm_serialinit.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
**************************************************************************************************/
|
||||||
|
|
||||||
#ifdef USE_EARLYSERIALINIT
|
#ifdef USE_EARLYSERIALINIT
|
||||||
void arm_earlyserialinit(void)
|
void arm_earlyserialinit(void)
|
||||||
@ -3586,14 +3584,14 @@ void arm_earlyserialinit(void)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/**************************************************************************************************
|
||||||
* Name: arm_serialinit
|
* Name: arm_serialinit
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Register serial console and serial ports. This assumes
|
* Register serial console and serial ports. This assumes
|
||||||
* that arm_earlyserialinit was called previously.
|
* that arm_earlyserialinit was called previously.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
**************************************************************************************************/
|
||||||
|
|
||||||
void arm_serialinit(void)
|
void arm_serialinit(void)
|
||||||
{
|
{
|
||||||
@ -3673,7 +3671,7 @@ void arm_serialinit(void)
|
|||||||
#endif /* HAVE UART */
|
#endif /* HAVE UART */
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/**************************************************************************************************
|
||||||
* Name: stm32_serial_dma_poll
|
* Name: stm32_serial_dma_poll
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
@ -3682,7 +3680,7 @@ void arm_serialinit(void)
|
|||||||
*
|
*
|
||||||
* This function should be called from a timer or other periodic context.
|
* This function should be called from a timer or other periodic context.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
**************************************************************************************************/
|
||||||
|
|
||||||
#ifdef SERIAL_HAVE_RXDMA
|
#ifdef SERIAL_HAVE_RXDMA
|
||||||
void stm32_serial_dma_poll(void)
|
void stm32_serial_dma_poll(void)
|
||||||
@ -3751,13 +3749,13 @@ void stm32_serial_dma_poll(void)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/**************************************************************************************************
|
||||||
* Name: up_putc
|
* Name: up_putc
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Provide priority, low-level access to support OS debug writes
|
* Provide priority, low-level access to support OS debug writes
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
**************************************************************************************************/
|
||||||
|
|
||||||
int up_putc(int ch)
|
int up_putc(int ch)
|
||||||
{
|
{
|
||||||
@ -3784,13 +3782,13 @@ int up_putc(int ch)
|
|||||||
|
|
||||||
#else /* USE_SERIALDRIVER */
|
#else /* USE_SERIALDRIVER */
|
||||||
|
|
||||||
/****************************************************************************
|
/**************************************************************************************************
|
||||||
* Name: up_putc
|
* Name: up_putc
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Provide priority, low-level access to support OS debug writes
|
* Provide priority, low-level access to support OS debug writes
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
**************************************************************************************************/
|
||||||
|
|
||||||
int up_putc(int ch)
|
int up_putc(int ch)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user