70 lines
1.8 KiB
C
70 lines
1.8 KiB
C
/*
|
|
* This file is part of Cleanflight.
|
|
*
|
|
* Cleanflight is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* Cleanflight is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#include <stdbool.h>
|
|
#include <stdint.h>
|
|
#include <string.h>
|
|
|
|
#include "platform.h"
|
|
|
|
#include "common/utils.h"
|
|
|
|
#include "config/feature.h"
|
|
#include "pg/pg.h"
|
|
#include "pg/pg_ids.h"
|
|
|
|
#include "fc/config.h"
|
|
#include "fc/runtime_config.h"
|
|
|
|
#include "sensors/sensors.h"
|
|
#include "sensors/acceleration.h"
|
|
#include "sensors/barometer.h"
|
|
#include "sensors/gyro.h"
|
|
#include "sensors/compass.h"
|
|
#include "sensors/rangefinder.h"
|
|
#include "sensors/initialisation.h"
|
|
|
|
// requestedSensors is not actually used
|
|
uint8_t requestedSensors[SENSOR_INDEX_COUNT] = { GYRO_NONE, ACC_NONE, BARO_NONE, MAG_NONE, RANGEFINDER_NONE };
|
|
uint8_t detectedSensors[SENSOR_INDEX_COUNT] = { GYRO_NONE, ACC_NONE, BARO_NONE, MAG_NONE, RANGEFINDER_NONE };
|
|
|
|
bool sensorsAutodetect(void)
|
|
{
|
|
|
|
// gyro must be initialised before accelerometer
|
|
|
|
bool gyroDetected = gyroInit();
|
|
|
|
if (gyroDetected) {
|
|
accInit(gyro.targetLooptime);
|
|
}
|
|
|
|
#ifdef USE_MAG
|
|
compassInit();
|
|
#endif
|
|
|
|
#ifdef USE_BARO
|
|
baroDetect(&baro.dev, barometerConfig()->baro_hardware);
|
|
#endif
|
|
|
|
#ifdef USE_RANGEFINDER
|
|
rangefinderInit();
|
|
#endif
|
|
|
|
return gyroDetected;
|
|
}
|