1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-15 12:25:20 +03:00

Reduce RAM usage of mpu6050 initialisation.

This commit is contained in:
Dominic Clifton 2014-10-16 01:10:23 +01:00
parent f5895b762f
commit 38dbe897d9
3 changed files with 30 additions and 26 deletions

View file

@ -67,23 +67,27 @@ extern gyro_t gyro;
extern baro_t baro;
extern acc_t acc;
mpu6050Config_t *generateMPU6050Config(void)
const mpu6050Config_t *selectMPU6050Config(void)
{
#ifdef NAZE
static mpu6050Config_t nazeMPU6050Config;
// MPU_INT output on rev4/5 hardware (PB13, PC13)
nazeMPU6050Config.gpioPin = Pin_13;
static const mpu6050Config_t nazeRev4MPU6050Config = {
.gpioAPB2Peripherals = RCC_APB2Periph_GPIOB,
.gpioPort = GPIOB,
.gpioPin = Pin_13
};
static const mpu6050Config_t nazeRev5MPU6050Config = {
.gpioAPB2Peripherals = RCC_APB2Periph_GPIOC,
.gpioPort = GPIOC,
.gpioPin = Pin_13
};
if (hardwareRevision < NAZE32_REV5) {
nazeMPU6050Config.gpioAPB2Peripherals = RCC_APB2Periph_GPIOB;
nazeMPU6050Config.gpioPort = GPIOB;
return &nazeRev4MPU6050Config;
} else {
nazeMPU6050Config.gpioAPB2Peripherals = RCC_APB2Periph_GPIOC;
nazeMPU6050Config.gpioPort = GPIOC;
return &nazeRev5MPU6050Config;
}
return &nazeMPU6050Config;
#endif
return NULL;
}
@ -127,7 +131,7 @@ bool detectGyro(uint16_t gyroLpf)
gyroAlign = ALIGN_DEFAULT;
#ifdef USE_GYRO_MPU6050
if (mpu6050GyroDetect(generateMPU6050Config(), &gyro, gyroLpf)) {
if (mpu6050GyroDetect(selectMPU6050Config(), &gyro, gyroLpf)) {
#ifdef NAZE
gyroAlign = CW0_DEG;
#endif
@ -231,7 +235,7 @@ retry:
#endif
#ifdef USE_ACC_MPU6050
case ACC_MPU6050: // MPU6050
if (mpu6050AccDetect(generateMPU6050Config(), &acc)) {
if (mpu6050AccDetect(selectMPU6050Config(), &acc)) {
accHardware = ACC_MPU6050;
#ifdef NAZE
accAlign = CW0_DEG;