diff options
author | Lorenz Meier <lm@inf.ethz.ch> | 2013-01-11 07:44:17 +0100 |
---|---|---|
committer | Lorenz Meier <lm@inf.ethz.ch> | 2013-01-11 07:44:17 +0100 |
commit | cf563eda8648534475705b6211bf4040ef9e193f (patch) | |
tree | 3adc294377c6c7c7d2b2285a0b77966a17c80a73 /apps/px4io/adc.c | |
parent | dc100f20201974eeae8743e1184efe6be1e31e6f (diff) | |
download | px4-firmware-cf563eda8648534475705b6211bf4040ef9e193f.tar.gz px4-firmware-cf563eda8648534475705b6211bf4040ef9e193f.tar.bz2 px4-firmware-cf563eda8648534475705b6211bf4040ef9e193f.zip |
px4io code style
Diffstat (limited to 'apps/px4io/adc.c')
-rw-r--r-- | apps/px4io/adc.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/apps/px4io/adc.c b/apps/px4io/adc.c index 62ff0b1f1..e06b269dc 100644 --- a/apps/px4io/adc.c +++ b/apps/px4io/adc.c @@ -87,12 +87,16 @@ adc_init(void) #ifdef ADC_CR2_CAL rCR2 |= ADC_CR2_RSTCAL; up_udelay(1); + if (rCR2 & ADC_CR2_RSTCAL) return -1; + rCR2 |= ADC_CR2_CAL; up_udelay(100); + if (rCR2 & ADC_CR2_CAL) return -1; + #endif /* arbitrarily configure all channels for 55 cycle sample time */ @@ -103,7 +107,7 @@ adc_init(void) rCR1 = 0; /* enable the temperature sensor / Vrefint channel if supported*/ - rCR2 = + rCR2 = #ifdef ADC_CR2_TSVREFE /* enable the temperature sensor in CR2 */ ADC_CR2_TSVREFE | @@ -118,7 +122,7 @@ adc_init(void) /* configure for a single-channel sequence */ rSQR1 = 0; rSQR2 = 0; - rSQR3 = 0; /* will be updated with the channel each tick */ + rSQR3 = 0; /* will be updated with the channel each tick */ /* power-cycle the ADC and turn it on */ rCR2 &= ~ADC_CR2_ADON; @@ -146,6 +150,7 @@ adc_measure(unsigned channel) /* wait for the conversion to complete */ hrt_abstime now = hrt_absolute_time(); + while (!(rSR & ADC_SR_EOC)) { /* never spin forever - this will give a bogus result though */ @@ -159,5 +164,5 @@ adc_measure(unsigned channel) uint16_t result = rDR; perf_end(adc_perf); - return result; -}
\ No newline at end of file + return result; +}
\ No newline at end of file |