From 9fea8fc08d632fa129c2899ffd500008b70e7706 Mon Sep 17 00:00:00 2001 From: jflyper Date: Thu, 9 Jan 2020 14:01:50 +0900 Subject: [PATCH] [G4][LIB] Fix LL_DMA_{Set,Get}PeriphRequest Fix bad handling of DMA_TypeDef argument in LL_DMA_{Set,Get}PeriphRequest() inline macro. This bug causes peripheral requests for DMA2 to be set in DMAMUX channels for DMA1. This is fixed in FW library V1.1.0. --- .../STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_dma.h | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/main/STM32G4/Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_dma.h b/lib/main/STM32G4/Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_dma.h index b6095b79ec..ea0486c5cc 100755 --- a/lib/main/STM32G4/Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_dma.h +++ b/lib/main/STM32G4/Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_ll_dma.h @@ -1433,9 +1433,8 @@ __STATIC_INLINE uint32_t LL_DMA_GetM2MDstAddress(DMA_TypeDef *DMAx, uint32_t Cha */ __STATIC_INLINE void LL_DMA_SetPeriphRequest(DMA_TypeDef *DMAx, uint32_t Channel, uint32_t PeriphRequest) { - UNUSED(DMAx); - MODIFY_REG(((DMAMUX_Channel_TypeDef *)(uint32_t)((uint32_t)DMAMUX1_Channel0 + (DMAMUX_CCR_SIZE * (Channel - 1U))))->CCR, - DMAMUX_CxCR_DMAREQ_ID, PeriphRequest); + uint32_t dmamux_ccr_offset = ((((uint32_t)DMAx ^ (uint32_t)DMA1) >> 10U) * 8U); + MODIFY_REG((DMAMUX1_Channel0 + Channel - 1 + dmamux_ccr_offset)->CCR, DMAMUX_CxCR_DMAREQ_ID, PeriphRequest); } /** @@ -1578,9 +1577,8 @@ __STATIC_INLINE void LL_DMA_SetPeriphRequest(DMA_TypeDef *DMAx, uint32_t Channel */ __STATIC_INLINE uint32_t LL_DMA_GetPeriphRequest(DMA_TypeDef *DMAx, uint32_t Channel) { - UNUSED(DMAx); - return (READ_BIT(((DMAMUX_Channel_TypeDef *)((uint32_t)((uint32_t)DMAMUX1_Channel0 + (DMAMUX_CCR_SIZE * - (Channel - 1U)))))->CCR, DMAMUX_CxCR_DMAREQ_ID)); + uint32_t dmamux_ccr_offset = ((((uint32_t)DMAx ^ (uint32_t)DMA1) >> 10U) * 8U); + return (READ_BIT((DMAMUX1_Channel0 + Channel - 1 + dmamux_ccr_offset)->CCR, DMAMUX_CxCR_DMAREQ_ID)); } /**