From 49c39d4a8d0b7bf6ba2f56bda34f00fe898aca09 Mon Sep 17 00:00:00 2001 From: Rbb666 Date: Fri, 13 Sep 2024 15:31:32 +0800 Subject: [PATCH] [bsp][gd32]Fix the problem that uartv2 does not enable dma compilation error. --- bsp/gd32/arm/libraries/gd32_drivers/drv_usart_v2.c | 9 +++------ bsp/gd32/arm/libraries/gd32_drivers/drv_usart_v2.h | 2 +- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/bsp/gd32/arm/libraries/gd32_drivers/drv_usart_v2.c b/bsp/gd32/arm/libraries/gd32_drivers/drv_usart_v2.c index f1edc7c462..4412875a8e 100644 --- a/bsp/gd32/arm/libraries/gd32_drivers/drv_usart_v2.c +++ b/bsp/gd32/arm/libraries/gd32_drivers/drv_usart_v2.c @@ -878,9 +878,8 @@ static void gd32_dma_config (struct rt_serial_device *serial, rt_ubase_t flag) static rt_err_t gd32_uart_control (struct rt_serial_device *serial, int cmd, void *arg) { struct gd32_uart *uart; -#ifdef RT_SERIAL_USING_DMA + rt_ubase_t ctrl_arg = (rt_ubase_t)arg; -#endif RT_ASSERT(serial != RT_NULL); uart = rt_container_of(serial, struct gd32_uart, serial); @@ -1027,8 +1026,10 @@ static rt_ssize_t gd32_transmit (struct rt_serial_device *serial, rt_uint8_t *bu if (uart->uart_dma_flag & RT_DEVICE_FLAG_DMA_TX) { +#ifdef RT_SERIAL_USING_DMA _uart_dma_transmit(uart, buf, size); return size; +#endif } gd32_uart_control(serial, RT_DEVICE_CTRL_SET_INT, (void *)tx_flag); @@ -1041,11 +1042,7 @@ static const struct rt_uart_ops gd32_uart_ops = .control = gd32_uart_control, .putc = gd32_uart_putc, .getc = gd32_uart_getc, -#ifdef RT_SERIAL_USING_DMA .transmit = gd32_transmit, -#else - .transmit = RT_NULL, -#endif }; static void gd32_uart_get_config (void) diff --git a/bsp/gd32/arm/libraries/gd32_drivers/drv_usart_v2.h b/bsp/gd32/arm/libraries/gd32_drivers/drv_usart_v2.h index 5b6c9026f6..6580791c05 100644 --- a/bsp/gd32/arm/libraries/gd32_drivers/drv_usart_v2.h +++ b/bsp/gd32/arm/libraries/gd32_drivers/drv_usart_v2.h @@ -52,8 +52,8 @@ struct gd32_uart rt_size_t last_index; rt_sem_t sem_ftf; } dma; - rt_uint16_t uart_dma_flag; #endif + rt_uint16_t uart_dma_flag; }; int rt_hw_usart_init(void);