You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by gn...@apache.org on 2020/04/26 17:35:21 UTC

[incubator-nuttx] 02/09: arch/arm/src/stm32/stm32_adc.c: enable callback logic if DMA enabled

This is an automated email from the ASF dual-hosted git repository.

gnutt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit a85ffd0fbde1e803908f958569076a44b1e88fc9
Author: raiden00pl <ra...@railab.me>
AuthorDate: Tue Apr 21 21:35:54 2020 +0200

    arch/arm/src/stm32/stm32_adc.c: enable callback logic if DMA enabled
---
 arch/arm/src/stm32/stm32_adc.c | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/arch/arm/src/stm32/stm32_adc.c b/arch/arm/src/stm32/stm32_adc.c
index 5ac3b58..f4ecc4e 100644
--- a/arch/arm/src/stm32/stm32_adc.c
+++ b/arch/arm/src/stm32/stm32_adc.c
@@ -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