From 5667f5d817eb3aa218019d90a48c203271c836e4 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 2 Apr 2013 13:20:08 +1100 Subject: [PATCH] AP_ADC: fixed APM1 HIL_SENSORS Ch6() return --- libraries/AP_ADC/AP_ADC_HIL.cpp | 5 ++++- libraries/AP_ADC/AP_ADC_HIL.h | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/libraries/AP_ADC/AP_ADC_HIL.cpp b/libraries/AP_ADC/AP_ADC_HIL.cpp index 1355dadd78..03c6c786c8 100644 --- a/libraries/AP_ADC/AP_ADC_HIL.cpp +++ b/libraries/AP_ADC/AP_ADC_HIL.cpp @@ -60,7 +60,10 @@ uint32_t AP_ADC_HIL::Ch6(const uint8_t *channel_numbers, float *result) for (uint8_t i=0; i<6; i++) { result[i] = Ch(channel_numbers[i]); } - return ((hal.scheduler->millis() - last_hil_time)*2)/5; + uint32_t now = hal.scheduler->micros(); + uint32_t ret = now - _last_ch6_time; + _last_ch6_time = now; + return ret; } // Set one channel value diff --git a/libraries/AP_ADC/AP_ADC_HIL.h b/libraries/AP_ADC/AP_ADC_HIL.h index a6285c6030..96a7accdf4 100644 --- a/libraries/AP_ADC/AP_ADC_HIL.h +++ b/libraries/AP_ADC/AP_ADC_HIL.h @@ -56,8 +56,8 @@ private: // The raw adc array uint16_t adcValue[8]; - // the time in milliseconds when we last got a HIL update - uint32_t last_hil_time; + // the time in microseconds when Ch6 was last requested + uint32_t _last_ch6_time; /// // sensor constants