1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-18 22:05:17 +03:00

Moved gyro and acc detection code into init functions

This commit is contained in:
Martin Budden 2016-12-13 10:00:43 +00:00
parent d9a2f7f5d9
commit 17494840a5
5 changed files with 26 additions and 36 deletions

View file

@ -14,26 +14,17 @@
* 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/axis.h"
#include "common/utils.h"
#include "config/feature.h"
#include "drivers/accgyro_mpu.h"
#include "drivers/system.h"
#include "drivers/exti.h"
#include "drivers/sensor.h"
#include "drivers/accgyro.h"
#include "drivers/barometer.h"
#include "drivers/compass.h"
#include "drivers/sonar_hcsr04.h"
#include "fc/config.h"
#include "fc/runtime_config.h"
@ -45,11 +36,6 @@
#include "sensors/sonar.h"
#include "sensors/initialisation.h"
#ifdef USE_HARDWARE_REVISION_DETECTION
#include "hardware_revision.h"
#endif
uint8_t detectedSensors[SENSOR_INDEX_COUNT] = { GYRO_NONE, ACC_NONE, BARO_NONE, MAG_NONE };
@ -72,17 +58,12 @@ bool sensorsAutodetect(const gyroConfig_t *gyroConfig,
const barometerConfig_t *barometerConfig,
const sonarConfig_t *sonarConfig)
{
memset(&gyro, 0, sizeof(gyro));
if (!gyroDetect(&gyro.dev)) {
// gyro must be initialised before accelerometer
if (!gyroInit(gyroConfig)) {
return false;
}
// gyro must be initialised before accelerometer
gyroInit(gyroConfig);
memset(&acc, 0, sizeof(acc));
if (accDetect(&acc.dev, accelerometerConfig->acc_hardware)) {
accInit(gyro.targetLooptime);
}
accInit(accelerometerConfig, gyro.targetLooptime);
mag.magneticDeclination = 0.0f; // TODO investigate if this is actually needed if there is no mag sensor or if the value stored in the config should be used.
#ifdef MAG