summaryrefslogtreecommitdiff
path: root/nuttx/arch/arm/src/stm32
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-12-14 01:25:14 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-12-14 01:25:14 +0000
commit891096cafd0ea56d923fb06ea81190bfb8d956e9 (patch)
tree81dbb00a631c5d4c2d21766dcdc553d2dbad4599 /nuttx/arch/arm/src/stm32
parent14205580387ff7d21e5be8efea91e7a92f6fe48e (diff)
downloadpx4-nuttx-891096cafd0ea56d923fb06ea81190bfb8d956e9.tar.gz
px4-nuttx-891096cafd0ea56d923fb06ea81190bfb8d956e9.tar.bz2
px4-nuttx-891096cafd0ea56d923fb06ea81190bfb8d956e9.zip
A few additional STM32 ADC changes
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4174 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/arch/arm/src/stm32')
-rw-r--r--nuttx/arch/arm/src/stm32/stm32_adc.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/nuttx/arch/arm/src/stm32/stm32_adc.c b/nuttx/arch/arm/src/stm32/stm32_adc.c
index bb8efa2e9..8356f53d5 100644
--- a/nuttx/arch/arm/src/stm32/stm32_adc.c
+++ b/nuttx/arch/arm/src/stm32/stm32_adc.c
@@ -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);
}