@@ -1239,25 +1239,77 @@ void beginI2C()
1239
1239
// Assign I2C interrupts to the core that started the task. See: https://github.com/espressif/arduino-esp32/issues/3386
1240
1240
void pinI2CTask (void *pvParameters)
1241
1241
{
1242
+ bool i2cBusAvailable;
1243
+ uint32_t timer;
1244
+
1242
1245
Wire.begin (); // Start I2C on core the core that was chosen when the task was started
1243
1246
// Wire.setClock(400000);
1244
1247
1245
- // begin/end wire transmission to see if bus is responding correctly
1246
- // All good: 0ms, response 2
1247
- // SDA/SCL shorted: 1000ms timeout, response 5
1248
- // SCL/VCC shorted: 14ms, response 5
1249
- // SCL/GND shorted: 1000ms, response 5
1250
- // SDA/VCC shorted: 1000ms, reponse 5
1251
- // SDA/GND shorted: 14ms, response 5
1252
- Wire.beginTransmission (0x15 ); // Dummy address
1253
- int endValue = Wire.endTransmission ();
1254
- if (endValue == 2 )
1255
- online.i2c = true ;
1256
- else
1257
- systemPrintln (" Error: I2C Bus Not Responding" );
1248
+ // Display the device addresses
1249
+ i2cBusAvailable = false ;
1250
+ for (uint8_t addr = 0 ; addr < 127 ; addr++)
1251
+ {
1252
+ // begin/end wire transmission to see if the bus is responding correctly
1253
+ // All good: 0ms, response 2
1254
+ // SDA/SCL shorted: 1000ms timeout, response 5
1255
+ // SCL/VCC shorted: 14ms, response 5
1256
+ // SCL/GND shorted: 1000ms, response 5
1257
+ // SDA/VCC shorted: 1000ms, response 5
1258
+ // SDA/GND shorted: 14ms, response 5
1259
+ timer = millis ();
1260
+ i2cBus->beginTransmission (addr);
1261
+ if (i2cBus->endTransmission () == 0 )
1262
+ {
1263
+ i2cBusAvailable = true ;
1264
+ switch (addr)
1265
+ {
1266
+ default : {
1267
+ systemPrintf (" 0x%02x\r\n " , addr);
1268
+ break ;
1269
+ }
1258
1270
1259
- i2cPinned = true ;
1271
+ case 0x19 : {
1272
+ systemPrintf (" 0x%02x - LIS2DH12 Accelerometer\r\n " , addr);
1273
+ break ;
1274
+ }
1275
+
1276
+ case 0x36 : {
1277
+ systemPrintf (" 0x%02x - MAX17048 Fuel Guage\r\n " , addr);
1278
+ break ;
1279
+ }
1280
+
1281
+ case 0x3d : {
1282
+ systemPrintf (" 0x%02x - SSD1306 (64x48) OLED Driver\r\n " , addr);
1283
+ break ;
1284
+ }
1260
1285
1286
+ case 0x42 : {
1287
+ systemPrintf (" 0x%02x - u-blox ZED-F9P GNSS Receiver\r\n " , addr);
1288
+ break ;
1289
+ }
1290
+
1291
+ case 0x43 : {
1292
+ systemPrintf (" 0x%02x - u-blox NEO-D9S-00B Correction Data Receiver\r\n " , addr);
1293
+ break ;
1294
+ }
1295
+
1296
+ case 0x60 : {
1297
+ systemPrintf (" 0x%02x - Crypto Coprocessor\r\n " , addr);
1298
+ break ;
1299
+ }
1300
+ }
1301
+ }
1302
+ else if ((millis () - timer) > 3 )
1303
+ {
1304
+ systemPrintln (" Error: I2C Bus Not Responding" );
1305
+ i2cBusAvailable = false ;
1306
+ break ;
1307
+ }
1308
+ }
1309
+
1310
+ // Update the I2C status
1311
+ online.i2c = i2cBusAvailable;
1312
+ i2cPinned = true ;
1261
1313
vTaskDelete (nullptr ); // Delete task once it has run once
1262
1314
}
1263
1315
0 commit comments