1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-29 14:52:12 +01:00

For now make the F4 PIOS_ADC return an error code if there is no new data in

the ADC buffer.  This should be handled appropriately by the caller.
This commit is contained in:
James Cotton 2012-06-11 09:22:04 -05:00
parent 2db95a6b4f
commit 821a25e419

View File

@ -292,6 +292,7 @@ void PIOS_ADC_Config(uint32_t oversampling)
* @param[in] pin number
* @return ADC pin value averaged over the set of samples since the last reading.
* @return -1 if pin doesn't exist
* @return -2 if no data acquired since last read
*/
int32_t last_conv_value;
int32_t PIOS_ADC_PinGet(uint32_t pin)
@ -304,6 +305,9 @@ int32_t PIOS_ADC_PinGet(uint32_t pin)
return -1;
}
if (accumulator[pin].accumulator <= 0)
return -2;
/* return accumulated result and clear accumulator */
result = accumulator[pin].accumulator / (accumulator[pin].count ?: 1);
accumulator[pin].accumulator = 0;