From d5635adecc959228fefce27610f211087fefd87f Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Wed, 2 Jan 2019 11:43:13 +0000 Subject: Mass update of all drivers to use the new DMA API. What could possibly go wrong? git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@12521 110e8d01-0319-4d1e-a829-52ad28d1bb01 --- os/hal/ports/STM32/STM32F1xx/hal_adc_lld.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'os/hal/ports/STM32/STM32F1xx') diff --git a/os/hal/ports/STM32/STM32F1xx/hal_adc_lld.c b/os/hal/ports/STM32/STM32F1xx/hal_adc_lld.c index 07d2fec89..9f29a911c 100644 --- a/os/hal/ports/STM32/STM32F1xx/hal_adc_lld.c +++ b/os/hal/ports/STM32/STM32F1xx/hal_adc_lld.c @@ -92,7 +92,7 @@ void adc_lld_init(void) { /* Driver initialization.*/ adcObjectInit(&ADCD1); ADCD1.adc = ADC1; - ADCD1.dmastp = STM32_DMA1_STREAM1; + ADCD1.dmastp = NULL; ADCD1.dmamode = STM32_DMA_CR_PL(STM32_ADC_ADC1_DMA_PRIORITY) | STM32_DMA_CR_MSIZE_HWORD | STM32_DMA_CR_PSIZE_HWORD | STM32_DMA_CR_MINC | STM32_DMA_CR_TCIE | @@ -132,12 +132,11 @@ void adc_lld_start(ADCDriver *adcp) { if (adcp->state == ADC_STOP) { #if STM32_ADC_USE_ADC1 if (&ADCD1 == adcp) { - bool b; - b = dmaStreamAllocate(adcp->dmastp, - STM32_ADC_ADC1_IRQ_PRIORITY, - (stm32_dmaisr_t)adc_lld_serve_rx_interrupt, - (void *)adcp); - osalDbgAssert(!b, "stream already allocated"); + adcp->dmastp = dmaStreamAllocI(STM32_DMA_STREAM_ID(1, 1), + STM32_ADC_ADC1_IRQ_PRIORITY, + (stm32_dmaisr_t)adc_lld_serve_rx_interrupt, + (void *)adcp); + osalDbgAssert(adcp->dmastp != NULL, "unable to allocate stream"); dmaStreamSetPeripheral(adcp->dmastp, &ADC1->DR); rccEnableADC1(true); } @@ -165,7 +164,10 @@ void adc_lld_stop(ADCDriver *adcp) { if (&ADCD1 == adcp) { ADC1->CR1 = 0; ADC1->CR2 = 0; - dmaStreamRelease(adcp->dmastp); + + dmaStreamFreeI(adcp->dmastp); + adcp->dmastp = NULL; + rccDisableADC1(); } #endif -- cgit v1.2.3