2 * This file is part of Cleanflight.
4 * Cleanflight is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * Cleanflight is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
23 #include "common/utils.h"
25 #include "config/config_eeprom.h"
27 #include "fc/config.h"
28 #include "fc/runtime_config.h"
30 #include "sensors/acceleration.h"
31 #include "sensors/barometer.h"
32 #include "sensors/compass.h"
33 #include "sensors/gyro.h"
34 #include "sensors/initialisation.h"
35 #include "sensors/irlock.h"
36 #include "sensors/opflow.h"
37 #include "sensors/pitotmeter.h"
38 #include "sensors/rangefinder.h"
39 #include "sensors/sensors.h"
40 #include "sensors/temperature.h"
41 #include "sensors/temperature.h"
44 uint8_t requestedSensors
[SENSOR_INDEX_COUNT
] = { GYRO_AUTODETECT
, ACC_NONE
, BARO_NONE
, MAG_NONE
, RANGEFINDER_NONE
, PITOT_NONE
, OPFLOW_NONE
};
45 uint8_t detectedSensors
[SENSOR_INDEX_COUNT
] = { GYRO_NONE
, ACC_NONE
, BARO_NONE
, MAG_NONE
, RANGEFINDER_NONE
, PITOT_NONE
, OPFLOW_NONE
};
47 bool sensorsAutodetect(void)
49 bool eepromUpdatePending
= false;
55 accInit(getLooptime());
69 #ifdef USE_TEMPERATURE_SENSOR
73 #ifdef USE_RANGEFINDER
81 if (accelerometerConfig()->acc_hardware
== ACC_AUTODETECT
) {
82 accelerometerConfigMutable()->acc_hardware
= detectedSensors
[SENSOR_INDEX_ACC
];
83 eepromUpdatePending
= true;
87 if (barometerConfig()->baro_hardware
== BARO_AUTODETECT
) {
88 barometerConfigMutable()->baro_hardware
= detectedSensors
[SENSOR_INDEX_BARO
];
89 eepromUpdatePending
= true;
94 if (compassConfig()->mag_hardware
== MAG_AUTODETECT
) {
95 compassConfigMutable()->mag_hardware
= detectedSensors
[SENSOR_INDEX_MAG
];
96 eepromUpdatePending
= true;
101 if (pitotmeterConfig()->pitot_hardware
== PITOT_AUTODETECT
) {
102 pitotmeterConfigMutable()->pitot_hardware
= detectedSensors
[SENSOR_INDEX_PITOT
];
103 eepromUpdatePending
= true;
111 if (eepromUpdatePending
) {