mirror of
https://github.com/apache/nuttx.git
synced 2026-06-05 07:12:54 +08:00
stm32_adc: invalidate dma buffer before use. Missing invalidation caused old samples being fetched from cache.
This commit is contained in:
committed by
Gregory Nutt
parent
25689d911c
commit
a1ee9547f3
@@ -67,6 +67,7 @@
|
|||||||
#include "up_internal.h"
|
#include "up_internal.h"
|
||||||
#include "up_arch.h"
|
#include "up_arch.h"
|
||||||
|
|
||||||
|
#include "cache.h"
|
||||||
#include "chip.h"
|
#include "chip.h"
|
||||||
#include "stm32_rcc.h"
|
#include "stm32_rcc.h"
|
||||||
#include "stm32_tim.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;
|
FAR struct stm32_dev_s *priv = (FAR struct stm32_dev_s *)dev->ad_priv;
|
||||||
int i;
|
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 */
|
/* Verify that the upper-half driver has bound its callback functions */
|
||||||
|
|
||||||
if (priv->cb != NULL)
|
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 */
|
/* Restart DMA for the next conversion series */
|
||||||
|
|
||||||
adc_modifyreg(priv, STM32_ADC_DMAREG_OFFSET, ADC_DMAREG_DMA, 0);
|
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_SR_OFFSET),
|
||||||
adc_getreg(priv, STM32_ADC_CR1_OFFSET),
|
adc_getreg(priv, STM32_ADC_CR1_OFFSET),
|
||||||
adc_getreg(priv, STM32_ADC_CR2_OFFSET));
|
adc_getreg(priv, STM32_ADC_CR2_OFFSET));
|
||||||
|
|
||||||
ainfo("SQR1: 0x%08x SQR2: 0x%08x SQR3: 0x%08x\n",
|
ainfo("SQR1: 0x%08x SQR2: 0x%08x SQR3: 0x%08x\n",
|
||||||
adc_getreg(priv, STM32_ADC_SQR1_OFFSET),
|
adc_getreg(priv, STM32_ADC_SQR1_OFFSET),
|
||||||
adc_getreg(priv, STM32_ADC_SQR2_OFFSET),
|
adc_getreg(priv, STM32_ADC_SQR2_OFFSET),
|
||||||
|
|||||||
Reference in New Issue
Block a user