stm32f7: serial: add interface to get uart_dev_t by USART number, stm32_serial_get_uart
This commit is contained in:
parent
95941b4908
commit
e180522854
@ -228,6 +228,10 @@ struct up_dev_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.
|
||||||
*/
|
*/
|
||||||
@ -1460,6 +1464,11 @@ static int up_setup(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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1539,6 +1548,10 @@ static void up_shutdown(struct uart_dev_s *dev)
|
|||||||
struct up_dev_s *priv = (struct up_dev_s *)dev->priv;
|
struct up_dev_s *priv = (struct up_dev_s *)dev->priv;
|
||||||
uint32_t regval;
|
uint32_t regval;
|
||||||
|
|
||||||
|
/* Mark device as uninitialized. */
|
||||||
|
|
||||||
|
priv->initialized = false;
|
||||||
|
|
||||||
/* Disable all interrupts */
|
/* Disable all interrupts */
|
||||||
|
|
||||||
up_disableusartint(priv, NULL);
|
up_disableusartint(priv, NULL);
|
||||||
@ -2529,6 +2542,31 @@ static int up_pm_prepare(struct pm_callback_s *cb, int domain,
|
|||||||
|
|
||||||
#ifdef USE_SERIALDRIVER
|
#ifdef USE_SERIALDRIVER
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: stm32_serial_get_uart
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Get serial driver structure for STM32 USART
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
FAR uart_dev_t *stm32_serial_get_uart(int uart_num)
|
||||||
|
{
|
||||||
|
int uart_idx = uart_num - 1;
|
||||||
|
|
||||||
|
if (uart_idx < 0 || uart_idx >= STM32_NSERIAL || !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
|
||||||
*
|
*
|
||||||
|
@ -41,6 +41,7 @@
|
|||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
#include <nuttx/serial/serial.h>
|
||||||
|
|
||||||
#include "chip/stm32_uart.h"
|
#include "chip/stm32_uart.h"
|
||||||
|
|
||||||
@ -319,6 +320,16 @@ extern "C"
|
|||||||
* Public Functions
|
* Public Functions
|
||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
|
|
||||||
|
/************************************************************************************
|
||||||
|
* Name: stm32_serial_get_uart
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Get serial driver structure for STM32 USART
|
||||||
|
*
|
||||||
|
************************************************************************************/
|
||||||
|
|
||||||
|
FAR uart_dev_t *stm32_serial_get_uart(int uart_num);
|
||||||
|
|
||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* Name: stm32_serial_dma_poll
|
* Name: stm32_serial_dma_poll
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user