From 3b502376999b703aab9a9c225fba88f259e4552b Mon Sep 17 00:00:00 2001 From: Guillaume Gautier Date: Fri, 8 Mar 2024 08:49:57 +0100 Subject: [PATCH] drivers: adc: stm32: use correct macros for dma transfer Use the correct dedicated macros for enabling DMA transfer for STM32H7 and U5. Signed-off-by: Guillaume Gautier --- drivers/adc/adc_stm32.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/drivers/adc/adc_stm32.c b/drivers/adc/adc_stm32.c index b37c02d839..1ed8db1c54 100644 --- a/drivers/adc/adc_stm32.c +++ b/drivers/adc/adc_stm32.c @@ -221,12 +221,9 @@ static void adc_stm32_enable_dma_support(ADC_TypeDef *adc) #if defined(ADC_VER_V5_V90) if (adc == ADC3) { - LL_ADC_REG_SetDMATransferMode(adc, - ADC3_CFGR_DMACONTREQ(LL_ADC_REG_DMA_TRANSFER_LIMITED)); - LL_ADC_EnableDMAReq(adc); + LL_ADC_REG_SetDMATransferMode(adc, LL_ADC3_REG_DMA_TRANSFER_LIMITED); } else { - LL_ADC_REG_SetDataTransferMode(adc, - ADC_CFGR_DMACONTREQ(LL_ADC_REG_DMA_TRANSFER_LIMITED)); + LL_ADC_REG_SetDataTransferMode(adc, LL_ADC_REG_DMA_TRANSFER_LIMITED); } #elif defined(ADC_VER_V5_X) LL_ADC_REG_SetDataTransferMode(adc, LL_ADC_REG_DMA_TRANSFER_LIMITED); @@ -238,7 +235,15 @@ static void adc_stm32_enable_dma_support(ADC_TypeDef *adc) #error "The STM32F1 ADC + DMA is not yet supported" -#else /* DT_HAS_COMPAT_STATUS_OKAY(st_stm32f1_adc) */ +#elif defined(CONFIG_SOC_SERIES_STM32U5X) /* DT_HAS_COMPAT_STATUS_OKAY(st_stm32f1_adc) */ + + if (adc == ADC4) { + LL_ADC_REG_SetDMATransfer(adc, LL_ADC_REG_DMA_TRANSFER_LIMITED_ADC4); + } else { + LL_ADC_REG_SetDataTransferMode(adc, LL_ADC_REG_DMA_TRANSFER_LIMITED); + } + +#else /* defined(CONFIG_SOC_SERIES_STM32U5X) */ /* Default mechanism for other MCUs */ LL_ADC_REG_SetDMATransfer(adc, LL_ADC_REG_DMA_TRANSFER_LIMITED);