浏览代码

Make I2C pins configurable on ESP32

Thomas Buck 4 年前
父节点
当前提交
14242852ac
共有 2 个文件被更改,包括 8 次插入0 次删除
  1. 3
    0
      include/config_pins.h
  2. 5
    0
      src/Functionality.cpp

+ 3
- 0
include/config_pins.h 查看文件

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 查看文件

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");

正在加载...
取消
保存