@@ -29,6 +29,41 @@ extern uint8_t __config_end;
2929# undef USE_OLED_UG2864
3030#endif
3131
32+
33+ // Make sure DEFAULT_I2C_BUS is valid
34+ #ifndef DEFAULT_I2C_BUS
35+
36+ #if defined(USE_I2C_DEVICE_1 )
37+ #define DEFAULT_I2C_BUS BUS_I2C1
38+ #elif defined(USE_I2C_DEVICE_2 )
39+ #define DEFAULT_I2C_BUS BUS_I2C2
40+ #elif defined(USE_I2C_DEVICE_3 )
41+ #define DEFAULT_I2C_BUS BUS_I2C3
42+ #elif defined(USE_I2C_DEVICE_4 )
43+ #define DEFAULT_I2C_BUS BUS_I2C4
44+ #endif
45+
46+ #endif
47+
48+ // Airspeed sensors
49+ #if defined(USE_PITOT ) && defined(DEFAULT_I2C_BUS )
50+
51+ #ifndef PITOT_I2C_BUS
52+ #define PITOT_I2C_BUS DEFAULT_I2C_BUS
53+ #endif
54+
55+ #endif
56+
57+ // Temperature sensors
58+ #if !defined(TEMPERATURE_I2C_BUS ) && defined(DEFAULT_I2C_BUS )
59+ #define TEMPERATURE_I2C_BUS DEFAULT_I2C_BUS
60+ #endif
61+
62+ // Rangefinder sensors
63+ #if !defined(RANGEFINDER_I2C_BUS ) && defined(DEFAULT_I2C_BUS )
64+ #define RANGEFINDER_I2C_BUS DEFAULT_I2C_BUS
65+ #endif
66+
3267// Enable MSP_DISPLAYPORT for F3 targets without builtin OSD,
3368// since it's used to display CMS on MWOSD
3469#if !defined(USE_MSP_DISPLAYPORT ) && !defined(USE_OSD )
@@ -67,6 +102,10 @@ extern uint8_t __config_end;
67102
68103#endif // USE_MAG_ALL
69104
105+ #if defined(DEFAULT_I2C_BUS ) && !defined(MAG_I2C_BUS )
106+ #define MAG_I2C_BUS DEFAULT_I2C_BUS
107+ #endif
108+
70109#endif // USE_MAG
71110
72111#if defined(USE_BARO )
@@ -84,6 +123,10 @@ extern uint8_t __config_end;
84123#define USE_BARO_SPL06
85124#endif
86125
126+ #if defined(DEFAULT_I2C_BUS ) && !defined(BARO_I2C_BUS )
127+ #define BARO_I2C_BUS DEFAULT_I2C_BUS
128+ #endif
129+
87130#endif
88131
89132#ifdef USE_ESC_SENSOR
0 commit comments