From 1131f6e6483d8f2fbafe07f4e598fc8f802ee85d Mon Sep 17 00:00:00 2001 From: Huaqi Fang <578567190@qq.com> Date: Wed, 8 Apr 2020 18:37:24 +0800 Subject: [PATCH] nuclei: update kconfig Signed-off-by: Huaqi Fang <578567190@qq.com> --- bsp/nuclei/gd32vf103/.config | 6 ++- bsp/nuclei/gd32vf103/board/Kconfig | 18 +++++-- bsp/nuclei/gd32vf103/drivers/drv_usart.c | 66 ++++++++++++++++++++++-- bsp/nuclei/gd32vf103/rtconfig.h | 2 +- 4 files changed, 84 insertions(+), 8 deletions(-) diff --git a/bsp/nuclei/gd32vf103/.config b/bsp/nuclei/gd32vf103/.config index faef6ecbb4..9b8584f97b 100644 --- a/bsp/nuclei/gd32vf103/.config +++ b/bsp/nuclei/gd32vf103/.config @@ -435,12 +435,16 @@ CONFIG_SOC_GD32VF103V=y # # Onboard Peripheral Drivers # -CONFIG_BSP_USING_USART=y +CONFIG_BSP_USING_UART_CONSOLE=y # # On-chip Peripheral Drivers # CONFIG_BSP_USING_UART=y +# CONFIG_BSP_USING_UART0 is not set +# CONFIG_BSP_USING_UART1 is not set +# CONFIG_BSP_USING_UART2 is not set +# CONFIG_BSP_USING_UART3 is not set CONFIG_BSP_USING_UART4=y # diff --git a/bsp/nuclei/gd32vf103/board/Kconfig b/bsp/nuclei/gd32vf103/board/Kconfig index e068bca057..7e18407b7f 100644 --- a/bsp/nuclei/gd32vf103/board/Kconfig +++ b/bsp/nuclei/gd32vf103/board/Kconfig @@ -7,8 +7,8 @@ config SOC_GD32VF103V menu "Onboard Peripheral Drivers" - config BSP_USING_USART - bool "Enable USART (uart4)" + config BSP_USING_UART_CONSOLE + bool "Enable UART CONSOLE" select BSP_USING_UART select BSP_USING_UART4 default y @@ -21,9 +21,21 @@ menu "On-chip Peripheral Drivers" default y select RT_USING_SERIAL if BSP_USING_UART + config BSP_USING_UART0 + bool "Enable UART0" + default n + config BSP_USING_UART1 + bool "Enable UART1" + default n + config BSP_USING_UART2 + bool "Enable UART2" + default n + config BSP_USING_UART3 + bool "Enable UART3" + default n config BSP_USING_UART4 bool "Enable UART4" - default y + default n endif endmenu diff --git a/bsp/nuclei/gd32vf103/drivers/drv_usart.c b/bsp/nuclei/gd32vf103/drivers/drv_usart.c index 18b9c08f99..79e6136166 100644 --- a/bsp/nuclei/gd32vf103/drivers/drv_usart.c +++ b/bsp/nuclei/gd32vf103/drivers/drv_usart.c @@ -14,14 +14,23 @@ #ifdef RT_USING_SERIAL #if !defined(BSP_USING_UART0) && !defined(BSP_USING_UART1) && !defined(BSP_USING_UART2) \ - && !defined(BSP_USING_UART3) && !defined(BSP_USING_UART4) && !defined(BSP_USING_UART5) + && !defined(BSP_USING_UART3) && !defined(BSP_USING_UART4) #error "Please define at least one BSP_USING_UARTx" /* this driver can be disabled at menuconfig -> RT-Thread Components -> Device Drivers */ #endif enum { #ifdef BSP_USING_UART0 - GDUSART0_INDEX, + GDUART0_INDEX, +#endif +#ifdef BSP_USING_UART1 + GDUART1_INDEX, +#endif +#ifdef BSP_USING_UART2 + GDUART2_INDEX, +#endif +#ifdef BSP_USING_UART3 + GDUART3_INDEX, #endif #ifdef BSP_USING_UART4 GDUART4_INDEX, @@ -34,6 +43,21 @@ static struct gd32_uart_config uart_config[] = { USART0, USART0_IRQn, }, #endif +#ifdef BSP_USING_UART1 + { "uart1", + USART1, + USART1_IRQn, }, +#endif +#ifdef BSP_USING_UART2 + { "uart2", + USART2, + USART2_IRQn, }, +#endif +#ifdef BSP_USING_UART3 + { "uart3", + USART3, + USART3_IRQn, }, +#endif #ifdef BSP_USING_UART4 { "uart4", UART4, @@ -202,7 +226,43 @@ static void usart_isr(struct rt_serial_device *serial) { void USART0_IRQHandler(void) { rt_interrupt_enter(); - usart_isr(&uart_obj[GDUSART0_INDEX].serial); + usart_isr(&uart_obj[GDUART0_INDEX].serial); + + rt_interrupt_leave(); +} + +#endif + +#ifdef BSP_USING_UART1 + +void USART1_IRQHandler(void) { + rt_interrupt_enter(); + + usart_isr(&uart_obj[GDUART1_INDEX].serial); + + rt_interrupt_leave(); +} + +#endif + +#ifdef BSP_USING_UART2 + +void USART2_IRQHandler(void) { + rt_interrupt_enter(); + + usart_isr(&uart_obj[GDUART2_INDEX].serial); + + rt_interrupt_leave(); +} + +#endif + +#ifdef BSP_USING_UART3 + +void UART3_IRQHandler(void) { + rt_interrupt_enter(); + + usart_isr(&uart_obj[GDUART3_INDEX].serial); rt_interrupt_leave(); } diff --git a/bsp/nuclei/gd32vf103/rtconfig.h b/bsp/nuclei/gd32vf103/rtconfig.h index 2bcbab6db5..b7b8898186 100644 --- a/bsp/nuclei/gd32vf103/rtconfig.h +++ b/bsp/nuclei/gd32vf103/rtconfig.h @@ -167,7 +167,7 @@ /* Onboard Peripheral Drivers */ -#define BSP_USING_USART +#define BSP_USING_UART_CONSOLE /* On-chip Peripheral Drivers */