forked from Archive/PX4-Autopilot
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:
parent
44015d6915
commit
af27101ffe
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue