STM32: ADCv2: integration with DMAv1 with MUX

This commit is contained in:
Andrey Gusakov 2023-10-27 15:59:21 +03:00
parent 7f73c584f8
commit 448b07c245
2 changed files with 15 additions and 0 deletions

View File

@ -255,6 +255,9 @@ void adc_lld_start(ADCDriver *adcp) {
osalDbgAssert(adcp->dmastp != NULL, "unable to allocate stream"); osalDbgAssert(adcp->dmastp != NULL, "unable to allocate stream");
dmaStreamSetPeripheral(adcp->dmastp, &ADC1->DR); dmaStreamSetPeripheral(adcp->dmastp, &ADC1->DR);
rccEnableADC1(true); rccEnableADC1(true);
#if STM32_DMA_SUPPORTS_DMAMUX
dmaSetRequestSource(adcp->dmastp, STM32_DMAMUX1_ADC1);
#endif
} }
#endif /* STM32_ADC_USE_ADC1 */ #endif /* STM32_ADC_USE_ADC1 */
@ -267,6 +270,9 @@ void adc_lld_start(ADCDriver *adcp) {
osalDbgAssert(adcp->dmastp != NULL, "unable to allocate stream"); osalDbgAssert(adcp->dmastp != NULL, "unable to allocate stream");
dmaStreamSetPeripheral(adcp->dmastp, &ADC2->DR); dmaStreamSetPeripheral(adcp->dmastp, &ADC2->DR);
rccEnableADC2(true); rccEnableADC2(true);
#if STM32_DMA_SUPPORTS_DMAMUX
dmaSetRequestSource(adcp->dmastp, STM32_DMAMUX1_ADC2);
#endif
} }
#endif /* STM32_ADC_USE_ADC2 */ #endif /* STM32_ADC_USE_ADC2 */
@ -279,6 +285,9 @@ void adc_lld_start(ADCDriver *adcp) {
osalDbgAssert(adcp->dmastp != NULL, "unable to allocate stream"); osalDbgAssert(adcp->dmastp != NULL, "unable to allocate stream");
dmaStreamSetPeripheral(adcp->dmastp, &ADC3->DR); dmaStreamSetPeripheral(adcp->dmastp, &ADC3->DR);
rccEnableADC3(true); rccEnableADC3(true);
#if STM32_DMA_SUPPORTS_DMAMUX
dmaSetRequestSource(adcp->dmastp, STM32_DMAMUX1_ADC3);
#endif
} }
#endif /* STM32_ADC_USE_ADC3 */ #endif /* STM32_ADC_USE_ADC3 */

View File

@ -256,6 +256,10 @@
#error "ADC driver activated but no ADC peripheral assigned" #error "ADC driver activated but no ADC peripheral assigned"
#endif #endif
#if STM32_DMA_SUPPORTS_DMAMUX
#else /* !STM32_DMA_SUPPORTS_DMAMUX */
#if STM32_ADC_USE_ADC1 && \ #if STM32_ADC_USE_ADC1 && \
!STM32_DMA_IS_VALID_ID(STM32_ADC_ADC1_DMA_STREAM, STM32_ADC1_DMA_MSK) !STM32_DMA_IS_VALID_ID(STM32_ADC_ADC1_DMA_STREAM, STM32_ADC1_DMA_MSK)
#error "invalid DMA stream associated to ADC1" #error "invalid DMA stream associated to ADC1"
@ -271,6 +275,8 @@
#error "invalid DMA stream associated to ADC3" #error "invalid DMA stream associated to ADC3"
#endif #endif
#endif /* !STM32_DMA_SUPPORTS_DMAMUX */
/* ADC clock related settings and checks.*/ /* ADC clock related settings and checks.*/
#if STM32_ADC_ADCPRE == ADC_CCR_ADCPRE_DIV2 #if STM32_ADC_ADCPRE == ADC_CCR_ADCPRE_DIV2
#define STM32_ADCCLK (STM32_PCLK2 / 2) #define STM32_ADCCLK (STM32_PCLK2 / 2)