[Bsp][stm32f4xx-hal]更新串口宏

This commit is contained in:
ZYH 2018-10-11 18:09:31 +08:00
parent d7b70ee9b0
commit bcfba031d5
2 changed files with 26 additions and 21 deletions

View File

@ -297,20 +297,24 @@ config RT_HSE_VALUE
config RT_HSE_HCLK config RT_HSE_HCLK
int "System Clock Value" int "System Clock Value"
default 84000000 default 84000000
config RT_USING_UART1 config BSP_USING_UART1
bool "Using UART1" bool "Using UART1"
select RT_USING_SERIAL
default y default y
config RT_USING_UART2 config BSP_USING_UART2
bool "Using UART2" bool "Using UART2"
select RT_USING_SERIAL
default n default n
config RT_USING_UART3 config BSP_USING_UART3
bool "Using UART3" bool "Using UART3"
select RT_USING_SERIAL
default n default n
config RT_USING_UART6 config BSP_USING_UART6
bool "Using UART6" bool "Using UART6"
select RT_USING_SERIAL
default n default n
if RT_USING_CAN if RT_USING_CAN

View File

@ -147,7 +147,7 @@ static const struct rt_uart_ops drv_uart_ops =
drv_getc, drv_getc,
}; };
#if defined(RT_USING_UART1) #if defined(BSP_USING_UART1)
/* UART1 device driver structure */ /* UART1 device driver structure */
static struct drv_uart uart1; static struct drv_uart uart1;
struct rt_serial_device serial1; struct rt_serial_device serial1;
@ -168,9 +168,9 @@ void USART1_IRQHandler(void)
/* leave interrupt */ /* leave interrupt */
rt_interrupt_leave(); rt_interrupt_leave();
} }
#endif /* RT_USING_UART1 */ #endif /* BSP_USING_UART1 */
#if defined(RT_USING_UART2) #if defined(BSP_USING_UART2)
/* UART2 device driver structure */ /* UART2 device driver structure */
static struct drv_uart uart2; static struct drv_uart uart2;
struct rt_serial_device serial2; struct rt_serial_device serial2;
@ -191,9 +191,9 @@ void USART2_IRQHandler(void)
/* leave interrupt */ /* leave interrupt */
rt_interrupt_leave(); rt_interrupt_leave();
} }
#endif /* RT_USING_UART2 */ #endif /* BSP_USING_UART2 */
#if defined(RT_USING_UART3) #if defined(BSP_USING_UART3)
/* UART3 device driver structure */ /* UART3 device driver structure */
static struct drv_uart uart3; static struct drv_uart uart3;
struct rt_serial_device serial3; struct rt_serial_device serial3;
@ -214,9 +214,9 @@ void USART3_IRQHandler(void)
/* leave interrupt */ /* leave interrupt */
rt_interrupt_leave(); rt_interrupt_leave();
} }
#endif /* RT_USING_UART3 */ #endif /* BSP_USING_UART3 */
#if defined(RT_USING_UART6) #if defined(BSP_USING_UART6)
/* UART6 device driver structure */ /* UART6 device driver structure */
static struct drv_uart uart6; static struct drv_uart uart6;
struct rt_serial_device serial6; struct rt_serial_device serial6;
@ -237,7 +237,7 @@ void USART6_IRQHandler(void)
/* leave interrupt */ /* leave interrupt */
rt_interrupt_leave(); rt_interrupt_leave();
} }
#endif /* RT_USING_UART6 */ #endif /* BSP_USING_UART6 */
/** /**
* @brief UART MSP Initialization * @brief UART MSP Initialization
@ -365,7 +365,7 @@ int hw_usart_init(void)
{ {
struct drv_uart *uart; struct drv_uart *uart;
struct serial_configure config = RT_SERIAL_CONFIG_DEFAULT; struct serial_configure config = RT_SERIAL_CONFIG_DEFAULT;
#ifdef RT_USING_UART1 #ifdef BSP_USING_UART1
uart = &uart1; uart = &uart1;
uart->UartHandle.Instance = USART1; uart->UartHandle.Instance = USART1;
uart->irq = USART1_IRQn; uart->irq = USART1_IRQn;
@ -375,8 +375,8 @@ int hw_usart_init(void)
rt_hw_serial_register(&serial1, "uart1", rt_hw_serial_register(&serial1, "uart1",
RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX, RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX,
uart); uart);
#endif /* RT_USING_UART1 */ #endif /* BSP_USING_UART1 */
#ifdef RT_USING_UART2 #ifdef BSP_USING_UART2
uart = &uart2; uart = &uart2;
uart->UartHandle.Instance = USART2; uart->UartHandle.Instance = USART2;
uart->irq = USART2_IRQn; uart->irq = USART2_IRQn;
@ -386,8 +386,8 @@ int hw_usart_init(void)
rt_hw_serial_register(&serial2, "uart2", rt_hw_serial_register(&serial2, "uart2",
RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX, RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX,
uart); uart);
#endif /* RT_USING_UART2 */ #endif /* BSP_USING_UART2 */
#ifdef RT_USING_UART3 #ifdef BSP_USING_UART3
uart = &uart3; uart = &uart3;
uart->UartHandle.Instance = USART3; uart->UartHandle.Instance = USART3;
uart->irq = USART3_IRQn; uart->irq = USART3_IRQn;
@ -397,18 +397,19 @@ int hw_usart_init(void)
rt_hw_serial_register(&serial3, "uart3", rt_hw_serial_register(&serial3, "uart3",
RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX, RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX,
uart); uart);
#endif /* RT_USING_UART3 */ #endif /* BSP_USING_UART3 */
#ifdef RT_USING_UART6 #ifdef BSP_USING_UART6
uart = &uart6; uart = &uart6;
uart->UartHandle.Instance = USART6; uart->UartHandle.Instance = USART6;
uart->irq = USART6_IRQn; uart->irq = USART6_IRQn;
serial6.ops = &drv_uart_ops; serial6.ops = &drv_uart_ops;
serial6.config = config; serial6.config = config;
/* register UART2 device */ /* register UART6 device */
rt_hw_serial_register(&serial6, "uart6", rt_hw_serial_register(&serial6, "uart6",
RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX, RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX,
uart); uart);
#endif /* RT_USING_UART6 */ #endif /* BSP_USING_UART6 */
return 0; return 0;
} }
INIT_BOARD_EXPORT(hw_usart_init); INIT_BOARD_EXPORT(hw_usart_init);