Skip to content

Commit

Permalink
Adds missing ACCGYRO defines and remove legacy drivers (betaflight#14087
Browse files Browse the repository at this point in the history
)
  • Loading branch information
haslinghuis authored Dec 31, 2024
1 parent ef81595 commit 3892808
Show file tree
Hide file tree
Showing 26 changed files with 114 additions and 1,483 deletions.
20 changes: 0 additions & 20 deletions mk/source.mk
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,6 @@ ifneq ($(SIMULATOR_BUILD),yes)
COMMON_SRC += \
drivers/bus_spi.c \
drivers/serial_uart.c \
drivers/accgyro/accgyro_mpu3050.c \
drivers/accgyro/accgyro_mpu6050.c \
drivers/accgyro/accgyro_mpu6500.c \
drivers/accgyro/accgyro_mpu.c \
Expand Down Expand Up @@ -332,24 +331,6 @@ COMMON_SRC += \
drivers/vtx_rtc6705.c \
drivers/vtx_rtc6705_soft_spi.c

ifneq ($(GYRO_DEFINE),)

LEGACY_GYRO_DEFINES := USE_GYRO_L3GD20
ifneq ($(findstring $(GYRO_DEFINE),$(LEGACY_GYRO_DEFINES)),)

LEGACY_SRC := \
drivers/accgyro/legacy/accgyro_adxl345.c \
drivers/accgyro/legacy/accgyro_bma280.c \
drivers/accgyro/legacy/accgyro_l3g4200d.c \
drivers/accgyro/legacy/accgyro_lsm303dlhc.c \
drivers/accgyro/legacy/accgyro_mma845x.c

COMMON_SRC += $(LEGACY_SRC)
SPEED_OPTIMISED_SRC += $(LEGACY_SRC)

endif
endif

RX_SRC = \
drivers/rx/expresslrs_driver.c \
drivers/rx/rx_a7105.c \
Expand Down Expand Up @@ -425,7 +406,6 @@ SPEED_OPTIMISED_SRC += \
drivers/bus_spi.c \
drivers/serial_uart.c \
drivers/accgyro/accgyro_mpu.c \
drivers/accgyro/accgyro_mpu3050.c \
drivers/accgyro/accgyro_spi_bmi160.c \
drivers/accgyro/accgyro_spi_bmi270.c \
drivers/accgyro/accgyro_spi_lsm6dso.c
Expand Down
43 changes: 37 additions & 6 deletions src/main/cli/settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,16 +143,47 @@
// Sensor names (used in lookup tables for *_hardware settings and in status command output)
// sync with accelerationSensor_e
const char * const lookupTableAccHardware[] = {
"AUTO", "NONE", "ADXL345", "MPU6050", "MMA8452", "BMA280", "LSM303DLHC",
"MPU6000", "MPU6500", "MPU9250", "ICM20601", "ICM20602", "ICM20608G", "ICM20649", "ICM20689", "ICM42605", "ICM42688P",
"BMI160", "BMI270", "LSM6DSO", "LSM6DSV16X", "VIRTUAL"
"AUTO",
"NONE",
"MPU6050",
"MPU6000",
"MPU6500",
"MPU9250",
"ICM20601",
"ICM20602",
"ICM20608G",
"ICM20649",
"ICM20689",
"ICM42605",
"ICM42688P",
"BMI160",
"BMI270",
"LSM6DSO",
"LSM6DSV16X",
"VIRTUAL"
};

// sync with gyroHardware_e
const char * const lookupTableGyroHardware[] = {
"AUTO", "NONE", "MPU6050", "L3G4200D", "MPU3050", "L3GD20",
"MPU6000", "MPU6500", "MPU9250", "ICM20601", "ICM20602", "ICM20608G", "ICM20649", "ICM20689", "ICM42605", "ICM42688P",
"BMI160", "BMI270", "LSM6DSO", "LSM6DSV16X", "VIRTUAL"
"AUTO",
"NONE",
"MPU6050",
"L3GD20",
"MPU6000",
"MPU6500",
"MPU9250",
"ICM20601",
"ICM20602",
"ICM20608G",
"ICM20649",
"ICM20689",
"ICM42605",
"ICM42688P",
"BMI160",
"BMI270",
"LSM6DSO",
"LSM6DSV16X",
"VIRTUAL"
};

#if defined(USE_SENSOR_NAMES) || defined(USE_BARO)
Expand Down
3 changes: 1 addition & 2 deletions src/main/drivers/accgyro/accgyro.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,11 @@
#define GYRO_SCALE_2000DPS (2000.0f / (1 << 15)) // 16.384 dps/lsb scalefactor for 2000dps sensors
#define GYRO_SCALE_4000DPS (4000.0f / (1 << 15)) // 8.192 dps/lsb scalefactor for 4000dps sensors

// Gyro hardware types were updated in PR #14087 (removed GYRO_L3G4200D, GYRO_MPU3050)
typedef enum {
GYRO_NONE = 0,
GYRO_DEFAULT,
GYRO_MPU6050,
GYRO_L3G4200D,
GYRO_MPU3050,
GYRO_L3GD20,
GYRO_MPU6000,
GYRO_MPU6500,
Expand Down
2 changes: 0 additions & 2 deletions src/main/drivers/accgyro/accgyro_mpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
#include "drivers/time.h"

#include "drivers/accgyro/accgyro.h"
#include "drivers/accgyro/accgyro_mpu3050.h"
#include "drivers/accgyro/accgyro_mpu6050.h"
#include "drivers/accgyro/accgyro_mpu6500.h"
#include "drivers/accgyro/accgyro_spi_bmi160.h"
Expand Down Expand Up @@ -452,7 +451,6 @@ bool mpuDetect(gyroDev_t *gyro, const gyroDeviceConfig_t *config)

if (ack) {
busDeviceRegister(&gyro->dev);
// If an MPU3050 is connected sig will contain 0.
uint8_t inquiryResult;
ack = busReadRegisterBuffer(&gyro->dev, MPU_RA_WHO_AM_I_LEGACY, &inquiryResult, 1);
inquiryResult &= MPU_INQUIRY_MASK;
Expand Down
114 changes: 0 additions & 114 deletions src/main/drivers/accgyro/accgyro_mpu3050.c

This file was deleted.

32 changes: 0 additions & 32 deletions src/main/drivers/accgyro/accgyro_mpu3050.h

This file was deleted.

7 changes: 7 additions & 0 deletions src/main/drivers/accgyro/accgyro_mpu6500.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@

#include "platform.h"

#if defined(USE_ACC_SPI_MPU6500) \
|| defined(USE_GYRO_SPI_MPU6500) \
|| defined(USE_ACC_MPU6500) \
|| defined(USE_GYRO_MPU6500)

#include "common/axis.h"
#include "common/maths.h"

Expand Down Expand Up @@ -108,3 +113,5 @@ bool mpu6500GyroDetect(gyroDev_t *gyro)

return true;
}

#endif // USE_ACC_SPI_MPU6500 || USE_GYRO_SPI_MPU6500 || USE_ACC_MPU6500 || USE_GYRO_MPU6500
4 changes: 4 additions & 0 deletions src/main/drivers/accgyro/accgyro_spi_icm20689.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

#include "platform.h"

#if defined(USE_ACC_SPI_ICM20689) || defined(USE_GYRO_SPI_ICM20689)

#include "common/axis.h"
#include "common/maths.h"

Expand Down Expand Up @@ -187,3 +189,5 @@ bool icm20689SpiGyroDetect(gyroDev_t *gyro)

return true;
}

#endif // USE_ACC_SPI_ICM20689 || USE_GYRO_SPI_ICM20689
4 changes: 4 additions & 0 deletions src/main/drivers/accgyro/accgyro_spi_mpu6500.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

#include "platform.h"

#if defined(USE_ACC_SPI_MPU6500) || defined(USE_GYRO_SPI_MPU6500)

#include "common/axis.h"
#include "common/maths.h"

Expand Down Expand Up @@ -146,3 +148,5 @@ bool mpu6500SpiGyroDetect(gyroDev_t *gyro)

return true;
}

#endif // USE_ACC_SPI_MPU6500 || USE_GYRO_SPI_MPU6500
4 changes: 4 additions & 0 deletions src/main/drivers/accgyro/accgyro_spi_mpu9250.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@

#include "platform.h"

#ifdef USE_ACC_SPI_MPU9250

#include "common/axis.h"
#include "common/maths.h"

Expand Down Expand Up @@ -173,3 +175,5 @@ bool mpu9250SpiGyroDetect(gyroDev_t *gyro)

return true;
}

#endif // USE_ACC_SPI_MPU9250
Loading

0 comments on commit 3892808

Please sign in to comment.