mirror of
https://github.com/apache/nuttx.git
synced 2026-05-28 11:56:10 +08:00
Merged in juniskane/nuttx_stm32l4/stm32l4_serial_pr (pull request #365)
STM32L4: port stm32l4_serial_get_uart function from STM32F7 Approved-by: Gregory Nutt <gnutt@nuttx.org>
This commit is contained in:
@@ -200,6 +200,10 @@ struct stm32l4_serial_s
|
|||||||
uint16_t ie; /* Saved interrupt mask bits value */
|
uint16_t ie; /* Saved interrupt mask bits value */
|
||||||
uint16_t sr; /* Saved status bits */
|
uint16_t sr; /* Saved status bits */
|
||||||
|
|
||||||
|
/* Has been initialized and HW is setup. */
|
||||||
|
|
||||||
|
bool initialized;
|
||||||
|
|
||||||
/* If termios are supported, then the following fields may vary at
|
/* If termios are supported, then the following fields may vary at
|
||||||
* runtime.
|
* runtime.
|
||||||
*/
|
*/
|
||||||
@@ -1169,6 +1173,11 @@ static int stm32l4serial_setup(FAR struct uart_dev_s *dev)
|
|||||||
/* Set up the cached interrupt enables value */
|
/* Set up the cached interrupt enables value */
|
||||||
|
|
||||||
priv->ie = 0;
|
priv->ie = 0;
|
||||||
|
|
||||||
|
/* Mark device as initialized. */
|
||||||
|
|
||||||
|
priv->initialized = true;
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1279,6 +1288,10 @@ static void stm32l4serial_shutdown(FAR struct uart_dev_s *dev)
|
|||||||
FAR struct stm32l4_serial_s *priv = (FAR struct stm32l4_serial_s *)dev->priv;
|
FAR struct stm32l4_serial_s *priv = (FAR struct stm32l4_serial_s *)dev->priv;
|
||||||
uint32_t regval;
|
uint32_t regval;
|
||||||
|
|
||||||
|
/* Mark device as uninitialized. */
|
||||||
|
|
||||||
|
priv->initialized = false;
|
||||||
|
|
||||||
/* Disable all interrupts */
|
/* Disable all interrupts */
|
||||||
|
|
||||||
stm32l4serial_disableusartint(priv, NULL);
|
stm32l4serial_disableusartint(priv, NULL);
|
||||||
@@ -2327,6 +2340,32 @@ static int stm32l4serial_pmprepare(FAR struct pm_callback_s *cb, int domain,
|
|||||||
|
|
||||||
#ifdef USE_SERIALDRIVER
|
#ifdef USE_SERIALDRIVER
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: stm32l4_serial_get_uart
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Get serial driver structure for STM32 USART
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
FAR uart_dev_t *stm32l4_serial_get_uart(int uart_num)
|
||||||
|
{
|
||||||
|
int uart_idx = uart_num - 1;
|
||||||
|
|
||||||
|
if (uart_idx < 0 || uart_idx >= STM32L4_NUSART+STM32L4_NUART || \
|
||||||
|
!uart_devs[uart_idx])
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!uart_devs[uart_idx]->initialized)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return &uart_devs[uart_idx]->dev;
|
||||||
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: up_earlyserialinit
|
* Name: up_earlyserialinit
|
||||||
*
|
*
|
||||||
@@ -2360,10 +2399,10 @@ void up_earlyserialinit(void)
|
|||||||
#endif
|
#endif
|
||||||
#endif /* HAVE UART */
|
#endif /* HAVE UART */
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* USE_EARLYSERIALINIT */
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: stm32l4serial_getregit
|
* Name: up_serialinit
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Register serial console and serial ports. This assumes
|
* Register serial console and serial ports. This assumes
|
||||||
@@ -2441,7 +2480,7 @@ void up_serialinit(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: stm32l4serial_dmapoll
|
* Name: stm32l4_serial_dma_poll
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Checks receive DMA buffers for received bytes that have not accumulated
|
* Checks receive DMA buffers for received bytes that have not accumulated
|
||||||
@@ -2452,7 +2491,7 @@ void up_serialinit(void)
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef SERIAL_HAVE_DMA
|
#ifdef SERIAL_HAVE_DMA
|
||||||
void stm32l4serial_dmapoll(void)
|
void stm32l4_serial_dma_poll(void)
|
||||||
{
|
{
|
||||||
irqstate_t flags;
|
irqstate_t flags;
|
||||||
|
|
||||||
|
|||||||
@@ -41,6 +41,7 @@
|
|||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
#include <nuttx/serial/serial.h>
|
||||||
|
|
||||||
#include "chip.h"
|
#include "chip.h"
|
||||||
|
|
||||||
@@ -236,6 +237,16 @@ extern "C"
|
|||||||
* Public Functions
|
* Public Functions
|
||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
|
|
||||||
|
/************************************************************************************
|
||||||
|
* Name: stm32l4_serial_get_uart
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Get serial driver structure for STM32 USART
|
||||||
|
*
|
||||||
|
************************************************************************************/
|
||||||
|
|
||||||
|
FAR uart_dev_t *stm32l4_serial_get_uart(int uart_num);
|
||||||
|
|
||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* Name: stm32l4_serial_dma_poll
|
* Name: stm32l4_serial_dma_poll
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user