A few additional STM32 ADC changes
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4174 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
48796107c8
commit
a4f48e6ee3
@ -145,6 +145,8 @@ static int adc_ioctl(FAR struct adc_dev_s *dev, int cmd, unsigned long arg);
|
|||||||
* Private Data
|
* Private Data
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
/* ADC interface operations */
|
||||||
|
|
||||||
static const struct adc_ops_s g_adcops =
|
static const struct adc_ops_s g_adcops =
|
||||||
{
|
{
|
||||||
.ao_reset = adc_reset,
|
.ao_reset = adc_reset,
|
||||||
@ -154,6 +156,8 @@ static const struct adc_ops_s g_adcops =
|
|||||||
.ao_ioctl = adc_ioctl,
|
.ao_ioctl = adc_ioctl,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* ADC1 state */
|
||||||
|
|
||||||
#ifdef CONFIG_STM32_ADC1
|
#ifdef CONFIG_STM32_ADC1
|
||||||
static struct stm32_dev_s g_adcpriv1 =
|
static struct stm32_dev_s g_adcpriv1 =
|
||||||
{
|
{
|
||||||
@ -174,6 +178,8 @@ static struct adc_dev_s g_adcdev1 =
|
|||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* ADC2 state */
|
||||||
|
|
||||||
#ifdef CONFIG_STM32_ADC2
|
#ifdef CONFIG_STM32_ADC2
|
||||||
static struct stm32_dev_s g_adcpriv2 =
|
static struct stm32_dev_s g_adcpriv2 =
|
||||||
{
|
{
|
||||||
@ -192,9 +198,10 @@ static struct adc_dev_s g_adcdev2 =
|
|||||||
.ad_ops = &g_adcops,
|
.ad_ops = &g_adcops,
|
||||||
.ad_priv= &g_adcpriv2,
|
.ad_priv= &g_adcpriv2,
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* ADC3 state */
|
||||||
|
|
||||||
#ifdef CONFIG_STM32_ADC3
|
#ifdef CONFIG_STM32_ADC3
|
||||||
static struct stm32_dev_s g_adcpriv3 =
|
static struct stm32_dev_s g_adcpriv3 =
|
||||||
{
|
{
|
||||||
@ -213,7 +220,6 @@ static struct adc_dev_s g_adcdev3 =
|
|||||||
.ad_ops = &g_adcops,
|
.ad_ops = &g_adcops,
|
||||||
.ad_priv= &g_adcpriv3,
|
.ad_priv= &g_adcpriv3,
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -255,7 +261,7 @@ static uint32_t adc_getreg(struct stm32_dev_s *priv, int offset)
|
|||||||
|
|
||||||
static void adc_putreg(struct stm32_dev_s *priv, int offset, uint32_t value)
|
static void adc_putreg(struct stm32_dev_s *priv, int offset, uint32_t value)
|
||||||
{
|
{
|
||||||
putreg32(value, priv->base + offst);
|
putreg32(value, priv->base + offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -314,9 +320,11 @@ static void adc_reset(FAR struct adc_dev_s *dev)
|
|||||||
regval &= ~ADC_CR2_ALIGN;
|
regval &= ~ADC_CR2_ALIGN;
|
||||||
|
|
||||||
/* Initialize the External event select "Timer CC1 event" */
|
/* Initialize the External event select "Timer CC1 event" */
|
||||||
|
|
||||||
regval &= ~ADC_CR2_EXTSEL_MASK;
|
regval &= ~ADC_CR2_EXTSEL_MASK;
|
||||||
|
|
||||||
/* Initialize the ADC_ContinuousConvMode "Single conversion mode" */
|
/* Initialize the ADC_ContinuousConvMode "Single conversion mode" */
|
||||||
|
|
||||||
regval &= ~ADC_CR2_CONT;
|
regval &= ~ADC_CR2_CONT;
|
||||||
adc_putreg(priv, STM32_ADC_CR2_OFFSET, regval);
|
adc_putreg(priv, STM32_ADC_CR2_OFFSET, regval);
|
||||||
|
|
||||||
@ -357,8 +365,8 @@ static int adc_setup(FAR struct adc_dev_s *dev)
|
|||||||
{
|
{
|
||||||
for (i = 0; i < 8; i++)
|
for (i = 0; i < 8; i++)
|
||||||
{
|
{
|
||||||
priv->buf[i]=0;
|
priv->buf[i] = 0;
|
||||||
priv->count[i]=0;
|
priv->count[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Enable the ADC interrupt */
|
/* Enable the ADC interrupt */
|
||||||
@ -606,7 +614,7 @@ static int adc123_interrupt(int irq, void *context)
|
|||||||
pending = regval & ADC_SR_ALLINTS;
|
pending = regval & ADC_SR_ALLINTS;
|
||||||
if (pending != 0)
|
if (pending != 0)
|
||||||
{
|
{
|
||||||
adc_interrupt(&g_adcpriv2);
|
adc_interrupt(&g_adcpriv3);
|
||||||
regval &= ~pending;
|
regval &= ~pending;
|
||||||
putreg32(regval, STM32_ADC3_SR);
|
putreg32(regval, STM32_ADC3_SR);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user