From e0f61010e2388147f087d97d9d01b247f01ba4c4 Mon Sep 17 00:00:00 2001 From: Freey0 Date: Fri, 2 Sep 2022 14:40:57 +0800 Subject: [PATCH] fix: Fix accidentally close PDMA used by other devices when close the serial port --- bsp/nuvoton/libraries/nuc980/rtt_port/drv_uart.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bsp/nuvoton/libraries/nuc980/rtt_port/drv_uart.c b/bsp/nuvoton/libraries/nuc980/rtt_port/drv_uart.c index fbafecee55..cb94bf8097 100644 --- a/bsp/nuvoton/libraries/nuc980/rtt_port/drv_uart.c +++ b/bsp/nuvoton/libraries/nuc980/rtt_port/drv_uart.c @@ -803,8 +803,10 @@ static rt_err_t nu_uart_control(struct rt_serial_device *serial, int cmd, void * rt_hw_interrupt_mask(psNuUart->irqn); #if defined(RT_SERIAL_USING_DMA) - nu_pdma_channel_terminate(psNuUart->pdma_chanid_tx); - nu_pdma_channel_terminate(psNuUart->pdma_chanid_rx); + if (psNuUart->dma_flag != 0) { + nu_pdma_channel_terminate(psNuUart->pdma_chanid_tx); + nu_pdma_channel_terminate(psNuUart->pdma_chanid_rx); + } #endif /* Close UART port */