Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ main_sources(COMMON_SRC
drivers/accgyro/accgyro_icm20689.h
drivers/accgyro/accgyro_icm42605.c
drivers/accgyro/accgyro_icm42605.h
drivers/accgyro/accgyro_icm45686.c
drivers/accgyro/accgyro_icm45686.h
drivers/accgyro/accgyro_mpu.c
drivers/accgyro/accgyro_mpu.h
drivers/accgyro/accgyro_mpu6000.c
Expand Down
500 changes: 500 additions & 0 deletions src/main/drivers/accgyro/accgyro_icm45686.c

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions src/main/drivers/accgyro/accgyro_icm45686.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* This file is part of INAV.
*
* INAV is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* INAV is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with INAV. If not, see <http://www.gnu.org/licenses/>.
*/

#pragma once


bool icm45686AccDetect(accDev_t *acc);
bool icm45686GyroDetect(gyroDev_t *gyro);
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 @@ -30,6 +30,7 @@
#define ICM20689_WHO_AM_I_CONST (0x98)
#define ICM42605_WHO_AM_I_CONST (0x42)
#define ICM42688P_WHO_AM_I_CONST (0x47)
#define ICM45686_WHO_AM_I_CONST (0xE9)


// RA = Register Address
Expand Down Expand Up @@ -181,4 +182,4 @@ const gyroFilterAndRateConfig_t * mpuChooseGyroConfig(uint8_t desiredLpf, uint16
bool mpuGyroRead(struct gyroDev_s *gyro);
bool mpuGyroReadScratchpad(struct gyroDev_s *gyro);
bool mpuAccReadScratchpad(struct accDev_s *acc);
bool mpuTemperatureReadScratchpad(struct gyroDev_s *gyro, int16_t * data);
bool mpuTemperatureReadScratchpad(struct gyroDev_s *gyro, int16_t * data);
3 changes: 2 additions & 1 deletion src/main/drivers/bus.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ typedef enum {
DEVHW_ICM42605,
DEVHW_BMI270,
DEVHW_LSM6D,
DEVHW_ICM45686,
/* Combined ACC/GYRO/MAG chips */
DEVHW_MPU9250,

Expand Down Expand Up @@ -330,4 +331,4 @@ bool busWrite(const busDevice_t * busdev, uint8_t reg, uint8_t data);
bool busTransfer(const busDevice_t * dev, uint8_t * rxBuf, const uint8_t * txBuf, int length);
bool busTransferMultiple(const busDevice_t * dev, busTransferDescriptor_t * buffers, int count);

bool busIsBusy(const busDevice_t * dev);
bool busIsBusy(const busDevice_t * dev);
2 changes: 1 addition & 1 deletion src/main/fc/cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ static const char *debugModeNames[DEBUG_COUNT] = {
// sync with gyroSensor_e
static const char *const gyroNames[] = {
"NONE", "AUTO", "MPU6000", "MPU6500", "MPU9250", "BMI160",
"ICM20689", "BMI088", "ICM42605", "BMI270", "LSM6DXX", "FAKE"};
"ICM20689", "BMI088", "ICM42605", "BMI270", "LSM6DXX", "ICM45686", "FAKE"};

// sync this with sensors_e
static const char * const sensorTypeNames[] = {
Expand Down
2 changes: 1 addition & 1 deletion src/main/fc/settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ tables:
- name: alignment
values: ["DEFAULT", "CW0", "CW90", "CW180", "CW270", "CW0FLIP", "CW90FLIP", "CW180FLIP", "CW270FLIP"]
- name: acc_hardware
values: ["NONE", "AUTO", "MPU6000", "MPU6500", "MPU9250", "BMI160", "ICM20689", "BMI088", "ICM42605", "BMI270","LSM6DXX", "FAKE"]
values: ["NONE", "AUTO", "MPU6000", "MPU6500", "MPU9250", "BMI160", "ICM20689", "BMI088", "ICM42605", "BMI270","LSM6DXX", ICM45686, "FAKE"]
enum: accelerationSensor_e
- name: rangefinder_hardware
values: ["NONE", "SRF10", "VL53L0X", "MSP", "BENEWAKE", "VL53L1X", "US42", "TOF10120_I2C", "FAKE", "TERARANGER_EVO", "USD1_V0", "NRA"]
Expand Down
15 changes: 14 additions & 1 deletion src/main/sensors/acceleration.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#include "drivers/accgyro/accgyro_bmi270.h"
#include "drivers/accgyro/accgyro_icm20689.h"
#include "drivers/accgyro/accgyro_icm42605.h"
#include "drivers/accgyro/accgyro_icm45686.h"
#include "drivers/accgyro/accgyro_lsm6dxx.h"
#include "drivers/accgyro/accgyro_fake.h"
#include "drivers/sensor.h"
Expand Down Expand Up @@ -247,6 +248,18 @@ static bool accDetect(accDev_t *dev, accelerationSensor_e accHardwareToUse)
}
FALLTHROUGH;
#endif
#ifdef USE_IMU_ICM45686
case ACC_ICM45686:
if (icm45686AccDetect(dev)) {
accHardware = ACC_ICM45686;
break;
}
/* If we are asked for a specific sensor - break out, otherwise - fall through and continue */
if (accHardwareToUse != ACC_AUTODETECT) {
break;
}
FALLTHROUGH;
#endif
#ifdef USE_IMU_FAKE
case ACC_FAKE:
if (fakeAccDetect(dev)) {
Expand Down Expand Up @@ -696,4 +709,4 @@ void accInitFilters(void)
bool accIsHealthy(void)
{
return true;
}
}
3 changes: 2 additions & 1 deletion src/main/sensors/acceleration.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ typedef enum {
ACC_ICM42605,
ACC_BMI270,
ACC_LSM6DXX,
ACC_ICM45686,
ACC_FAKE,
ACC_MAX = ACC_FAKE
} accelerationSensor_e;
Expand Down Expand Up @@ -97,4 +98,4 @@ void accSetCalibrationValues(void);
void accInitFilters(void);
bool accIsHealthy(void);
bool accGetCalibrationAxisStatus(int axis);
uint8_t accGetCalibrationAxisFlags(void);
uint8_t accGetCalibrationAxisFlags(void);
12 changes: 11 additions & 1 deletion src/main/sensors/gyro.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
#include "drivers/accgyro/accgyro_bmi270.h"
#include "drivers/accgyro/accgyro_icm20689.h"
#include "drivers/accgyro/accgyro_icm42605.h"
#include "drivers/accgyro/accgyro_icm45686.h"
#include "drivers/accgyro/accgyro_lsm6dxx.h"
#include "drivers/accgyro/accgyro_fake.h"
#include "drivers/io.h"
Expand Down Expand Up @@ -228,6 +229,15 @@ STATIC_UNIT_TESTED gyroSensor_e gyroDetect(gyroDev_t *dev, gyroSensor_e gyroHard
FALLTHROUGH;
#endif

#ifdef USE_IMU_ICM45686
case GYRO_ICM45686:
if (icm45686GyroDetect(dev)) {
gyroHardware = GYRO_ICM45686;
break;
}
FALLTHROUGH;
#endif

#ifdef USE_IMU_FAKE
case GYRO_FAKE:
if (fakeGyroDetect(dev)) {
Expand Down Expand Up @@ -609,4 +619,4 @@ void gyroUpdateDynamicLpf(float cutoffFreq) {
float averageAbsGyroRates(void)
{
return (fabsf(gyro.gyroADCf[ROLL]) + fabsf(gyro.gyroADCf[PITCH]) + fabsf(gyro.gyroADCf[YAW])) / 3.0f;
}
}
4 changes: 2 additions & 2 deletions src/main/sensors/gyro.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ typedef enum {
GYRO_ICM42605,
GYRO_BMI270,
GYRO_LSM6DXX,
GYRO_ICM45686,
GYRO_FAKE

} gyroSensor_e;

typedef enum {
Expand Down Expand Up @@ -120,4 +120,4 @@ bool gyroReadTemperature(void);
int16_t gyroGetTemperature(void);
int16_t gyroRateDps(int axis);
void gyroUpdateDynamicLpf(float cutoffFreq);
float averageAbsGyroRates(void);
float averageAbsGyroRates(void);
6 changes: 5 additions & 1 deletion src/main/target/common_hardware.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@
BUSDEV_REGISTER_SPI(busdev_lsm6dxx, DEVHW_LSM6D, LSM6DXX_SPI_BUS, LSM6DXX_CS_PIN, NONE, DEVFLAGS_NONE, IMU_LSM6DXX_ALIGN);
#endif

#if defined(USE_IMU_ICM45686)
BUSDEV_REGISTER_SPI(busdev_icm45686, DEVHW_ICM45686, ICM45686_SPI_BUS, ICM45686_CS_PIN, NONE, DEVFLAGS_NONE, IMU_ICM45686_ALIGN);
#endif

#endif


Expand Down Expand Up @@ -473,4 +477,4 @@
BUSDEV_REGISTER_I2C(busdev_pcf8574, DEVHW_PCF8574, PCF8574_I2C_BUS, 0x20, NONE, DEVFLAGS_NONE, 0);
#endif

#endif // USE_TARGET_HARDWARE_DESCRIPTORS
#endif // USE_TARGET_HARDWARE_DESCRIPTORS