From 451ee4ab2b2c8663b4dbfc8430f1ec17f47067ab Mon Sep 17 00:00:00 2001 From: Dominic Clifton Date: Fri, 26 Dec 2014 00:07:03 +0000 Subject: [PATCH] Move sensor alignment defaults into target.h files. --- src/main/sensors/initialisation.c | 71 ++++++++++++++++---------- src/main/target/CC3D/target.h | 8 ++- src/main/target/CHEBUZZF3/target.h | 6 +++ src/main/target/EUSTM32F103RC/target.h | 19 ++++--- src/main/target/NAZE/target.h | 13 +++++ src/main/target/OLIMEXINO/target.h | 22 ++++---- src/main/target/PORT103R/target.h | 19 ++++--- src/main/target/SPARKY/target.h | 6 +++ 8 files changed, 103 insertions(+), 61 deletions(-) diff --git a/src/main/sensors/initialisation.c b/src/main/sensors/initialisation.c index 3eaf74d49..f47dfc636 100644 --- a/src/main/sensors/initialisation.c +++ b/src/main/sensors/initialisation.c @@ -137,8 +137,8 @@ bool detectGyro(uint16_t gyroLpf) #ifdef USE_GYRO_MPU6050 if (mpu6050GyroDetect(selectMPU6050Config(), &gyro, gyroLpf)) { -#ifdef NAZE - gyroAlign = CW0_DEG; +#ifdef GYRO_MPU6050_ALIGN + gyroAlign = GYRO_MPU6050_ALIGN; #endif return true; } @@ -146,8 +146,8 @@ bool detectGyro(uint16_t gyroLpf) #ifdef USE_GYRO_L3G4200D if (l3g4200dDetect(&gyro, gyroLpf)) { -#ifdef NAZE - gyroAlign = CW0_DEG; +#ifdef GYRO_L3G4200D_ALIGN + gyroAlign = GYRO_L3G4200D_ALIGN; #endif return true; } @@ -155,8 +155,8 @@ bool detectGyro(uint16_t gyroLpf) #ifdef USE_GYRO_MPU3050 if (mpu3050Detect(&gyro, gyroLpf)) { -#ifdef NAZE - gyroAlign = CW0_DEG; +#ifdef GYRO_MPU3050_ALIGN + gyroAlign = GYRO_MPU3050_ALIGN; #endif return true; } @@ -164,14 +164,17 @@ bool detectGyro(uint16_t gyroLpf) #ifdef USE_GYRO_L3GD20 if (l3gd20Detect(&gyro, gyroLpf)) { +#ifdef GYRO_GYRO_L3GD20_ALIGN + gyroAlign = GYRO_GYRO_L3GD20_ALIGN; +#endif return true; } #endif #ifdef USE_GYRO_SPI_MPU6000 if (mpu6000SpiGyroDetect(&gyro, gyroLpf)) { -#ifdef CC3D - gyroAlign = CW270_DEG; +#ifdef GYRO_SPI_MPU6000_ALIGN + gyroAlign = GYRO_SPI_MPU6000_ALIGN; #endif return true; } @@ -180,12 +183,16 @@ bool detectGyro(uint16_t gyroLpf) #ifdef USE_GYRO_SPI_MPU6500 #ifdef NAZE if (hardwareRevision == NAZE32_SP && mpu6500SpiGyroDetect(&gyro, gyroLpf)) { - gyroAlign = CW0_DEG; +#ifdef GYRO_SPI_MPU6500_ALIGN + gyroAlign = GYRO_SPI_MPU6500_ALIGN; +#endif return true; } #else if (mpu6500SpiGyroDetect(&gyro, gyroLpf)) { - gyroAlign = CW0_DEG; +#ifdef GYRO_SPI_MPU6500_ALIGN + gyroAlign = GYRO_SPI_MPU6500_ALIGN; +#endif return true; } #endif @@ -227,11 +234,12 @@ retry: acc_params.dataRate = 800; // unused currently #ifdef NAZE if (hardwareRevision < NAZE32_REV5 && adxl345Detect(&acc_params, &acc)) { - accAlign = CW270_DEG; #else if (adxl345Detect(&acc_params, &acc)) { #endif - accHardware = ACC_ADXL345; +#ifdef ACC_ADXL345_ALIGN + accAlign = ACC_ADXL345_ALIGN; +#endif accHardware = ACC_ADXL345; if (accHardwareToUse == ACC_ADXL345) break; @@ -241,10 +249,10 @@ retry: #ifdef USE_ACC_MPU6050 case ACC_MPU6050: // MPU6050 if (mpu6050AccDetect(selectMPU6050Config(), &acc)) { - accHardware = ACC_MPU6050; -#ifdef NAZE - accAlign = CW0_DEG; +#ifdef ACC_MPU6050_ALIGN + accAlign = ACC_MPU6050_ALIGN; #endif + accHardware = ACC_MPU6050; if (accHardwareToUse == ACC_MPU6050) break; } @@ -255,9 +263,11 @@ retry: #ifdef NAZE // Not supported with this frequency if (hardwareRevision < NAZE32_REV5 && mma8452Detect(&acc)) { - accAlign = CW90_DEG; #else if (mma8452Detect(&acc)) { +#endif +#ifdef ACC_MMA8452_ALIGN + accAlign = ACC_MMA8452_ALIGN; #endif accHardware = ACC_MMA8452; if (accHardwareToUse == ACC_MMA8452) @@ -268,10 +278,10 @@ retry: #ifdef USE_ACC_BMA280 case ACC_BMA280: // BMA280 if (bma280Detect(&acc)) { - accHardware = ACC_BMA280; -#ifdef NAZE - accAlign = CW0_DEG; +#ifdef ACC_BMA280_ALIGN + accAlign = ACC_BMA280_ALIGN; #endif + accHardware = ACC_BMA280; if (accHardwareToUse == ACC_BMA280) break; } @@ -280,6 +290,9 @@ retry: #ifdef USE_ACC_LSM303DLHC case ACC_LSM303DLHC: if (lsm303dlhcAccDetect(&acc)) { +#ifdef ACC_LSM303DLHC_ALIGN + accAlign = ACC_LSM303DLHC_ALIGN; +#endif accHardware = ACC_LSM303DLHC; if (accHardwareToUse == ACC_LSM303DLHC) break; @@ -289,10 +302,10 @@ retry: #ifdef USE_ACC_SPI_MPU6000 case ACC_SPI_MPU6000: if (mpu6000SpiAccDetect(&acc)) { - accHardware = ACC_SPI_MPU6000; -#ifdef CC3D - accAlign = CW270_DEG; +#ifdef ACC_SPI_MPU6000_ALIGN + accAlign = ACC_SPI_MPU6000_ALIGN; #endif + accHardware = ACC_SPI_MPU6000; if (accHardwareToUse == ACC_SPI_MPU6000) break; } @@ -305,10 +318,10 @@ retry: #else if (mpu6500SpiAccDetect(&acc)) { #endif - accHardware = ACC_SPI_MPU6500; -#ifdef NAZE - accAlign = CW0_DEG; +#ifdef ACC_SPI_MPU6500_ALIGN + accAlign = ACC_SPI_MPU6500_ALIGN; #endif + accHardware = ACC_SPI_MPU6500; if (accHardwareToUse == ACC_SPI_MPU6500) break; } @@ -408,8 +421,8 @@ retry: #ifdef USE_MAG_HMC5883 case MAG_HMC5883: if (hmc5883lDetect(&mag, hmc5883Config)) { -#ifdef NAZE - magAlign = CW180_DEG; +#ifdef MAG_HMC5883_ALIGN + magAlign = MAG_HMC5883_ALIGN; #endif magHardware = MAG_HMC5883; if (magHardwareToUse == MAG_HMC5883) @@ -422,6 +435,10 @@ retry: #ifdef USE_MAG_AK8975 case MAG_AK8975: if (ak8975detect(&mag)) { + +#ifdef MAG_AK8975_ALIGN + magAlign = MAG_AK8975_ALIGN; +#endif magHardware = MAG_AK8975; if (magHardwareToUse == MAG_AK8975) break; diff --git a/src/main/target/CC3D/target.h b/src/main/target/CC3D/target.h index e8607dd05..44acf4630 100644 --- a/src/main/target/CC3D/target.h +++ b/src/main/target/CC3D/target.h @@ -35,11 +35,15 @@ #define MPU6000_CS_PIN GPIO_Pin_4 #define MPU6000_SPI_INSTANCE SPI1 +#define GYRO +#define USE_GYRO_SPI_MPU6000 + +#define GYRO_SPI_MPU6000_ALIGN CW270_DEG + #define ACC #define USE_ACC_SPI_MPU6000 -#define GYRO -#define USE_GYRO_SPI_MPU6000 +#define ACC_SPI_MPU6000_ALIGN CW270_DEG #define INVERTER #define BEEPER diff --git a/src/main/target/CHEBUZZF3/target.h b/src/main/target/CHEBUZZF3/target.h index 2b7cdd34f..3a28e955c 100644 --- a/src/main/target/CHEBUZZF3/target.h +++ b/src/main/target/CHEBUZZF3/target.h @@ -37,16 +37,22 @@ #define USE_GYRO_L3GD20 #define USE_GYRO_MPU6050 +#define GYRO_MPU6050_ALIGN CW0_DEG + #define ACC #define USE_ACC_MPU6050 #define USE_ACC_LSM303DLHC +#define ACC_MPU6050_ALIGN CW0_DEG + #define BARO #define USE_BARO_MS5611 #define MAG #define USE_MAG_AK8975 +#define MAG_AK8975_ALIGN CW90_DEG_FLIP + #define BEEPER #define LED0 #define LED1 diff --git a/src/main/target/EUSTM32F103RC/target.h b/src/main/target/EUSTM32F103RC/target.h index bb2245d37..fab0469b6 100644 --- a/src/main/target/EUSTM32F103RC/target.h +++ b/src/main/target/EUSTM32F103RC/target.h @@ -39,16 +39,6 @@ #define MPU6500_CS_PIN GPIO_Pin_12 #define MPU6500_SPI_INSTANCE SPI2 -#define ACC -#define USE_FAKE_ACC -#define USE_ACC_ADXL345 -#define USE_ACC_BMA280 -#define USE_ACC_MMA8452 -#define USE_ACC_MPU3050 -#define USE_ACC_MPU6050 -//#define USE_ACC_SPI_MPU6000 -#define USE_ACC_SPI_MPU6500 - #define GYRO #define USE_FAKE_GYRO #define USE_GYRO_L3G4200D @@ -58,6 +48,15 @@ #define USE_GYRO_SPI_MPU6000 #define USE_GYRO_SPI_MPU6500 +#define ACC +#define USE_FAKE_ACC +#define USE_ACC_ADXL345 +#define USE_ACC_BMA280 +#define USE_ACC_MMA8452 +#define USE_ACC_MPU6050 +//#define USE_ACC_SPI_MPU6000 +#define USE_ACC_SPI_MPU6500 + #define BARO #define USE_BARO_MS5611 #define USE_BARO_BMP085 diff --git a/src/main/target/NAZE/target.h b/src/main/target/NAZE/target.h index a176c9d87..f6cd2c45a 100644 --- a/src/main/target/NAZE/target.h +++ b/src/main/target/NAZE/target.h @@ -63,11 +63,22 @@ #define USE_GYRO_MPU3050 #define USE_GYRO_MPU6050 +#define GYRO_MPU3050_ALIGN CW0_DEG +#define GYRO_MPU6050_ALIGN CW0_DEG +#define GYRO_SPI_MPU6500_ALIGN CW0_DEG + #define ACC #define USE_ACC_ADXL345 #define USE_ACC_BMA280 #define USE_ACC_MMA8452 #define USE_ACC_MPU6050 +//#define ACC_SPI_MPU6500 + +#define ACC_ADXL345_ALIGN CW270_DEG +#define ACC_MPU6050_ALIGN CW0_DEG +#define ACC_MMA8452_ALIGN CW90_DEG +#define ACC_BMA280_ALIGN CW0_DEG +//#define ACC_SPI_MPU6500_ALIGN CW0_DEG #define BARO #define USE_BARO_MS5611 @@ -76,6 +87,8 @@ #define MAG #define USE_MAG_HMC5883 +#define MAG_HMC5883_ALIGN CW180_DEG + #define SONAR #define BEEPER #define LED0 diff --git a/src/main/target/OLIMEXINO/target.h b/src/main/target/OLIMEXINO/target.h index f74fe1c94..935ff691c 100644 --- a/src/main/target/OLIMEXINO/target.h +++ b/src/main/target/OLIMEXINO/target.h @@ -37,18 +37,6 @@ #define LED1 #endif - -#define ACC -#define USE_FAKE_ACC -//#define USE_ACC_ADXL345 -//#define USE_ACC_BMA280 -//#define USE_ACC_MMA8452 -//#define USE_ACC_LSM303DLHC -//#define USE_ACC_MPU3050 -#define USE_ACC_MPU6050 -//#define USE_ACC_SPI_MPU6000 -//#define USE_ACC_SPI_MPU6500 - #define GYRO #define USE_FAKE_GYRO //#define USE_GYRO_L3G4200D @@ -58,6 +46,16 @@ //#define USE_GYRO_SPI_MPU6000 //#define USE_GYRO_SPI_MPU6500 +#define ACC +#define USE_FAKE_ACC +//#define USE_ACC_ADXL345 +//#define USE_ACC_BMA280 +//#define USE_ACC_MMA8452 +//#define USE_ACC_LSM303DLHC +#define USE_ACC_MPU6050 +//#define USE_ACC_SPI_MPU6000 +//#define USE_ACC_SPI_MPU6500 + #define BARO //#define USE_BARO_MS5611 #define USE_BARO_BMP085 diff --git a/src/main/target/PORT103R/target.h b/src/main/target/PORT103R/target.h index b8a96ef34..6af8a46a3 100644 --- a/src/main/target/PORT103R/target.h +++ b/src/main/target/PORT103R/target.h @@ -46,16 +46,6 @@ #define MPU6500_CS_PIN GPIO_Pin_12 #define MPU6500_SPI_INSTANCE SPI2 -#define ACC -#define USE_FAKE_ACC -//#define USE_ACC_ADXL345 -//#define USE_ACC_BMA280 -//#define USE_ACC_MMA8452 -//#define USE_ACC_MPU3050 -#define USE_ACC_MPU6050 -//#define USE_ACC_SPI_MPU6000 -//#define USE_ACC_SPI_MPU6500 - #define GYRO #define USE_FAKE_GYRO //#define USE_GYRO_L3G4200D @@ -65,6 +55,15 @@ //#define USE_GYRO_SPI_MPU6000 //#define USE_GYRO_SPI_MPU6500 +#define ACC +#define USE_FAKE_ACC +//#define USE_ACC_ADXL345 +//#define USE_ACC_BMA280 +//#define USE_ACC_MMA8452 +#define USE_ACC_MPU6050 +//#define USE_ACC_SPI_MPU6000 +//#define USE_ACC_SPI_MPU6500 + #define BARO #define USE_BARO_MS5611 //#define USE_BARO_BMP085 diff --git a/src/main/target/SPARKY/target.h b/src/main/target/SPARKY/target.h index 6eba57907..7df62339d 100644 --- a/src/main/target/SPARKY/target.h +++ b/src/main/target/SPARKY/target.h @@ -30,15 +30,21 @@ #define GYRO #define USE_GYRO_MPU6050 +#define GYRO_MPU6050_ALIGN CW270_DEG + #define ACC #define USE_ACC_MPU6050 +#define ACC_MPU6050_ALIGN CW270_DEG + //#define BARO //#define USE_BARO_MS5611 #define MAG #define USE_MAG_AK8975 +#define MAG_AK8975_ALIGN CW0_DEG_FLIP + #define LED0 #define LED1