9
0
Fork 0

A few additional STM32 ADC changes

git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4174 7fd9a85b-ad96-42d3-883c-3090e2eb8679
This commit is contained in:
patacongo 2011-12-14 01:25:14 +00:00
parent 68850d9b89
commit 996f89bc78
1 changed files with 14 additions and 6 deletions

View File

@ -145,6 +145,8 @@ static int adc_ioctl(FAR struct adc_dev_s *dev, int cmd, unsigned long arg);
* Private Data
****************************************************************************/
/* ADC interface operations */
static const struct adc_ops_s g_adcops =
{
.ao_reset = adc_reset,
@ -154,6 +156,8 @@ static const struct adc_ops_s g_adcops =
.ao_ioctl = adc_ioctl,
};
/* ADC1 state */
#ifdef CONFIG_STM32_ADC1
static struct stm32_dev_s g_adcpriv1 =
{
@ -174,6 +178,8 @@ static struct adc_dev_s g_adcdev1 =
};
#endif
/* ADC2 state */
#ifdef CONFIG_STM32_ADC2
static struct stm32_dev_s g_adcpriv2 =
{
@ -192,9 +198,10 @@ static struct adc_dev_s g_adcdev2 =
.ad_ops = &g_adcops,
.ad_priv= &g_adcpriv2,
};
#endif
/* ADC3 state */
#ifdef CONFIG_STM32_ADC3
static struct stm32_dev_s g_adcpriv3 =
{
@ -213,7 +220,6 @@ static struct adc_dev_s g_adcdev3 =
.ad_ops = &g_adcops,
.ad_priv= &g_adcpriv3,
};
#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)
{
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;
/* Initialize the External event select "Timer CC1 event" */
regval &= ~ADC_CR2_EXTSEL_MASK;
/* Initialize the ADC_ContinuousConvMode "Single conversion mode" */
regval &= ~ADC_CR2_CONT;
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++)
{
priv->buf[i]=0;
priv->count[i]=0;
priv->buf[i] = 0;
priv->count[i] = 0;
}
/* Enable the ADC interrupt */
@ -606,7 +614,7 @@ static int adc123_interrupt(int irq, void *context)
pending = regval & ADC_SR_ALLINTS;
if (pending != 0)
{
adc_interrupt(&g_adcpriv2);
adc_interrupt(&g_adcpriv3);
regval &= ~pending;
putreg32(regval, STM32_ADC3_SR);
}