mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-15 21:03:34 +08:00
Merge branch 'adc_fix' into paul_estimator_mavlink2
This commit is contained in:
@@ -1171,16 +1171,19 @@ Sensors::adc_poll(struct sensor_combined_s &raw)
|
||||
hrt_abstime t = hrt_absolute_time();
|
||||
/* rate limit to 100 Hz */
|
||||
if (t - _last_adc >= 10000) {
|
||||
/* make space for a maximum of eight channels */
|
||||
struct adc_msg_s buf_adc[8];
|
||||
/* make space for a maximum of ten channels (to ensure reading all channels at once) */
|
||||
struct adc_msg_s buf_adc[10];
|
||||
/* read all channels available */
|
||||
int ret = read(_fd_adc, &buf_adc, sizeof(buf_adc));
|
||||
|
||||
if (ret >= (int)sizeof(buf_adc[0])) {
|
||||
for (unsigned i = 0; i < sizeof(buf_adc) / sizeof(buf_adc[0]); i++) {
|
||||
|
||||
/* Read add channels we got */
|
||||
for (unsigned i = 0; i < ret / sizeof(buf_adc[0]); i++) {
|
||||
/* Save raw voltage values */
|
||||
if (i < (sizeof(raw.adc_voltage_v)) / sizeof(raw.adc_voltage_v[0])) {
|
||||
if (i < (sizeof(raw.adc_voltage_v) / sizeof(raw.adc_voltage_v[0]))) {
|
||||
raw.adc_voltage_v[i] = buf_adc[i].am_data / (4096.0f / 3.3f);
|
||||
raw.adc_mapping[i] = buf_adc[i].am_channel;
|
||||
}
|
||||
|
||||
/* look for specific channels and process the raw voltage to measurement data */
|
||||
|
||||
@@ -98,7 +98,8 @@ struct sensor_combined_s {
|
||||
float baro_pres_mbar; /**< Barometric pressure, already temp. comp. */
|
||||
float baro_alt_meter; /**< Altitude, already temp. comp. */
|
||||
float baro_temp_celcius; /**< Temperature in degrees celsius */
|
||||
float adc_voltage_v[4]; /**< ADC voltages of ADC Chan 10/11/12/13 or -1 */
|
||||
float adc_voltage_v[9]; /**< ADC voltages of ADC Chan 10/11/12/13 or -1 */
|
||||
unsigned adc_mapping[9]; /**< Channel indices of each of these values */
|
||||
float mcu_temp_celcius; /**< Internal temperature measurement of MCU */
|
||||
uint64_t baro_timestamp; /**< Barometer timestamp */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user