From b3f060d9ef4d999ef38c0995a325cfc6bc7ba248 Mon Sep 17 00:00:00 2001 From: Marcelo Bezerra <23555060+mmosca@users.noreply.github.com> Date: Tue, 23 Jul 2024 10:45:04 +0200 Subject: [PATCH] Make sure DEFAULT_I2C_DEVICE is always valid --- src/main/target/KAKUTEF4WING/target.h | 2 ++ src/main/target/common_post.h | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/main/target/KAKUTEF4WING/target.h b/src/main/target/KAKUTEF4WING/target.h index 70eb12564..cd8b74ac1 100644 --- a/src/main/target/KAKUTEF4WING/target.h +++ b/src/main/target/KAKUTEF4WING/target.h @@ -45,6 +45,8 @@ #define I2C2_SCL PB10 #define I2C2_SDA PB11 +#define DEFAULT_I2C_BUS BUS_I2C2 + // ********** External MAG On I2C2****** #define USE_MAG #define MAG_I2C_BUS BUS_I2C2 diff --git a/src/main/target/common_post.h b/src/main/target/common_post.h index d3ccf280b..9a85d14f1 100644 --- a/src/main/target/common_post.h +++ b/src/main/target/common_post.h @@ -29,6 +29,22 @@ extern uint8_t __config_end; # undef USE_OLED_UG2864 #endif + +// Make sure DEFAULT_I2C_BUS is valid +#ifndef DEFAULT_I2C_BUS + +#ifdef USE_I2C_DEVICE_1 +#define DEFAULT_I2C_BUS BUS_I2C1 +#elif USE_I2C_DEVICE_2 +#define DEFAULT_I2C_BUS BUS_I2C2 +#elif USE_I2C_DEVICE_3 +#define DEFAULT_I2C_BUS BUS_I2C3 +#elif USE_I2C_DEVICE_4 +#define DEFAULT_I2C_BUS BUS_I2C4 +#endif + +#endif + // Enable MSP_DISPLAYPORT for F3 targets without builtin OSD, // since it's used to display CMS on MWOSD #if !defined(USE_MSP_DISPLAYPORT) && !defined(USE_OSD) -- 2.11.4.GIT