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
This commit is contained in:
Andrew Tridgell 2013-05-02 21:27:20 +10:00
parent 44015d6915
commit af27101ffe
1 changed files with 7 additions and 3 deletions

View File

@ -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;
}
}