Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BMI323 sfusion implementation #345

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
887 changes: 887 additions & 0 deletions lib/bmi323/bmi323_lib.cpp

Large diffs are not rendered by default.

459 changes: 459 additions & 0 deletions lib/bmi323/bmi323_lib.h

Large diffs are not rendered by default.

702 changes: 702 additions & 0 deletions lib/bmm350/bmm350.cpp

Large diffs are not rendered by default.

442 changes: 442 additions & 0 deletions lib/bmm350/bmm350.h

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/consts.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ enum class ImuID {
LSM6DSV,
LSM6DSO,
LSM6DSR,
BMI323,
Empty = 255
};

Expand All @@ -61,6 +62,7 @@ enum class ImuID {
#define IMU_LSM6DSV SoftFusionLSM6DSV
#define IMU_LSM6DSO SoftFusionLSM6DSO
#define IMU_LSM6DSR SoftFusionLSM6DSR
#define IMU_BMI323 SoftFusionBMI323
#define IMU_MPU6050_SF SoftFusionMPU6050

#define IMU_DEV_RESERVED 250 // Reserved, should not be used in any release firmware
Expand Down
24 changes: 21 additions & 3 deletions src/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
// ================================================

// Set parameters of IMU and board used
#define IMU IMU_BNO085
#define SECOND_IMU IMU
#define BOARD BOARD_SLIMEVR
#define IMU IMU_BMI323
#define SECOND_IMU IMU_BMI323
#define BOARD BOARD_CUSTOM
jojos38 marked this conversation as resolved.
Show resolved Hide resolved
#define IMU_ROTATION DEG_270
#define SECOND_IMU_ROTATION DEG_270

Expand Down Expand Up @@ -149,6 +149,24 @@ IMU_DESC_ENTRY(IMU_BMP160, PRIMARY_IMU_ADDRESS_ONE, IMU_ROTATION, PIN_IMU_SCL, P
// #define LED_INVERTED false
#elif BOARD == BOARD_CUSTOM
// Define pins by the examples above
#define PIN_IMU_SDA 4
#define PIN_IMU_SCL 5
#define PIN_IMU_INT 14
#define PIN_IMU_INT_2 12
#define PIN_BATTERY_LEVEL A0
#define LED_PIN 15
#define LED_INVERTED false
// The Wemos D1 mini has an internal voltage divider that I don't have on my custom board
// Therefor, BATTERY_SHIELD_RESISTANCE is set to 0 and SHIELD_R1 and R2 are adjusted instead
#ifndef BATTERY_SHIELD_RESISTANCE
#define BATTERY_SHIELD_RESISTANCE 0
#endif
#ifndef BATTERY_SHIELD_R1
#define BATTERY_SHIELD_R1 36
#endif
#ifndef BATTERY_SHIELD_R2
#define BATTERY_SHIELD_R2 123.5
#endif
jojos38 marked this conversation as resolved.
Show resolved Hide resolved
#elif BOARD == BOARD_WROOM32
#define PIN_IMU_SDA 21
#define PIN_IMU_SCL 22
Expand Down
2 changes: 2 additions & 0 deletions src/sensors/SensorManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include "softfusion/drivers/lsm6dso.h"
#include "softfusion/drivers/lsm6dsr.h"
#include "softfusion/drivers/mpu6050.h"
#include "softfusion/drivers/bmi323.h"

#include "softfusion/i2cimpl.h"

Expand All @@ -56,6 +57,7 @@ namespace SlimeVR
using SoftFusionLSM6DSO = SoftFusionSensor<SoftFusion::Drivers::LSM6DSO, SoftFusion::I2CImpl>;
using SoftFusionLSM6DSR = SoftFusionSensor<SoftFusion::Drivers::LSM6DSR, SoftFusion::I2CImpl>;
using SoftFusionMPU6050 = SoftFusionSensor<SoftFusion::Drivers::MPU6050, SoftFusion::I2CImpl>;
using SoftFusionBMI323 = SoftFusionSensor<SoftFusion::Drivers::BMI323, SoftFusion::I2CImpl>;

// TODO Make it more generic in the future and move another place (abstract sensor interface)
void SensorManager::swapI2C(uint8_t sclPin, uint8_t sdaPin)
Expand Down
Loading