@@ -1057,6 +1057,10 @@ namespace lgfx
10571057#endif
10581058 }
10591059
1060+ #if defined ( ARDUINO ) && __has_include (<Wire.h>)
1061+ #elif __has_include(<driver/i2c_master.h>)
1062+ i2c_master_bus_handle_t i2c_bus_handle = nullptr ;
1063+ #endif
10601064 private:
10611065 uint32_t _reg_store[22 ];
10621066 };
@@ -1276,6 +1280,12 @@ namespace lgfx
12761280 #endif
12771281 #endif
12781282 #endif
1283+ #elif __has_include(<driver/i2c_master.h>)
1284+ auto bus_handle = i2c_context[i2c_port].i2c_bus_handle ;
1285+ if (bus_handle) {
1286+ i2c_context[i2c_port].i2c_bus_handle = nullptr ;
1287+ i2c_del_master_bus (bus_handle);
1288+ }
12791289#else
12801290 i2c_periph_disable (i2c_port);
12811291#endif
@@ -1370,6 +1380,20 @@ namespace lgfx
13701380 #else
13711381 twowire->begin ((int )pin_sda, (int )pin_scl);
13721382 #endif
1383+ #elif __has_include(<driver/i2c_master.h>)
1384+ i2c_master_bus_handle_t bus_handle = nullptr ;
1385+ i2c_master_bus_config_t bus_config;
1386+ memset (&bus_config, 0 , sizeof (i2c_master_bus_config_t ));
1387+ bus_config.i2c_port = i2c_port;
1388+ bus_config.sda_io_num = pin_sda;
1389+ bus_config.scl_io_num = pin_scl;
1390+ bus_config.clk_source = I2C_CLK_SRC_DEFAULT;
1391+ bus_config.glitch_ignore_cnt = 7 ;
1392+ bus_config.flags .enable_internal_pullup = true ;
1393+ bus_config.intr_priority = 1 ;
1394+
1395+ i2c_new_master_bus (&bus_config, &bus_handle);
1396+ i2c_context[i2c_port].i2c_bus_handle = bus_handle;
13731397#else
13741398 i2c_periph_enable (i2c_port);
13751399#endif
0 commit comments