فهرست منبع

[bsp/hc32] fix uart dma if gcc optimization level is not none

liuchao 9 ماه پیش
والد
کامیت
56c9bbe405
2فایلهای تغییر یافته به همراه2 افزوده شده و 2 حذف شده
  1. 1 1
      bsp/hc32/libraries/hc32_drivers/drv_usart.c
  2. 1 1
      bsp/hc32/libraries/hc32_drivers/drv_usart_v2.c

+ 1 - 1
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)

+ 1 - 1
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)