mirror of
https://github.com/apache/nuttx.git
synced 2026-05-29 20:56:47 +08:00
stm32/stm32_adc.c: fix enable/disable interrupts logic for coupled ADC
This commit is contained in:
committed by
Alan Carvalho de Assis
parent
166bf0434b
commit
88753afb75
@@ -2975,13 +2975,6 @@ static int adc_setup(FAR struct adc_dev_s *dev)
|
|||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Enable the ADC interrupt */
|
|
||||||
|
|
||||||
#ifndef CONFIG_STM32_ADC_NOIRQ
|
|
||||||
ainfo("Enable the ADC interrupt: irq=%d\n", priv->irq);
|
|
||||||
up_enable_irq(priv->irq);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_ADC_CMN_DATA
|
#ifdef HAVE_ADC_CMN_DATA
|
||||||
/* Increase instances counter */
|
/* Increase instances counter */
|
||||||
|
|
||||||
@@ -2991,6 +2984,18 @@ static int adc_setup(FAR struct adc_dev_s *dev)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (priv->cmn->initialized == 0)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
/* Enable the ADC interrupt */
|
||||||
|
|
||||||
|
#ifndef CONFIG_STM32_ADC_NOIRQ
|
||||||
|
ainfo("Enable the ADC interrupt: irq=%d\n", priv->irq);
|
||||||
|
up_enable_irq(priv->irq);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_ADC_CMN_DATA
|
||||||
priv->cmn->initialized += 1;
|
priv->cmn->initialized += 1;
|
||||||
adccmn_lock(priv, false);
|
adccmn_lock(priv, false);
|
||||||
#endif
|
#endif
|
||||||
@@ -3041,13 +3046,6 @@ static void adc_shutdown(FAR struct adc_dev_s *dev)
|
|||||||
adc_enable_hsi(false);
|
adc_enable_hsi(false);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CONFIG_STM32_ADC_NOIRQ
|
|
||||||
/* Disable ADC interrupts and detach the ADC interrupt handler */
|
|
||||||
|
|
||||||
up_disable_irq(priv->irq);
|
|
||||||
irq_detach(priv->irq);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_ADC_CMN_DATA
|
#ifdef HAVE_ADC_CMN_DATA
|
||||||
if (adccmn_lock(priv, true) < 0)
|
if (adccmn_lock(priv, true) < 0)
|
||||||
{
|
{
|
||||||
@@ -3057,6 +3055,13 @@ static void adc_shutdown(FAR struct adc_dev_s *dev)
|
|||||||
if (priv->cmn->initialized <= 1)
|
if (priv->cmn->initialized <= 1)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
#ifndef CONFIG_STM32_ADC_NOIRQ
|
||||||
|
/* Disable ADC interrupts and detach the ADC interrupt handler */
|
||||||
|
|
||||||
|
up_disable_irq(priv->irq);
|
||||||
|
irq_detach(priv->irq);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Disable and reset the ADC module.
|
/* Disable and reset the ADC module.
|
||||||
*
|
*
|
||||||
* NOTE: The ADC block will be reset to its reset state only if all
|
* NOTE: The ADC block will be reset to its reset state only if all
|
||||||
@@ -3081,7 +3086,10 @@ static void adc_shutdown(FAR struct adc_dev_s *dev)
|
|||||||
#ifdef HAVE_ADC_CMN_DATA
|
#ifdef HAVE_ADC_CMN_DATA
|
||||||
/* Decrease instances counter */
|
/* Decrease instances counter */
|
||||||
|
|
||||||
priv->cmn->initialized -= 1;
|
if (priv->cmn->initialized > 0)
|
||||||
|
{
|
||||||
|
priv->cmn->initialized -= 1;
|
||||||
|
}
|
||||||
|
|
||||||
adccmn_lock(priv, false);
|
adccmn_lock(priv, false);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user