From b632dc1aaf2efa4156b87b2d534cf6732010eaee Mon Sep 17 00:00:00 2001 From: Junjie Wang <34395906+WKJay@users.noreply.github.com> Date: Fri, 3 May 2024 06:57:18 +0800 Subject: [PATCH] =?UTF-8?q?[bsp][gd32]=20=E4=BF=AE=E5=A4=8D=E4=B8=B2?= =?UTF-8?q?=E5=8F=A3=E9=A9=B1=E5=8A=A8=E4=B8=AD=E7=94=B1=E4=BA=8E=E5=8F=AF?= =?UTF-8?q?=E8=83=BD=E7=9A=84=E4=B8=AD=E6=96=AD=E5=B5=8C=E5=A5=97=E8=80=8C?= =?UTF-8?q?=E5=AF=BC=E8=87=B4RB=E7=B4=A2=E5=BC=95=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bsp/gd32/arm/libraries/gd32_drivers/drv_usart_v2.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 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 4802a7bb3e5..f1edc7c462e 100644 --- a/bsp/gd32/arm/libraries/gd32_drivers/drv_usart_v2.c +++ b/bsp/gd32/arm/libraries/gd32_drivers/drv_usart_v2.c @@ -233,13 +233,14 @@ static void dma_recv_isr (struct rt_serial_device *serial) { struct gd32_uart *uart; rt_size_t recv_len, counter; + rt_base_t level; RT_ASSERT(serial != RT_NULL); uart = rt_container_of(serial, struct gd32_uart, serial); recv_len = 0; + level = rt_hw_interrupt_disable(); counter = dma_transfer_number_get(uart->dma.rx.periph, uart->dma.rx.channel); - if (counter <= uart->dma.last_index) { recv_len = uart->dma.last_index - counter; @@ -248,10 +249,11 @@ static void dma_recv_isr (struct rt_serial_device *serial) { recv_len = serial->config.rx_bufsz + uart->dma.last_index - counter; } + uart->dma.last_index = counter; + rt_hw_interrupt_enable(level); if (recv_len) { - uart->dma.last_index = counter; rt_hw_serial_isr(serial, RT_SERIAL_EVENT_RX_DMADONE | (recv_len << 8)); } }