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"
42 uint8_t requestedSensors
[SENSOR_INDEX_COUNT
] = { GYRO_AUTODETECT
, ACC_NONE
, BARO_NONE
, MAG_NONE
, RANGEFINDER_NONE
, PITOT_NONE
, OPFLOW_NONE
};
43 uint8_t detectedSensors
[SENSOR_INDEX_COUNT
] = { GYRO_NONE
, ACC_NONE
, BARO_NONE
, MAG_NONE
, RANGEFINDER_NONE
, PITOT_NONE
, OPFLOW_NONE
};
46 bool sensorsAutodetect(void)
48 bool eepromUpdatePending
= false;
54 accInit(getLooptime());
68 #ifdef USE_TEMPERATURE_SENSOR
72 #ifdef USE_RANGEFINDER
80 if (accelerometerConfig()->acc_hardware
== ACC_AUTODETECT
) {
81 accelerometerConfigMutable()->acc_hardware
= detectedSensors
[SENSOR_INDEX_ACC
];
82 eepromUpdatePending
= true;
86 if (barometerConfig()->baro_hardware
== BARO_AUTODETECT
) {
87 barometerConfigMutable()->baro_hardware
= detectedSensors
[SENSOR_INDEX_BARO
];
88 eepromUpdatePending
= true;
93 if (compassConfig()->mag_hardware
== MAG_AUTODETECT
) {
94 compassConfigMutable()->mag_hardware
= detectedSensors
[SENSOR_INDEX_MAG
];
95 eepromUpdatePending
= true;
100 if (pitotmeterConfig()->pitot_hardware
== PITOT_AUTODETECT
) {
101 pitotmeterConfigMutable()->pitot_hardware
= detectedSensors
[SENSOR_INDEX_PITOT
];
102 eepromUpdatePending
= true;
110 if (eepromUpdatePending
) {