arch/arm/src/stm32/stm32_adc.c: enable callback logic if DMA enabled

This commit is contained in:
raiden00pl
2020-04-21 21:35:54 +02:00
committed by patacongo
parent 4cb8be9608
commit a85ffd0fbd
+18 -3
View File
@@ -460,6 +460,16 @@
# undef ADC_HAVE_DMACFG
#endif
/* We have to support ADC callbacks if default ADC interrupts or
* DMA transfer are enabled
*/
#if !defined(CONFIG_STM32_ADC_NOIRQ) || defined(ADC_HAVE_DMA)
# define ADC_HAVE_CB
#else
# undef ADC_HAVE_CB
#endif
/****************************************************************************
* Private Types
****************************************************************************/
@@ -483,7 +493,7 @@ struct stm32_dev_s
#ifdef CONFIG_STM32_ADC_LL_OPS
FAR const struct stm32_adc_ops_s *llops; /* Low-level ADC ops */
#endif
#ifndef CONFIG_STM32_ADC_NOIRQ
#ifdef ADC_HAVE_CB
FAR const struct adc_callback_s *cb;
uint8_t irq; /* Interrupt generated by this ADC block */
#endif
@@ -2331,11 +2341,14 @@ static void adc_dmaconvcallback(DMA_HANDLE handle, uint8_t isr,
static int adc_bind(FAR struct adc_dev_s *dev,
FAR const struct adc_callback_s *callback)
{
#ifndef CONFIG_STM32_ADC_NOIRQ
#ifdef ADC_HAVE_CB
FAR struct stm32_dev_s *priv = (FAR struct stm32_dev_s *)dev->ad_priv;
DEBUGASSERT(priv != NULL);
priv->cb = callback;
#else
UNUSED(dev);
UNUSED(callback);
#endif
return OK;
@@ -2725,6 +2738,8 @@ static void adc_dma_start(FAR struct adc_dev_s *dev)
priv->dma = stm32_dmachannel(priv->dmachan);
#ifndef CONFIG_STM32_ADC_NOIRQ
/* Start DMA only if standard ADC interrupts used */
stm32_dmasetup(priv->dma,
priv->base + STM32_ADC_DR_OFFSET,
(uint32_t)priv->r_dmabuffer,
@@ -4708,7 +4723,7 @@ struct adc_dev_s *stm32_adcinitialize(int intf, FAR const uint8_t *chanlist,
priv->adc_channels = ADC_CHANNELS_NUMBER;
#endif
#ifndef CONFIG_STM32_ADC_NOIRQ
#ifdef ADC_HAVE_CB
priv->cb = NULL;
#endif