mirror of
https://github.com/apache/nuttx.git
synced 2026-06-04 06:32:32 +08:00
stm32/stm32_adc.c: protect irq_attach with refcounter
irq_attach should only be called once for ADCs that share a common interrupt handler. We can move irq_attach to just before interrupts are enabled.
This commit is contained in:
committed by
Alan Carvalho de Assis
parent
225d5bba6e
commit
0e40cc2853
@@ -2890,17 +2890,6 @@ static int adc_setup(struct adc_dev_s *dev)
|
|||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Attach the ADC interrupt */
|
|
||||||
|
|
||||||
#ifndef CONFIG_STM32_ADC_NOIRQ
|
|
||||||
ret = irq_attach(priv->irq, priv->isr, NULL);
|
|
||||||
if (ret < 0)
|
|
||||||
{
|
|
||||||
ainfo("irq_attach failed: %d\n", ret);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Make sure that the ADC device is in the powered up, reset state */
|
/* Make sure that the ADC device is in the powered up, reset state */
|
||||||
|
|
||||||
adc_reset(dev);
|
adc_reset(dev);
|
||||||
@@ -2954,9 +2943,18 @@ static int adc_setup(struct adc_dev_s *dev)
|
|||||||
if (priv->cmn->refcount == 0)
|
if (priv->cmn->refcount == 0)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
#ifndef CONFIG_STM32_ADC_NOIRQ
|
||||||
|
/* Attach the ADC interrupt */
|
||||||
|
|
||||||
|
ret = irq_attach(priv->irq, priv->isr, NULL);
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
ainfo("irq_attach failed: %d\n", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
/* Enable the ADC interrupt */
|
/* Enable the ADC interrupt */
|
||||||
|
|
||||||
#ifndef CONFIG_STM32_ADC_NOIRQ
|
|
||||||
ainfo("Enable the ADC interrupt: irq=%d\n", priv->irq);
|
ainfo("Enable the ADC interrupt: irq=%d\n", priv->irq);
|
||||||
up_enable_irq(priv->irq);
|
up_enable_irq(priv->irq);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user