mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-17 05:15:25 +03:00
Cleanup Fake GYRO and Fake ACC support.
This commit is contained in:
parent
8be5e63faa
commit
9b672791f4
1 changed files with 25 additions and 11 deletions
|
@ -39,6 +39,10 @@
|
||||||
#include "sensors_compass.h"
|
#include "sensors_compass.h"
|
||||||
#include "sensors_sonar.h"
|
#include "sensors_sonar.h"
|
||||||
|
|
||||||
|
// Use these to help with porting to new boards
|
||||||
|
//#define USE_FAKE_ACC
|
||||||
|
//#define USE_FAKE_GYRO
|
||||||
|
|
||||||
extern uint16_t batteryWarningVoltage;
|
extern uint16_t batteryWarningVoltage;
|
||||||
extern uint8_t batteryCellCount;
|
extern uint8_t batteryCellCount;
|
||||||
extern float magneticDeclination;
|
extern float magneticDeclination;
|
||||||
|
@ -47,6 +51,7 @@ extern gyro_t gyro;
|
||||||
extern baro_t baro;
|
extern baro_t baro;
|
||||||
extern acc_t acc;
|
extern acc_t acc;
|
||||||
|
|
||||||
|
#ifdef USE_FAKE_GYRO
|
||||||
static void fakeGyroInit(void) {}
|
static void fakeGyroInit(void) {}
|
||||||
static void fakeGyroRead(int16_t *gyroData) {}
|
static void fakeGyroRead(int16_t *gyroData) {}
|
||||||
static void fakeGyroReadTemp(int16_t *tempData) {}
|
static void fakeGyroReadTemp(int16_t *tempData) {}
|
||||||
|
@ -58,9 +63,11 @@ bool fakeGyroDetect(gyro_t *gyro, uint16_t lpf)
|
||||||
gyro->temperature = fakeGyroReadTemp;
|
gyro->temperature = fakeGyroReadTemp;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_FAKE_ACC
|
||||||
static void fakeAccInit(void) {}
|
static void fakeAccInit(void) {}
|
||||||
static void fakeAccRead(int16_t *gyroData) {}
|
static void fakeAccRead(int16_t *accData) {}
|
||||||
|
|
||||||
bool fakeAccDetect(acc_t *acc)
|
bool fakeAccDetect(acc_t *acc)
|
||||||
{
|
{
|
||||||
|
@ -69,7 +76,7 @@ bool fakeAccDetect(acc_t *acc)
|
||||||
acc->revisionCode = 0;
|
acc->revisionCode = 0;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef FY90Q
|
#ifdef FY90Q
|
||||||
// FY90Q analog gyro/acc
|
// FY90Q analog gyro/acc
|
||||||
|
@ -89,6 +96,11 @@ void sensorsAutodetect(sensorAlignmentConfig_t *sensorAlignmentConfig, uint16_t
|
||||||
memset(&acc, sizeof(acc), 0);
|
memset(&acc, sizeof(acc), 0);
|
||||||
memset(&gyro, sizeof(gyro), 0);
|
memset(&gyro, sizeof(gyro), 0);
|
||||||
|
|
||||||
|
#ifdef USE_FAKE_GYRO
|
||||||
|
if (fakeGyroDetect(&gyro, gyroLpf)) {
|
||||||
|
gyroAlign = ALIGN_DEFAULT;
|
||||||
|
#else
|
||||||
|
|
||||||
// Autodetect gyro hardware. We have MPU3050 or MPU6050.
|
// Autodetect gyro hardware. We have MPU3050 or MPU6050.
|
||||||
if (mpu6050Detect(&acc, &gyro, gyroLpf)) {
|
if (mpu6050Detect(&acc, &gyro, gyroLpf)) {
|
||||||
haveMpu6k = true;
|
haveMpu6k = true;
|
||||||
|
@ -100,8 +112,7 @@ void sensorsAutodetect(sensorAlignmentConfig_t *sensorAlignmentConfig, uint16_t
|
||||||
#ifdef STM32F3DISCOVERY
|
#ifdef STM32F3DISCOVERY
|
||||||
} else if (l3gd20Detect(&gyro, gyroLpf)) {
|
} else if (l3gd20Detect(&gyro, gyroLpf)) {
|
||||||
gyroAlign = ALIGN_DEFAULT;
|
gyroAlign = ALIGN_DEFAULT;
|
||||||
} else if (fakeGyroDetect(&gyro, gyroLpf)) {
|
#endif
|
||||||
gyroAlign = ALIGN_DEFAULT;
|
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
// if this fails, we get a beep + blink pattern. we're doomed, no gyro or i2c error.
|
// if this fails, we get a beep + blink pattern. we're doomed, no gyro or i2c error.
|
||||||
|
@ -111,6 +122,15 @@ void sensorsAutodetect(sensorAlignmentConfig_t *sensorAlignmentConfig, uint16_t
|
||||||
// Accelerometer. Fuck it. Let user break shit.
|
// Accelerometer. Fuck it. Let user break shit.
|
||||||
retry:
|
retry:
|
||||||
switch (accHardwareToUse) {
|
switch (accHardwareToUse) {
|
||||||
|
#ifdef USE_FAKE_ACC
|
||||||
|
default:
|
||||||
|
if (fakeAccDetect(&acc)) {
|
||||||
|
accHardware = ACC_FAKE;
|
||||||
|
accAlign = CW0_DEG; //
|
||||||
|
if (accHardwareToUse == ACC_FAKE)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#else
|
||||||
case ACC_NONE: // disable ACC
|
case ACC_NONE: // disable ACC
|
||||||
sensorsClear(SENSOR_ACC);
|
sensorsClear(SENSOR_ACC);
|
||||||
break;
|
break;
|
||||||
|
@ -159,13 +179,7 @@ retry:
|
||||||
if (accHardwareToUse == ACC_LSM303DLHC)
|
if (accHardwareToUse == ACC_LSM303DLHC)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// default:
|
#endif
|
||||||
// if (fakeAccDetect(&acc)) {
|
|
||||||
// accHardware = ACC_FAKE;
|
|
||||||
// accAlign = CW0_DEG; //
|
|
||||||
// if (accHardwareToUse == ACC_FAKE)
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue