From 6ba0bc885fdf91afa13f75b3f2ff6529e71560ab Mon Sep 17 00:00:00 2001 From: gdisirio Date: Mon, 18 Jun 2012 18:16:12 +0000 Subject: [PATCH] Fixed bug 3535938. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/stable_2.4.x@4305 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/platforms/STM32/spi_lld.c | 34 ++++++++++++++++++---------- os/hal/platforms/STM32F1xx/adc_lld.c | 3 ++- os/hal/platforms/STM32F1xx/adc_lld.h | 1 + os/hal/platforms/STM32F2xx/adc_lld.c | 10 ++++---- os/hal/platforms/STM32F2xx/adc_lld.h | 1 + os/hal/platforms/STM32F4xx/adc_lld.c | 10 ++++---- os/hal/platforms/STM32F4xx/adc_lld.h | 1 + os/hal/platforms/STM32L1xx/adc_lld.c | 4 ++-- os/hal/platforms/STM32L1xx/adc_lld.h | 1 + readme.txt | 4 ++-- 10 files changed, 40 insertions(+), 29 deletions(-) diff --git a/os/hal/platforms/STM32/spi_lld.c b/os/hal/platforms/STM32/spi_lld.c index c701a8274..c71fcad77 100644 --- a/os/hal/platforms/STM32/spi_lld.c +++ b/os/hal/platforms/STM32/spi_lld.c @@ -372,11 +372,14 @@ void spi_lld_ignore(SPIDriver *spip, size_t n) { dmaStreamSetMemory0(spip->dmarx, &dummyrx); dmaStreamSetTransactionSize(spip->dmarx, n); - dmaStreamSetMode(spip->dmarx, spip->rxdmamode | STM32_DMA_CR_EN); + dmaStreamSetMode(spip->dmarx, spip->rxdmamode); dmaStreamSetMemory0(spip->dmatx, &dummytx); dmaStreamSetTransactionSize(spip->dmatx, n); - dmaStreamSetMode(spip->dmatx, spip->txdmamode | STM32_DMA_CR_EN); + dmaStreamSetMode(spip->dmatx, spip->txdmamode); + + dmaStreamEnable(spip->dmarx); + dmaStreamEnable(spip->dmatx); } /** @@ -399,12 +402,14 @@ void spi_lld_exchange(SPIDriver *spip, size_t n, dmaStreamSetMemory0(spip->dmarx, rxbuf); dmaStreamSetTransactionSize(spip->dmarx, n); - dmaStreamSetMode(spip->dmarx, spip->rxdmamode| STM32_DMA_CR_MINC | - STM32_DMA_CR_EN); + dmaStreamSetMode(spip->dmarx, spip->rxdmamode| STM32_DMA_CR_MINC); + dmaStreamSetMemory0(spip->dmatx, txbuf); dmaStreamSetTransactionSize(spip->dmatx, n); - dmaStreamSetMode(spip->dmatx, spip->txdmamode | STM32_DMA_CR_MINC | - STM32_DMA_CR_EN); + dmaStreamSetMode(spip->dmatx, spip->txdmamode | STM32_DMA_CR_MINC); + + dmaStreamEnable(spip->dmarx); + dmaStreamEnable(spip->dmatx); } /** @@ -424,12 +429,14 @@ void spi_lld_send(SPIDriver *spip, size_t n, const void *txbuf) { dmaStreamSetMemory0(spip->dmarx, &dummyrx); dmaStreamSetTransactionSize(spip->dmarx, n); - dmaStreamSetMode(spip->dmarx, spip->rxdmamode | STM32_DMA_CR_EN); + dmaStreamSetMode(spip->dmarx, spip->rxdmamode); dmaStreamSetMemory0(spip->dmatx, txbuf); dmaStreamSetTransactionSize(spip->dmatx, n); - dmaStreamSetMode(spip->dmatx, spip->txdmamode | STM32_DMA_CR_MINC | - STM32_DMA_CR_EN); + dmaStreamSetMode(spip->dmatx, spip->txdmamode | STM32_DMA_CR_MINC); + + dmaStreamEnable(spip->dmarx); + dmaStreamEnable(spip->dmatx); } /** @@ -449,11 +456,14 @@ void spi_lld_receive(SPIDriver *spip, size_t n, void *rxbuf) { dmaStreamSetMemory0(spip->dmarx, rxbuf); dmaStreamSetTransactionSize(spip->dmarx, n); - dmaStreamSetMode(spip->dmarx, spip->rxdmamode | STM32_DMA_CR_MINC | - STM32_DMA_CR_EN); + dmaStreamSetMode(spip->dmarx, spip->rxdmamode | STM32_DMA_CR_MINC); + dmaStreamSetMemory0(spip->dmatx, &dummytx); dmaStreamSetTransactionSize(spip->dmatx, n); - dmaStreamSetMode(spip->dmatx, spip->txdmamode | STM32_DMA_CR_EN); + dmaStreamSetMode(spip->dmatx, spip->txdmamode); + + dmaStreamEnable(spip->dmarx); + dmaStreamEnable(spip->dmatx); } /** diff --git a/os/hal/platforms/STM32F1xx/adc_lld.c b/os/hal/platforms/STM32F1xx/adc_lld.c index eaff9958c..878568802 100644 --- a/os/hal/platforms/STM32F1xx/adc_lld.c +++ b/os/hal/platforms/STM32F1xx/adc_lld.c @@ -104,7 +104,7 @@ void adc_lld_init(void) { 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 | - STM32_DMA_CR_TEIE | STM32_DMA_CR_EN; + STM32_DMA_CR_TEIE; /* Temporary activation.*/ rccEnableADC1(FALSE); @@ -206,6 +206,7 @@ void adc_lld_start_conversion(ADCDriver *adcp) { dmaStreamSetMemory0(adcp->dmastp, adcp->samples); dmaStreamSetTransactionSize(adcp->dmastp, n); dmaStreamSetMode(adcp->dmastp, mode); + dmaStreamEnable(adcp->dmastp); /* ADC setup.*/ adcp->adc->CR1 = grpp->cr1 | ADC_CR1_SCAN; diff --git a/os/hal/platforms/STM32F1xx/adc_lld.h b/os/hal/platforms/STM32F1xx/adc_lld.h index 03e2fa109..894c7e6d0 100644 --- a/os/hal/platforms/STM32F1xx/adc_lld.h +++ b/os/hal/platforms/STM32F1xx/adc_lld.h @@ -179,6 +179,7 @@ typedef void (*adccallback_t)(ADCDriver *adcp, adcsample_t *buffer, size_t n); * * @param[in] adcp pointer to the @p ADCDriver object triggering the * callback + * @param[in] err ADC error code */ typedef void (*adcerrorcallback_t)(ADCDriver *adcp, adcerror_t err); diff --git a/os/hal/platforms/STM32F2xx/adc_lld.c b/os/hal/platforms/STM32F2xx/adc_lld.c index 091a9c5ea..016b12c52 100644 --- a/os/hal/platforms/STM32F2xx/adc_lld.c +++ b/os/hal/platforms/STM32F2xx/adc_lld.c @@ -193,8 +193,7 @@ void adc_lld_init(void) { STM32_DMA_CR_DIR_P2M | STM32_DMA_CR_MSIZE_HWORD | STM32_DMA_CR_PSIZE_HWORD | STM32_DMA_CR_MINC | STM32_DMA_CR_TCIE | - STM32_DMA_CR_DMEIE | STM32_DMA_CR_TEIE | - STM32_DMA_CR_EN; + STM32_DMA_CR_DMEIE | STM32_DMA_CR_TEIE; #endif #if STM32_ADC_USE_ADC2 @@ -207,8 +206,7 @@ void adc_lld_init(void) { STM32_DMA_CR_DIR_P2M | STM32_DMA_CR_MSIZE_HWORD | STM32_DMA_CR_PSIZE_HWORD | STM32_DMA_CR_MINC | STM32_DMA_CR_TCIE | - STM32_DMA_CR_DMEIE | STM32_DMA_CR_TEIE | - STM32_DMA_CR_EN; + STM32_DMA_CR_DMEIE | STM32_DMA_CR_TEIE; #endif #if STM32_ADC_USE_ADC3 @@ -221,8 +219,7 @@ void adc_lld_init(void) { STM32_DMA_CR_DIR_P2M | STM32_DMA_CR_MSIZE_HWORD | STM32_DMA_CR_PSIZE_HWORD | STM32_DMA_CR_MINC | STM32_DMA_CR_TCIE | - STM32_DMA_CR_DMEIE | STM32_DMA_CR_TEIE | - STM32_DMA_CR_EN; + STM32_DMA_CR_DMEIE | STM32_DMA_CR_TEIE; #endif /* The shared vector is initialized on driver initialization and never @@ -345,6 +342,7 @@ void adc_lld_start_conversion(ADCDriver *adcp) { dmaStreamSetTransactionSize(adcp->dmastp, (uint32_t)grpp->num_channels * (uint32_t)adcp->depth); dmaStreamSetMode(adcp->dmastp, mode); + dmaStreamEnable(adcp->dmastp); /* ADC setup.*/ adcp->adc->SR = 0; diff --git a/os/hal/platforms/STM32F2xx/adc_lld.h b/os/hal/platforms/STM32F2xx/adc_lld.h index be2de51d2..67f47173e 100644 --- a/os/hal/platforms/STM32F2xx/adc_lld.h +++ b/os/hal/platforms/STM32F2xx/adc_lld.h @@ -336,6 +336,7 @@ typedef void (*adccallback_t)(ADCDriver *adcp, adcsample_t *buffer, size_t n); * * @param[in] adcp pointer to the @p ADCDriver object triggering the * callback + * @param[in] err ADC error code */ typedef void (*adcerrorcallback_t)(ADCDriver *adcp, adcerror_t err); diff --git a/os/hal/platforms/STM32F4xx/adc_lld.c b/os/hal/platforms/STM32F4xx/adc_lld.c index cbe7173d7..4340f8fa7 100644 --- a/os/hal/platforms/STM32F4xx/adc_lld.c +++ b/os/hal/platforms/STM32F4xx/adc_lld.c @@ -193,8 +193,7 @@ void adc_lld_init(void) { STM32_DMA_CR_DIR_P2M | STM32_DMA_CR_MSIZE_HWORD | STM32_DMA_CR_PSIZE_HWORD | STM32_DMA_CR_MINC | STM32_DMA_CR_TCIE | - STM32_DMA_CR_DMEIE | STM32_DMA_CR_TEIE | - STM32_DMA_CR_EN; + STM32_DMA_CR_DMEIE | STM32_DMA_CR_TEIE; #endif #if STM32_ADC_USE_ADC2 @@ -207,8 +206,7 @@ void adc_lld_init(void) { STM32_DMA_CR_DIR_P2M | STM32_DMA_CR_MSIZE_HWORD | STM32_DMA_CR_PSIZE_HWORD | STM32_DMA_CR_MINC | STM32_DMA_CR_TCIE | - STM32_DMA_CR_DMEIE | STM32_DMA_CR_TEIE | - STM32_DMA_CR_EN; + STM32_DMA_CR_DMEIE | STM32_DMA_CR_TEIE; #endif #if STM32_ADC_USE_ADC3 @@ -221,8 +219,7 @@ void adc_lld_init(void) { STM32_DMA_CR_DIR_P2M | STM32_DMA_CR_MSIZE_HWORD | STM32_DMA_CR_PSIZE_HWORD | STM32_DMA_CR_MINC | STM32_DMA_CR_TCIE | - STM32_DMA_CR_DMEIE | STM32_DMA_CR_TEIE | - STM32_DMA_CR_EN; + STM32_DMA_CR_DMEIE | STM32_DMA_CR_TEIE; #endif /* The shared vector is initialized on driver initialization and never @@ -345,6 +342,7 @@ void adc_lld_start_conversion(ADCDriver *adcp) { dmaStreamSetTransactionSize(adcp->dmastp, (uint32_t)grpp->num_channels * (uint32_t)adcp->depth); dmaStreamSetMode(adcp->dmastp, mode); + dmaStreamEnable(adcp->dmastp); /* ADC setup.*/ adcp->adc->SR = 0; diff --git a/os/hal/platforms/STM32F4xx/adc_lld.h b/os/hal/platforms/STM32F4xx/adc_lld.h index 00aca8005..cb7f84b88 100644 --- a/os/hal/platforms/STM32F4xx/adc_lld.h +++ b/os/hal/platforms/STM32F4xx/adc_lld.h @@ -336,6 +336,7 @@ typedef void (*adccallback_t)(ADCDriver *adcp, adcsample_t *buffer, size_t n); * * @param[in] adcp pointer to the @p ADCDriver object triggering the * callback + * @param[in] err ADC error code */ typedef void (*adcerrorcallback_t)(ADCDriver *adcp, adcerror_t err); diff --git a/os/hal/platforms/STM32L1xx/adc_lld.c b/os/hal/platforms/STM32L1xx/adc_lld.c index 3f9b57eba..b19aa6be4 100644 --- a/os/hal/platforms/STM32L1xx/adc_lld.c +++ b/os/hal/platforms/STM32L1xx/adc_lld.c @@ -136,8 +136,7 @@ void adc_lld_init(void) { STM32_DMA_CR_DIR_P2M | STM32_DMA_CR_MSIZE_HWORD | STM32_DMA_CR_PSIZE_HWORD | STM32_DMA_CR_MINC | STM32_DMA_CR_TCIE | - STM32_DMA_CR_DMEIE | STM32_DMA_CR_TEIE | - STM32_DMA_CR_EN; + STM32_DMA_CR_DMEIE | STM32_DMA_CR_TEIE; #endif /* The shared vector is initialized on driver initialization and never @@ -224,6 +223,7 @@ void adc_lld_start_conversion(ADCDriver *adcp) { dmaStreamSetTransactionSize(adcp->dmastp, (uint32_t)grpp->num_channels * (uint32_t)adcp->depth); dmaStreamSetMode(adcp->dmastp, mode); + dmaStreamEnable(adcp->dmastp); /* ADC setup.*/ adcp->adc->SR = 0; diff --git a/os/hal/platforms/STM32L1xx/adc_lld.h b/os/hal/platforms/STM32L1xx/adc_lld.h index e36741f43..d40308793 100644 --- a/os/hal/platforms/STM32L1xx/adc_lld.h +++ b/os/hal/platforms/STM32L1xx/adc_lld.h @@ -215,6 +215,7 @@ typedef void (*adccallback_t)(ADCDriver *adcp, adcsample_t *buffer, size_t n); * * @param[in] adcp pointer to the @p ADCDriver object triggering the * callback + * @param[in] err ADC error code */ typedef void (*adcerrorcallback_t)(ADCDriver *adcp, adcerror_t err); diff --git a/readme.txt b/readme.txt index da9eab739..ac8ca767f 100644 --- a/readme.txt +++ b/readme.txt @@ -81,9 +81,9 @@ *** 2.4.2 *** - FIX: Fixed wrong DMA channels on USART2 in STM32F10X_MD_VL devices (bug 3536070). - +- FIX: Fixed issue with DMA channel init in STM32 ADC and SPI drivers (bug + 3535938). - FIX: Fixed unreliable PHY initialization (bug 3534819)(backported to 2.4.2). - - FIX: Fixed wrong ADC callback buffer pointer in ADC driver (bug 3534767). - FIX: Fixed lwIP-related files missing from version 2.4.1 (bug 3533887). - FIX: Fixed problem with arm-v6m and state checker (bug 3532591).