Browse Source

Make I2C pins configurable on ESP32

Thomas Buck 3 years ago
parent
commit
14242852ac
2 changed files with 8 additions and 0 deletions
  1. 3
    0
      include/config_pins.h
  2. 5
    0
      src/Functionality.cpp

+ 3
- 0
include/config_pins.h View File

69
 #define SWITCH_COUNT 2
69
 #define SWITCH_COUNT 2
70
 #define SWITCH_PINS 22, 23
70
 #define SWITCH_PINS 22, 23
71
 
71
 
72
+#define I2C_SDA_PIN 21
73
+#define I2C_SCL_PIN 22
74
+
72
 #endif // FUNCTION_CONTROL
75
 #endif // FUNCTION_CONTROL
73
 
76
 
74
 #endif // PLATFORM_ESP
77
 #endif // PLATFORM_ESP

+ 5
- 0
src/Functionality.cpp View File

436
     
436
     
437
     debug.println("Initializing I2C Master");
437
     debug.println("Initializing I2C Master");
438
     Wire.setClock(I2C_BUS_SPEED);
438
     Wire.setClock(I2C_BUS_SPEED);
439
+    
440
+#if defined(I2C_SDA_PIN) && defined(I2C_SCL_PIN)
441
+    Wire.begin(I2C_SDA_PIN, I2C_SCL_PIN);
442
+#else
439
     Wire.begin();
443
     Wire.begin();
444
+#endif // defined(I2C_SDA_PIN) && defined(I2C_SCL_PIN)
440
     
445
     
441
 #ifdef DEBUG_WAIT_FOR_SERIAL_CONN
446
 #ifdef DEBUG_WAIT_FOR_SERIAL_CONN
442
     debug.println("Wait for Serial");
447
     debug.println("Wait for Serial");

Loading…
Cancel
Save