Skip to content

Commit

Permalink
Cleaned up the inclusion of the microcode for BMI270.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeller committed Mar 11, 2020
1 parent acdccd5 commit ad4cc3d
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 98 deletions.
7 changes: 0 additions & 7 deletions lib/main/BoschSensortec/BMI270-Sensor-API/betaflight_info.txt
Expand Up @@ -4,10 +4,3 @@ Library download location:
https://github.com/BoschSensortec/BMI270-Sensor-API

The only file that is compiled as part of Betaflight is bmi270.c. This file contains the device microcode that must be uploaded during initialization.

When upgrading this library the bmi270.h header must have the following code block added:

// Betaflight modifications begin
#define BMI270_CONFIG_SIZE 8192
extern const uint8_t bmi270_config_file[BMI270_CONFIG_SIZE];
// Betaflight modifications end
5 changes: 0 additions & 5 deletions lib/main/BoschSensortec/BMI270-Sensor-API/bmi270.h
Expand Up @@ -130,8 +130,3 @@ int8_t bmi270_init(struct bmi2_dev *dev);
#endif /* End of CPP guard */

#endif /* BMI270_H_ */

// Betaflight modifications begin
#define BMI270_CONFIG_SIZE 8192
extern const uint8_t bmi270_config_file[BMI270_CONFIG_SIZE];
// Betaflight modifications end
1 change: 0 additions & 1 deletion make/source.mk
Expand Up @@ -189,7 +189,6 @@ COMMON_SRC = \
io/vtx_smartaudio.c \
io/vtx_tramp.c \
io/vtx_control.c \
./lib/main/BoschSensortec/BMI270-Sensor-API/bmi270.c

COMMON_DEVICE_SRC = \
$(CMSIS_SRC) \
Expand Down
12 changes: 8 additions & 4 deletions src/main/drivers/accgyro/accgyro_spi_bmi270.c
Expand Up @@ -35,12 +35,16 @@
#include "drivers/sensor.h"
#include "drivers/time.h"

// Include the device config (microcode) that must be uploaded to the sensor
#include "../../../../lib/main/BoschSensortec/BMI270-Sensor-API/bmi270.h"

#define BMI270_SPI_DIVISOR 16
#define BMI270_FIFO_FRAME_SIZE 6

#define BMI270_CONFIG_SIZE 8192

// Declaration for the device config (microcode) that must be uploaded to the sensor
extern const uint8_t bmi270_config_file[BMI270_CONFIG_SIZE];

#define BMI270_CHIP_ID 0x24

// BMI270 registers (not the complete list)
typedef enum {
BMI270_REG_CHIP_ID = 0x00,
Expand Down Expand Up @@ -168,7 +172,7 @@ static void bmi270UploadConfig(const busDevice_t *bus)
// Transfer the config file
IOLo(bus->busdev_u.spi.csnPin);
spiTransferByte(bus->busdev_u.spi.instance, BMI270_REG_INIT_DATA);
spiTransfer(bus->busdev_u.spi.instance, bmi270_config_file, NULL, BMI270_CONFIG_SIZE);
spiTransfer(bus->busdev_u.spi.instance, bmi270_config_file, NULL, sizeof(bmi270_config_file));
IOHi(bus->busdev_u.spi.csnPin);

delay(10);
Expand Down
55 changes: 0 additions & 55 deletions src/main/target/STM32F745/target.h

This file was deleted.

21 changes: 0 additions & 21 deletions src/main/target/STM32F745/target.mk

This file was deleted.

8 changes: 4 additions & 4 deletions src/main/target/STM32_UNIFIED/target.h
Expand Up @@ -25,6 +25,8 @@

#define USBD_PRODUCT_STRING "Betaflight STM32F405"

#define USE_ACCGYRO_BMI270

#define USE_I2C_DEVICE_1
#define USE_I2C_DEVICE_2
#define USE_I2C_DEVICE_3
Expand Down Expand Up @@ -112,6 +114,8 @@

#define USBD_PRODUCT_STRING "Betaflight STM32F745"

#define USE_ACCGYRO_BMI270

#define USE_I2C_DEVICE_1
#define USE_I2C_DEVICE_2
#define USE_I2C_DEVICE_3
Expand Down Expand Up @@ -166,10 +170,6 @@
#define USE_ACC_SPI_ICM20689
#define USE_GYRO_SPI_ICM20689

#if (TARGET_FLASH_SIZE > 512)
#define USE_ACCGYRO_BMI270
#endif

#define USE_MAG
#define USE_MAG_DATA_READY_SIGNAL
#define USE_MAG_HMC5883
Expand Down
4 changes: 3 additions & 1 deletion src/main/target/STM32_UNIFIED/target.mk
Expand Up @@ -13,8 +13,9 @@ else
ifeq ($(TARGET), STM32F7X2)
F7X2RE_TARGETS += $(TARGET)

else
else # STM32F745
F7X5XG_TARGETS += $(TARGET)

endif
endif
endif
Expand All @@ -23,6 +24,7 @@ FEATURES += VCP SDCARD_SPI SDCARD_SDIO ONBOARDFLASH

TARGET_SRC = \
$(addprefix drivers/accgyro/,$(notdir $(wildcard $(SRC_DIR)/drivers/accgyro/*.c))) \
$(ROOT)/lib/main/BoschSensortec/BMI270-Sensor-API/bmi270.c \
$(addprefix drivers/barometer/,$(notdir $(wildcard $(SRC_DIR)/drivers/barometer/*.c))) \
$(addprefix drivers/compass/,$(notdir $(wildcard $(SRC_DIR)/drivers/compass/*.c))) \
drivers/max7456.c \
Expand Down

0 comments on commit ad4cc3d

Please sign in to comment.