diff options
author | Andrew Tridgell <tridge@samba.org> | 2013-05-02 21:27:20 +1000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2013-05-04 19:18:51 +1000 |
commit | af27101ffecf2ad4642b1ced23640ff133c7246f (patch) | |
tree | 37a730ac165d412aa6cd2b246affbf1b4dfde3bc /src/modules/px4iofirmware/adc.c | |
parent | 44015d69154062d42ecc3aa0c9b25d7019bd5a71 (diff) | |
download | px4-firmware-af27101ffecf2ad4642b1ced23640ff133c7246f.tar.gz px4-firmware-af27101ffecf2ad4642b1ced23640ff133c7246f.tar.bz2 px4-firmware-af27101ffecf2ad4642b1ced23640ff133c7246f.zip |
px4io: changed adc_measure() to return 0xffff on error, and lower timeout
the timeout of 1ms was far too long, and could impact flight
performance
Returning 0xffff on error matches the FMU code, and allows bad values
to be discarded
Diffstat (limited to 'src/modules/px4iofirmware/adc.c')
-rw-r--r-- | src/modules/px4iofirmware/adc.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/modules/px4iofirmware/adc.c b/src/modules/px4iofirmware/adc.c index 670b8d635..f744698be 100644 --- a/src/modules/px4iofirmware/adc.c +++ b/src/modules/px4iofirmware/adc.c @@ -135,6 +135,9 @@ adc_init(void) return 0; } +/* + return one measurement, or 0xffff on error + */ uint16_t adc_measure(unsigned channel) { @@ -154,9 +157,10 @@ adc_measure(unsigned channel) while (!(rSR & ADC_SR_EOC)) { /* never spin forever - this will give a bogus result though */ - if (hrt_elapsed_time(&now) > 1000) { + if (hrt_elapsed_time(&now) > 100) { debug("adc timeout"); - break; + perf_end(adc_perf); + return 0xffff; } } @@ -165,4 +169,4 @@ adc_measure(unsigned channel) perf_end(adc_perf); return result; -}
\ No newline at end of file +} |