You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ac...@apache.org on 2020/05/03 18:58:02 UTC

[incubator-nuttx] 06/07: arch/arm/src/stm32/stm32_adc: add setup and shutdown operations to the low-level interface

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

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

commit 534ba2cc18062da617e8edb9acc79f3f301cc483
Author: raiden00pl <ra...@railab.me>
AuthorDate: Mon Apr 27 20:52:06 2020 +0200

    arch/arm/src/stm32/stm32_adc: add setup and shutdown operations to the low-level interface
---
 arch/arm/src/stm32/stm32_adc.c | 33 +++++++++++++++++++++++++++++++++
 arch/arm/src/stm32/stm32_adc.h | 12 ++++++++++++
 2 files changed, 45 insertions(+)

diff --git a/arch/arm/src/stm32/stm32_adc.c b/arch/arm/src/stm32/stm32_adc.c
index 88db525..a19ba37 100644
--- a/arch/arm/src/stm32/stm32_adc.c
+++ b/arch/arm/src/stm32/stm32_adc.c
@@ -395,6 +395,7 @@ struct stm32_dev_s
 {
 #ifdef CONFIG_STM32_ADC_LL_OPS
   FAR const struct stm32_adc_ops_s *llops; /* Low-level ADC ops */
+  FAR struct adc_dev_s             *dev;   /* Upper-half ADC reference */
 #endif
 #ifdef ADC_HAVE_CB
   FAR const struct adc_callback_s *cb;
@@ -597,6 +598,8 @@ static int adc_jextcfg_set(FAR struct stm32_dev_s *priv, uint32_t jextcfg);
 static void adc_dumpregs(FAR struct stm32_dev_s *priv);
 
 #ifdef CONFIG_STM32_ADC_LL_OPS
+static int adc_llops_setup(FAR struct stm32_adc_dev_s *dev);
+static void adc_llops_shutdown(FAR struct stm32_adc_dev_s *dev);
 static void adc_intack(FAR struct stm32_adc_dev_s *dev, uint32_t source);
 static void adc_inten(FAR struct stm32_adc_dev_s *dev, uint32_t source);
 static void adc_intdis(FAR struct stm32_adc_dev_s *dev, uint32_t source);
@@ -656,6 +659,8 @@ static const struct adc_ops_s g_adcops =
 #ifdef CONFIG_STM32_ADC_LL_OPS
 static const struct stm32_adc_ops_s g_adc_llops =
 {
+  .setup         = adc_llops_setup,
+  .shutdown      = adc_llops_shutdown,
   .int_ack       = adc_intack,
   .int_get       = adc_intget,
   .int_en        = adc_inten,
@@ -4146,6 +4151,28 @@ static int adc123_interrupt(int irq, FAR void *context, FAR void *arg)
 #ifdef CONFIG_STM32_ADC_LL_OPS
 
 /****************************************************************************
+ * Name: adc_llops_setup
+ ****************************************************************************/
+
+static int adc_llops_setup(FAR struct stm32_adc_dev_s *dev)
+{
+  FAR struct stm32_dev_s *priv = (FAR struct stm32_dev_s *)dev;
+
+  return adc_setup(priv->dev);
+}
+
+/****************************************************************************
+ * Name: adc_llops_shutdown
+ ****************************************************************************/
+
+static void adc_llops_shutdown(FAR struct stm32_adc_dev_s *dev)
+{
+  FAR struct stm32_dev_s *priv = (FAR struct stm32_dev_s *)dev;
+
+  adc_shutdown(priv->dev);
+}
+
+/****************************************************************************
  * Name: adc_intack
  ****************************************************************************/
 
@@ -4710,6 +4737,12 @@ struct adc_dev_s *stm32_adcinitialize(int intf, FAR const uint8_t *chanlist,
   priv->cb        = NULL;
 #endif
 
+#ifdef CONFIG_STM32_ADC_LL_OPS
+  /* Store reference to the upper-half ADC device */
+
+  priv->dev = dev;
+#endif
+
 #ifdef ADC_HAVE_INJECTED
   ainfo("intf: %d cr_channels: %d, cj_channels: %d\n",
         intf, priv->cr_channels, priv->cj_channels);
diff --git a/arch/arm/src/stm32/stm32_adc.h b/arch/arm/src/stm32/stm32_adc.h
index 82de784..da0ae58 100644
--- a/arch/arm/src/stm32/stm32_adc.h
+++ b/arch/arm/src/stm32/stm32_adc.h
@@ -2067,6 +2067,10 @@
         (adc)->llops->stime_write(adc)
 #define STM32_ADC_DUMP_REGS(adc)                    \
         (adc)->llops->dump_regs(adc)
+#define STM32_ADC_SETUP(adc)                        \
+        (adc)->llops->setup(adc)
+#define STM32_ADC_SHUTDOWN(adc)                     \
+        (adc)->llops->shutdown(adc)
 
 /************************************************************************************
  * Public Types
@@ -2161,6 +2165,14 @@ struct stm32_adc_dev_s
 
 struct stm32_adc_ops_s
 {
+  /* Low-level ADC setup */
+
+  int (*setup)(FAR struct stm32_adc_dev_s *dev);
+
+  /* Low-level ADC shutdown */
+
+  void (*shutdown)(FAR struct stm32_adc_dev_s *dev);
+
   /* Acknowledge interrupts */
 
   void (*int_ack)(FAR struct stm32_adc_dev_s *dev, uint32_t source);