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

initial ICM426xx support #891

Merged
merged 23 commits into from
Jun 1, 2023
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
764ea65
ICM426xx - very dont know
nerdCopter Sep 30, 2022
1acaaf6
ICM426xx - very dont know, part deaux
nerdCopter Mar 28, 2023
8996ba1
ICM426xx - very dont know, RUSHBLADEF7HD
nerdCopter Mar 28, 2023
1247359
ICM426xx - same; add accgyro_mpu.c; add icm 42688p to BETAFPVF722
nerdCopter Apr 3, 2023
3ee661e
ICM426xx - still finding missing elements
nerdCopter May 3, 2023
11ab40a
acc/gyro read change for icm426xx
Peck07 May 18, 2023
13c2c97
ICM42688P - DIAT_MAMBAF405_2022B; WIP; untested
nerdCopter May 24, 2023
05c1759
Adding ICM4xxxx to GEPRCF722_AIO
BeauBrewski May 25, 2023
80159ed
ICM42688P - JHEF_JHEF7DUAL; WIP; untested
nerdCopter May 25, 2023
8d0ae02
Merge remote-tracking branch 'upstream/20230518_ICM426xx_Peck07_fixed…
nerdCopter May 25, 2023
b071d65
ICM42688P - JHEF_JHEF7DUAL; WIP; not working; no USB connect
nerdCopter May 26, 2023
ed9dc77
ICM426xx - add CRAZYFLIE2 to unsupported targets due to build failure…
nerdCopter May 26, 2023
cd6e9e3
ICM426xx - fix out of band #endif
nerdCopter May 26, 2023
8c7ac73
ICM42688P - JHEF_JHEF7DUAL; WIP; untested
nerdCopter May 26, 2023
3c25c29
ICM42688P - modded existing JHEF7DUAL; new JHEF_JHEF7DUAL is not working
nerdCopter May 27, 2023
de8f05a
ICM466xx - fix BETAFPVF722 target
BeauBrewski May 28, 2023
cd92f98
ICM466xx - fix JHEF_JHEF7DUAL target
BeauBrewski May 28, 2023
c18e54a
ICM426xx - gyro_hardware_lpf modes
nerdCopter May 30, 2023
beb0cf8
ICM426xx - define USE_GYRO_DLPF_EXPERIMENTAL
nerdCopter May 31, 2023
fa49fa6
ICM426xx - add ICM42605_CS_PIN
nerdCopter May 31, 2023
2a3b820
ICM426xx - remove comma in lookupTableGyroHardwareLpf
nerdCopter May 31, 2023
12b2865
ICM426xx - target resets and removal
nerdCopter Jun 1, 2023
5a52aa3
ICM42688P - extra line removal
nerdCopter Jun 1, 2023
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 make/targets.mk
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ UNSUPPORTED_TARGETS := \
CRAZYBEEF3DX \
CRAZYBEEF3FR \
CRAZYBEEF3FS \
CRAZYFLIE2 \
CRAZYFLIE2BQ \
DOGE EACHIF3 \
FF_ACROWHOOPSP \
FF_KOMBINI \
Expand Down
2 changes: 2 additions & 0 deletions src/main/common/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ static inline int32_t cmp32(uint32_t a, uint32_t b) {
return (int32_t)(a - b);
}

static inline uint32_t llog2(uint32_t n) { return 31 - __builtin_clz(n | 1); }

// using memcpy_fn will force memcpy function call, instead of inlining it. In most cases function call takes fewer instructions
// than inlined version (inlining is cheaper for very small moves < 8 bytes / 2 store instructions)
#if defined(UNIT_TEST) || defined(SIMULATOR_BUILD)
Expand Down
5 changes: 5 additions & 0 deletions src/main/drivers/accgyro/accgyro.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
#define GYRO_32KHZ_HARDWARE_LPF_NORMAL 0
#define GYRO_32KHZ_HARDWARE_LPF_EXPERIMENTAL 1

#define GYRO_HARDWARE_LPF_OPTION_1 1
#define GYRO_HARDWARE_LPF_OPTION_2 2

#define GYRO_LPF_256HZ 0
#define GYRO_LPF_188HZ 1
#define GYRO_LPF_98HZ 2
Expand Down Expand Up @@ -91,6 +94,8 @@ typedef struct gyroDev_s {
ioTag_t mpuIntExtiTag;
uint8_t gyroHasOverflowProtection;
gyroSensor_e gyroHardware;
uint8_t accDataReg;
uint8_t gyroDataReg;
} gyroDev_t;

typedef struct accDev_s {
Expand Down
27 changes: 27 additions & 0 deletions src/main/drivers/accgyro/accgyro_mpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
#include "drivers/accgyro/accgyro_spi_bmi160.h"
#include "drivers/accgyro/accgyro_spi_icm20649.h"
#include "drivers/accgyro/accgyro_spi_icm20689.h"
#include "drivers/accgyro/accgyro_spi_icm426xx.h"
#include "drivers/accgyro/accgyro_spi_mpu6000.h"
#include "drivers/accgyro/accgyro_spi_mpu6500.h"
#include "drivers/accgyro/accgyro_spi_mpu9250.h"
Expand Down Expand Up @@ -365,6 +366,32 @@ static bool detectSPISensorsAndUpdateDetectionResult(gyroDev_t *gyro) {
return true;
}
#endif
#ifdef USE_GYRO_SPI_ICM42605
#ifdef ICM42605_SPI_INSTANCE
spiBusSetInstance(&gyro->bus, ICM42605_SPI_INSTANCE);
#endif
#ifdef ICM42605_CS_PIN
gyro->bus.busdev_u.spi.csnPin = gyro->bus.busdev_u.spi.csnPin == IO_NONE ? IOGetByTag(IO_TAG(ICM42605_CS_PIN)) : gyro->bus.busdev_u.spi.csnPin;
#endif
sensor = icm426xxSpiDetect(&gyro->bus);
if (sensor != MPU_NONE) {
gyro->mpuDetectionResult.sensor = sensor;
return true;
}
#endif
#ifdef USE_GYRO_SPI_ICM42688P
#ifdef ICM42688P_SPI_INSTANCE
spiBusSetInstance(&gyro->bus, ICM42688P_SPI_INSTANCE);
#endif
#ifdef ICM42688P_CS_PIN
gyro->bus.busdev_u.spi.csnPin = gyro->bus.busdev_u.spi.csnPin == IO_NONE ? IOGetByTag(IO_TAG(ICM42688P_CS_PIN)) : gyro->bus.busdev_u.spi.csnPin;
#endif
sensor = icm426xxSpiDetect(&gyro->bus);
if (sensor != MPU_NONE) {
gyro->mpuDetectionResult.sensor = sensor;
return true;
}
#endif
#ifdef USE_ACCGYRO_BMI160
#ifndef USE_DUAL_GYRO
spiBusSetInstance(&gyro->bus, BMI160_SPI_INSTANCE);
Expand Down
6 changes: 5 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_ICM20689) || defined(USE_GYRO_SPI_ICM42605) || defined(USE_GYRO_SPI_ICM42688P)
#define GYRO_USES_SPI
#endif

Expand All @@ -47,6 +47,8 @@
#define ICM20608G_WHO_AM_I_CONST (0xAF)
#define ICM20649_WHO_AM_I_CONST (0xE1)
#define ICM20689_WHO_AM_I_CONST (0x98)
#define ICM42605_WHO_AM_I_CONST (0x42)
#define ICM42688P_WHO_AM_I_CONST (0x47)

// RA = Register Address

Expand Down Expand Up @@ -214,6 +216,8 @@ typedef enum {
ICM_20608_SPI,
ICM_20649_SPI,
ICM_20689_SPI,
ICM_42605_SPI,
ICM_42688P_SPI,
BMI_160_SPI,
IMUF_9001_SPI,
} mpuSensor_e;
Expand Down
Loading