mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-06-07 01:04:19 +08:00
Use HW independant overrideable defines to condition ADC V5 sensing & publishing
Use ADC_SCALED_V5_SENSE as apposed to legasy ADC_5V_RAIL_SENSE to populate
voltage5V_v
Then Scale the DN based on an overridable ADC_V5_V_FULL_SCALE value
This commit is contained in:
committed by
Lorenz Meier
parent
a5ec920756
commit
26b1e1fe0c
@@ -68,6 +68,7 @@
|
||||
#include <uORB/topics/adc_report.h>
|
||||
|
||||
#if defined(ADC_CHANNELS)
|
||||
|
||||
/*
|
||||
* Register accessors.
|
||||
* For now, no reason not to just use ADC1.
|
||||
@@ -347,16 +348,19 @@ ADC::update_system_power(hrt_abstime now)
|
||||
|
||||
system_power.voltage5V_v = 0;
|
||||
|
||||
#if defined(ADC_5V_RAIL_SENSE)
|
||||
/* HW provides ADC_SCALED_V5_SENSE */
|
||||
|
||||
# if defined(ADC_SCALED_V5_SENSE)
|
||||
|
||||
for (unsigned i = 0; i < _channel_count; i++) {
|
||||
if (_samples[i].am_channel == ADC_5V_RAIL_SENSE) {
|
||||
if (_samples[i].am_channel == ADC_SCALED_V5_SENSE) {
|
||||
// it is 2:1 scaled
|
||||
system_power.voltage5V_v = _samples[i].am_data * (6.6f / 4096);
|
||||
system_power.voltage5V_v = _samples[i].am_data * (ADC_V5_V_FULL_SCALE / 4096);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
# endif
|
||||
|
||||
/* Note once the board_config.h provides BOARD_ADC_USB_CONNECTED,
|
||||
* It must provide the true logic GPIO BOARD_ADC_xxxx macros.
|
||||
|
||||
Reference in New Issue
Block a user