Skip to content

Commit 71c09d2

Browse files
committed
Add basic I2C bus testing at startup
1 parent 683462d commit 71c09d2

File tree

4 files changed

+29
-4
lines changed

4 files changed

+29
-4
lines changed

Firmware/RTK_Surveyor/Begin.ino

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -476,8 +476,8 @@ void beginGNSS()
476476
//Configuration can take >1s so configure during splash
477477
void configureGNSS()
478478
{
479-
if(online.gnss == false) return;
480-
479+
if (online.gnss == false) return;
480+
481481
i2cGNSS.setAutoPVTcallbackPtr(&storePVTdata); // Enable automatic NAV PVT messages with callback to storePVTdata
482482
i2cGNSS.setAutoHPPOSLLHcallbackPtr(&storeHPdata); // Enable automatic NAV HPPOSLLH messages with callback to storeHPdata
483483

@@ -811,3 +811,24 @@ void beginIdleTasks()
811811
index); //Core where task should run, 0=core, 1=Arduino
812812
}
813813
}
814+
815+
void beginI2C()
816+
{
817+
Wire.begin(); //Start I2C on core 1
818+
//Wire.setClock(400000);
819+
820+
//begin/end wire transmission to see if bus is responding correctly
821+
//All good: 0ms, response 2
822+
//SDA/SCL shorted: 1000ms timeout, response 5
823+
//SCL/VCC shorted: 14ms, response 5
824+
//SCL/GND shorted: 1000ms, response 5
825+
//SDA/VCC shorted: 1000ms, reponse 5
826+
//SDA/GND shorted: 14ms, response 5
827+
unsigned long startTime = millis();
828+
Wire.beginTransmission(0x15); //Dummy address
829+
int endValue = Wire.endTransmission();
830+
if (endValue == 2)
831+
online.i2c = true;
832+
else
833+
Serial.println("Error: I2C Bus Not Responding");
834+
}

Firmware/RTK_Surveyor/RTK_Surveyor.ino

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -511,8 +511,7 @@ void setup()
511511

512512
beginIdleTasks();
513513

514-
Wire.begin(); //Start I2C on core 1
515-
//Wire.setClock(400000);
514+
beginI2C();
516515

517516
beginDisplay(); //Start display first to be able to display any errors
518517

Firmware/RTK_Surveyor/menuSystem.ino

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ void menuSystem()
88
Serial.println();
99
Serial.println("Menu: System Menu");
1010

11+
beginI2C();
12+
if (online.i2c == false)
13+
Serial.println("I2C: Offline - Something is causing bus problems");
14+
1115
Serial.print("GNSS: ");
1216
if (online.gnss == true)
1317
{

Firmware/RTK_Surveyor/settings.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,4 +452,5 @@ struct struct_online {
452452
bool txNtripDataCasting = false;
453453
bool lband = false;
454454
bool lbandCorrections = false;
455+
bool i2c = false;
455456
} online;

0 commit comments

Comments
 (0)