Skip to content

Commit

Permalink
BMI270 Support - FIFO config file 328 bytes (#930)
Browse files Browse the repository at this point in the history
* BMI270 - WIP - failing - incl IFRC_IFLIGHT_F745_AIO_V2 for testing (nerdCopter) (2023-06-20)
* bmi270 - add IFLIGHT_F745_AIO_V2 (nerdCopter from BeauBrewski)
* bmi270 - fix my obvious mistakes (nerdCopter)
* bmi270 - align ifrcf745aiov2 target (nerdCopter)
* BMI270 should compile on IFLIGHT_F745_AIO_V2 target (Peck07)
* add BMI270 support to BETAFPVF411 target (Peck07)
* Delete accgyro_spi_bmi270.c.newww (Peck07)
* change to OSD4 by default  (Peck07)(discussed with nerdCopter)
* put back a working getBmiOsrMode function  (Peck07)(discussed with nerdCopter)
* LPF_EXPERIMENTAL should give back OSR2  (Peck07)
* unneeded files cleanup and file move; target path change (nerdCopter)
* reorganize gyroRateKHz with switch/case; add bmi270 3.2 KHz (nerdCopter)
* bmi270 - more file cleanup (nerdCopter)
* bmi270 - switch/case - samplingTime (nerdCopter)
* bmi270 targets - really not sure about this CS_PIN stuff (nerdCopter)
* BMI270 - FOXEERF745_AIO (V2) (nerdCopter from BeauBrewski)
* BMI270 - NBD_INFINITYAIOV2PRO (nerdCopter)
* added SkystarsF7 target updates (BeauBrewski)
* fix FLYWOOF411_5IN1_AIO align (nerdCopter)
* BMI270 - gyro/pid denom default 1 (nerdCopter)
* BMI270 - GYRO_HARDWARE_LPF_EXPERIMENTAL 3 (nerdCopter)
* BMI270 - deduplicate spiCalculateDivider in bus_spi.h (nerdCopter)
* BMI270 - remove OWNER_GYRO_EXTI from resource.h to fix  breakage (nerdCopter)
* BMI270 - gyro_hardware_lpf options (USE_GYRO_DLPF_EXPERIMENTAL) (nerdCopter)
* BMI270 - replace OWNER_GYRO_EXTI with OWNER_MPU_EXTI (nerdCopter)
* BMI270 - fix NBD_INFINITYAIOV2PRO dual-gyro defines (nerdCopter)
* fix IFLIGHT_F745_AIO_V2 .mk (nerdCopter)
* BMI270 - add bmi gyros to accgyro_mpu.h ifdef (nerdCopter)
* BMI270 - fix detect - fixes requirement for mpu6000 defines (nerdCopter)
* BMI270 - ensure  over (nerdCopter)
* BMI270 - move bmi270_maximum_fifo_config_file constant (nerdCopter)
* BMI270 - remove extraneous fifo.c file inclusions (nerdCopter)
* BMI270 - comment spiCalculateDivider (nerdCopter)
* BMI270 - sync targets (nerdCopter)
* BMI270 - remove targets and targets modification from this PR (nerdCopter)
* BMI270 - emptyline cleanup (nerdCopter) (2023-10-31)

---------

Co-authored-by: Peck07 <[email protected]>
Co-authored-by: BeauBrewski <[email protected]>
  • Loading branch information
3 people authored Nov 1, 2023
1 parent 3fd882d commit b1cf5d0
Show file tree
Hide file tree
Showing 17 changed files with 605 additions and 19 deletions.
1 change: 1 addition & 0 deletions make/source.mk
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ SPEED_OPTIMISED_SRC := $(SPEED_OPTIMISED_SRC) \
drivers/accgyro/accgyro_mpu6050.c \
drivers/accgyro/accgyro_mpu6500.c \
drivers/accgyro/accgyro_spi_bmi160.c \
drivers/accgyro/accgyro_spi_bmi270.c \
drivers/accgyro/accgyro_spi_icm20689.c \
drivers/accgyro/accgyro_spi_mpu6000.c \
drivers/accgyro/accgyro_spi_mpu6500.c \
Expand Down
5 changes: 4 additions & 1 deletion src/main/drivers/accgyro/accgyro.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,17 @@
#include <pthread.h>
#endif

#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 sensor

#ifndef MPU_I2C_INSTANCE
#define MPU_I2C_INSTANCE I2C_DEVICE
#endif

#define GYRO_HARDWARE_LPF_NORMAL 0
#define GYRO_HARDWARE_LPF_1KHZ_SAMPLE 2

#if defined(USE_GYRO_SPI_ICM42688P)
#if defined(USE_GYRO_SPI_ICM42688P) || defined(USE_ACCGYRO_BMI270)
#define GYRO_HARDWARE_LPF_EXPERIMENTAL 3
#else
#define GYRO_HARDWARE_LPF_EXPERIMENTAL 1
Expand Down
14 changes: 14 additions & 0 deletions src/main/drivers/accgyro/accgyro_mpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
#include "drivers/accgyro/accgyro_mpu6050.h"
#include "drivers/accgyro/accgyro_mpu6500.h"
#include "drivers/accgyro/accgyro_spi_bmi160.h"
#include "drivers/accgyro/accgyro_spi_bmi270.h"
#include "drivers/accgyro/accgyro_spi_icm20649.h"
#include "drivers/accgyro/accgyro_spi_icm20689.h"
#include "drivers/accgyro/accgyro_spi_icm426xx.h"
Expand Down Expand Up @@ -404,6 +405,19 @@ static bool detectSPISensorsAndUpdateDetectionResult(gyroDev_t *gyro) {
gyro->mpuDetectionResult.sensor = sensor;
return true;
}
#endif
#ifdef USE_ACCGYRO_BMI270
#ifndef USE_DUAL_GYRO
spiBusSetInstance(&gyro->bus, BMI270_SPI_INSTANCE);
#endif
#ifdef BMI270_CS_PIN
gyro->bus.busdev_u.spi.csnPin = gyro->bus.busdev_u.spi.csnPin == IO_NONE ? IOGetByTag(IO_TAG(BMI270_CS_PIN)) : gyro->bus.busdev_u.spi.csnPin;
#endif
sensor = bmi270Detect(&gyro->bus);
if (sensor != MPU_NONE) {
gyro->mpuDetectionResult.sensor = sensor;
return true;
}
#endif
return false;
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/drivers/accgyro/accgyro_mpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
//#define DEBUG_MPU_DATA_READY_INTERRUPT

#if defined(USE_GYRO_SPI_MPU6500) || defined(USE_GYRO_SPI_MPU6000) || defined(USE_GYRO_SPI_MPU9250) || defined(USE_GYRO_SPI_ICM20649) \
|| defined(USE_GYRO_SPI_ICM20689) || defined(USE_GYRO_SPI_ICM42605) || defined(USE_GYRO_SPI_ICM42688P)
|| defined(USE_GYRO_SPI_ICM20689) || defined(USE_GYRO_SPI_ICM42605) || defined(USE_GYRO_SPI_ICM42688P) || defined(USE_ACCGYRO_BMI160) || defined(USE_ACCGYRO_BMI270)
#define GYRO_USES_SPI
#endif

Expand Down Expand Up @@ -219,6 +219,7 @@ typedef enum {
ICM_42605_SPI,
ICM_42688P_SPI,
BMI_160_SPI,
BMI_270_SPI,
IMUF_9001_SPI,
} mpuSensor_e;

Expand Down
Loading

0 comments on commit b1cf5d0

Please sign in to comment.