stm32_adc: invalidate dma buffer before use. Missing invalidation caused old samples being fetched from cache.

This commit is contained in:
Jussi Kivilinna 2017-06-19 07:52:19 -06:00 committed by Gregory Nutt
parent 25689d911c
commit a1ee9547f3
1 changed files with 6 additions and 1 deletions

View File

@ -67,6 +67,7 @@
#include "up_internal.h"
#include "up_arch.h"
#include "cache.h"
#include "chip.h"
#include "stm32_rcc.h"
#include "stm32_tim.h"
@ -1131,6 +1132,9 @@ static void adc_dmaconvcallback(DMA_HANDLE handle, uint8_t isr, FAR void *arg)
FAR struct stm32_dev_s *priv = (FAR struct stm32_dev_s *)dev->ad_priv;
int i;
arch_invalidate_dcache((uintptr_t)priv->dmabuffer,
(uintptr_t)priv->dmabuffer + sizeof(priv->dmabuffer));
/* Verify that the upper-half driver has bound its callback functions */
if (priv->cb != NULL)
@ -1149,6 +1153,7 @@ static void adc_dmaconvcallback(DMA_HANDLE handle, uint8_t isr, FAR void *arg)
}
}
}
/* Restart DMA for the next conversion series */
adc_modifyreg(priv, STM32_ADC_DMAREG_OFFSET, ADC_DMAREG_DMA, 0);
@ -1347,7 +1352,7 @@ static void adc_reset(FAR struct adc_dev_s *dev)
adc_getreg(priv, STM32_ADC_SR_OFFSET),
adc_getreg(priv, STM32_ADC_CR1_OFFSET),
adc_getreg(priv, STM32_ADC_CR2_OFFSET));
ainfo("SQR1: 0x%08x SQR2: 0x%08x SQR3: 0x%08x\n",
adc_getreg(priv, STM32_ADC_SQR1_OFFSET),
adc_getreg(priv, STM32_ADC_SQR2_OFFSET),