Skip to content

Commit

Permalink
fix compilation without ACC (betaflight#14218)
Browse files Browse the repository at this point in the history
* fix compilation without ACC

- compilatiopn may fail with cryptic message when no ACC is
selected (unused variable `dev`). Mark dev as unused
- MPU6500 is handled differently than all other accs (it is only
driver that adds case labels)
- also make dev UNUSED for gyro

* Update src/main/sensors/acceleration_init.c

---------

Co-authored-by: Mark Haslinghuis <[email protected]>
  • Loading branch information
ledvinap and haslinghuis authored Feb 1, 2025
1 parent 79ecc1a commit e7f0486
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/main/sensors/acceleration_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,11 @@ static bool accDetect(accDev_t *dev, accelerationSensor_e accHardwareToUse)
FALLTHROUGH;
#endif

#if defined(USE_ACC_MPU6500) || defined(USE_ACC_SPI_MPU6500)
case ACC_MPU6500:
case ACC_ICM20601:
case ACC_ICM20602:
case ACC_ICM20608G:
#if defined(USE_ACC_MPU6500) || defined(USE_ACC_SPI_MPU6500)
#ifdef USE_ACC_SPI_MPU6500
if (mpu6500SpiAccDetect(dev)) {
#else
Expand All @@ -195,8 +195,8 @@ static bool accDetect(accDev_t *dev, accelerationSensor_e accHardwareToUse)
}
break;
}
#endif
FALLTHROUGH;
#endif

#ifdef USE_ACC_SPI_ICM20649
case ACC_ICM20649:
Expand Down Expand Up @@ -287,6 +287,7 @@ static bool accDetect(accDev_t *dev, accelerationSensor_e accHardwareToUse)

default:
case ACC_NONE: // disable ACC
UNUSED(dev);
accHardware = ACC_NONE;
break;
}
Expand Down
1 change: 1 addition & 0 deletions src/main/sensors/gyro_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,7 @@ STATIC_UNIT_TESTED gyroHardware_e gyroDetect(gyroDev_t *dev)
#endif

default:
UNUSED(dev);
gyroHardware = GYRO_NONE;
}

Expand Down

0 comments on commit e7f0486

Please sign in to comment.