From db6383eee75ce262e28d09e888dcd9c748ee6fdc Mon Sep 17 00:00:00 2001 From: TunaLobster Date: Tue, 28 Sep 2021 11:40:08 -0500 Subject: [PATCH] AP_IOMCU: fix ADC scaling on IOMCU --- libraries/AP_IOMCU/AP_IOMCU.h | 8 ++++---- libraries/AP_IOMCU/iofirmware/analog.cpp | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/libraries/AP_IOMCU/AP_IOMCU.h b/libraries/AP_IOMCU/AP_IOMCU.h index 4f89351a93..5fe549cdb5 100644 --- a/libraries/AP_IOMCU/AP_IOMCU.h +++ b/libraries/AP_IOMCU/AP_IOMCU.h @@ -74,14 +74,14 @@ public: } /* - get servo rail voltage + get servo rail voltage adc counts */ - float get_vservo(void) const { return reg_status.vservo * 0.001; } + uint16_t get_vservo_adc_count(void) const { return reg_status.vservo; } /* - get rssi voltage + get rssi voltage adc counts */ - float get_vrssi(void) const { return reg_status.vrssi * 0.001; } + uint16_t get_vrssi_adc_count(void) const { return reg_status.vrssi; } // set target for IMU heater void set_heater_duty_cycle(uint8_t duty_cycle); diff --git a/libraries/AP_IOMCU/iofirmware/analog.cpp b/libraries/AP_IOMCU/iofirmware/analog.cpp index 5ab775378d..e2c6f82081 100644 --- a/libraries/AP_IOMCU/iofirmware/analog.cpp +++ b/libraries/AP_IOMCU/iofirmware/analog.cpp @@ -75,7 +75,7 @@ static uint16_t adc_sample_channel(uint32_t channel) uint16_t adc_sample_vservo(void) { const uint32_t channel = ADC_SQR3_SQ1_N(ADC_CHANNEL_IN4); - return adc_sample_channel(channel) * 9900 / 4096; + return adc_sample_channel(channel); } /* @@ -84,5 +84,5 @@ uint16_t adc_sample_vservo(void) uint16_t adc_sample_vrssi(void) { const uint32_t channel = ADC_SQR3_SQ1_N(ADC_CHANNEL_IN5); - return adc_sample_channel(channel) * 9900 / 4096; + return adc_sample_channel(channel); }