From 013caf7c4bc52642b8910bbe3e55954f101a8c32 Mon Sep 17 00:00:00 2001 From: liuchao Date: Sat, 9 Nov 2024 17:17:20 +0800 Subject: [PATCH] [bsp/hc32] fix uart dma if gcc optimization level is not none --- bsp/hc32/libraries/hc32_drivers/drv_usart.c | 2 +- bsp/hc32/libraries/hc32_drivers/drv_usart_v2.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bsp/hc32/libraries/hc32_drivers/drv_usart.c b/bsp/hc32/libraries/hc32_drivers/drv_usart.c index f6f5514d11..c29904bd07 100644 --- a/bsp/hc32/libraries/hc32_drivers/drv_usart.c +++ b/bsp/hc32/libraries/hc32_drivers/drv_usart.c @@ -35,7 +35,7 @@ * Local pre-processor symbols/macros ('#define') ******************************************************************************/ #define DMA_CH_REG(reg_base, ch) \ - (*(uint32_t *)((uint32_t)(&(reg_base)) + ((ch) * 0x40UL))) + (*(volatile uint32_t *)((uint32_t)(&(reg_base)) + ((ch) * 0x40UL))) #define DMA_TRANS_SET_CNT(unit, ch) \ (READ_REG32(DMA_CH_REG((unit)->DTCTL0,(ch))) >> DMA_DTCTL_CNT_POS) diff --git a/bsp/hc32/libraries/hc32_drivers/drv_usart_v2.c b/bsp/hc32/libraries/hc32_drivers/drv_usart_v2.c index 82e47796a7..b46eba6094 100644 --- a/bsp/hc32/libraries/hc32_drivers/drv_usart_v2.c +++ b/bsp/hc32/libraries/hc32_drivers/drv_usart_v2.c @@ -35,7 +35,7 @@ * Local pre-processor symbols/macros ('#define') ******************************************************************************/ #define DMA_CH_REG(reg_base, ch) \ - (*(uint32_t *)((uint32_t)(&(reg_base)) + ((ch) * 0x40UL))) + (*(volatile uint32_t *)((uint32_t)(&(reg_base)) + ((ch) * 0x40UL))) #define DMA_TRANS_SET_CNT(unit, ch) \ (READ_REG32(DMA_CH_REG((unit)->DTCTL0,(ch))) >> DMA_DTCTL_CNT_POS)