Skip to content

Commit 5d873c0

Browse files
authored
Add conditional compilation for second I2C interface based on SOC_I2C_NUM (#10408)
The ESP32, ESP32-S and ESP32-H series have two I2C interfaces, while the ESP32-C series has only one.
1 parent 733373a commit 5d873c0

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

libraries/Wire/src/Wire.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,8 @@ void TwoWire::onRequestService(uint8_t num, void *arg) {
646646
#endif /* SOC_I2C_SUPPORT_SLAVE */
647647

648648
TwoWire Wire = TwoWire(0);
649+
#if SOC_I2C_NUM > 1
649650
TwoWire Wire1 = TwoWire(1);
651+
#endif /* SOC_I2C_NUM */
650652

651653
#endif /* SOC_I2C_SUPPORTED */

libraries/Wire/src/Wire.h

+2
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,9 @@ class TwoWire : public HardwareI2C {
144144
};
145145

146146
extern TwoWire Wire;
147+
#if SOC_I2C_NUM > 1
147148
extern TwoWire Wire1;
149+
#endif /* SOC_I2C_NUM */
148150

149151
#endif /* SOC_I2C_SUPPORTED */
150152
#endif /* TwoWire_h */

0 commit comments

Comments
 (0)