Cleanup 32K capable gyro includes (#5523)

Added a `USE_32K_CAPABLE_GYRO` define set in `common_fc_post.h` that replaces the repeated testing for each gyro define wherever 32KHz compatibility is checked.
This commit is contained in:
etracer65 2018-03-24 01:02:27 -04:00 committed by Michael Keller
parent a8e86880f5
commit c8a646ebc3
4 changed files with 11 additions and 6 deletions

View File

@ -1291,7 +1291,7 @@ static bool blackboxWriteSysinfo(void)
BLACKBOX_PRINT_HEADER_LINE("yaw_deadband", "%d", rcControlsConfig()->yaw_deadband);
BLACKBOX_PRINT_HEADER_LINE("gyro_hardware_lpf", "%d", gyroConfig()->gyro_hardware_lpf);
#if defined(USE_GYRO_SPI_MPU6500) || defined(USE_GYRO_SPI_MPU9250) || defined(USE_GYRO_SPI_ICM20689)
#ifdef USE_32K_CAPABLE_GYRO
BLACKBOX_PRINT_HEADER_LINE("gyro_32khz_hardware_lpf", "%d", gyroConfig()->gyro_32khz_hardware_lpf);
#endif
BLACKBOX_PRINT_HEADER_LINE("gyro_lowpass_type", "%d", gyroConfig()->gyro_lowpass_type);

View File

@ -224,7 +224,7 @@ static const char * const lookupTableGyroHardwareLpf[] = {
"1KHZ_SAMPLING"
};
#if defined(USE_GYRO_SPI_MPU6500) || defined(USE_GYRO_SPI_MPU9250) || defined(USE_GYRO_SPI_ICM20689)
#ifdef USE_32K_CAPABLE_GYRO
static const char * const lookupTableGyro32khzHardwareLpf[] = {
"NORMAL",
"EXPERIMENTAL"
@ -345,7 +345,7 @@ const lookupTableEntry_t lookupTables[] = {
LOOKUP_TABLE_ENTRY(lookupTableRxSpi),
#endif
LOOKUP_TABLE_ENTRY(lookupTableGyroHardwareLpf),
#if defined(USE_GYRO_SPI_MPU6500) || defined(USE_GYRO_SPI_MPU9250) || defined(USE_GYRO_SPI_ICM20689)
#ifdef USE_32K_CAPABLE_GYRO
LOOKUP_TABLE_ENTRY(lookupTableGyro32khzHardwareLpf),
#endif
LOOKUP_TABLE_ENTRY(lookupTableAccHardware),
@ -394,7 +394,7 @@ const clivalue_t valueTable[] = {
// PG_GYRO_CONFIG
{ "align_gyro", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_ALIGNMENT }, PG_GYRO_CONFIG, offsetof(gyroConfig_t, gyro_align) },
{ "gyro_hardware_lpf", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_GYRO_HARDWARE_LPF }, PG_GYRO_CONFIG, offsetof(gyroConfig_t, gyro_hardware_lpf) },
#if defined(USE_GYRO_SPI_MPU6500) || defined(USE_GYRO_SPI_MPU9250) || defined(USE_GYRO_SPI_ICM20689)
#ifdef USE_32K_CAPABLE_GYRO
{ "gyro_32khz_hardware_lpf", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_GYRO_32KHZ_HARDWARE_LPF }, PG_GYRO_CONFIG, offsetof(gyroConfig_t, gyro_32khz_hardware_lpf) },
#endif
#if defined(USE_GYRO_SPI_ICM20649)
@ -424,7 +424,7 @@ const clivalue_t valueTable[] = {
{ "gyro_overflow_detect", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_GYRO_OVERFLOW_CHECK }, PG_GYRO_CONFIG, offsetof(gyroConfig_t, checkOverflow) },
#endif
#if defined(GYRO_USES_SPI)
#if defined(USE_GYRO_SPI_MPU6500) || defined(USE_GYRO_SPI_MPU9250) || defined(USE_GYRO_SPI_ICM20689)
#ifdef USE_32K_CAPABLE_GYRO
{ "gyro_use_32khz", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON }, PG_GYRO_CONFIG, offsetof(gyroConfig_t, gyro_use_32khz) },
#endif
#endif

View File

@ -46,7 +46,7 @@ typedef enum {
TABLE_RX_SPI,
#endif
TABLE_GYRO_HARDWARE_LPF,
#if defined(USE_GYRO_SPI_MPU6500) || defined(USE_GYRO_SPI_MPU9250) || defined(USE_GYRO_SPI_ICM20689)
#ifdef USE_32K_CAPABLE_GYRO
TABLE_GYRO_32KHZ_HARDWARE_LPF,
#endif
TABLE_ACC_HARDWARE,

View File

@ -106,3 +106,8 @@
#if !defined(USE_SDCARD)
#undef USE_USB_MSC
#endif
// Determine if the target could have a 32KHz capable gyro
#if defined(USE_GYRO_SPI_MPU6500) || defined(USE_GYRO_SPI_MPU9250) || defined(USE_GYRO_SPI_ICM20689)
#define USE_32K_CAPABLE_GYRO
#endif