@@ -514,6 +514,13 @@ void SFE_UBLOX_GNSS::setI2CpollingWait(uint8_t newPollingWait_ms)
514
514
i2cPollingWait = newPollingWait_ms;
515
515
}
516
516
517
+ // Allow the user to change SPI polling wait
518
+ // (the minimum interval between SPI data requests when no data is available - to avoid pounding the bus)
519
+ void SFE_UBLOX_GNSS::setSPIpollingWait(uint8_t newPollingWait_ms)
520
+ {
521
+ spiPollingWait = newPollingWait_ms;
522
+ }
523
+
517
524
//Sets the global size for I2C transactions
518
525
//Most platforms use 32 bytes (the default) but this allows users to increase the transaction
519
526
//size if the platform supports it
@@ -664,7 +671,7 @@ const char *SFE_UBLOX_GNSS::statusString(sfe_ublox_status_e stat)
664
671
return "None";
665
672
}
666
673
667
- // Check for the arrival of new I2C/Serial data
674
+ // Check for the arrival of new I2C/Serial/SPI data
668
675
669
676
//Allow the user to disable the "7F" check (e.g.) when logging RAWX data
670
677
void SFE_UBLOX_GNSS::disableUBX7Fcheck(boolean disabled)
@@ -860,8 +867,20 @@ boolean SFE_UBLOX_GNSS::checkUbloxSpi(ubxPacket *incomingUBX, uint8_t requestedC
860
867
_spiPort->beginTransaction(SPISettings(_spiSpeed, MSBFIRST, SPI_MODE0));
861
868
digitalWrite(_csPin, LOW);
862
869
uint8_t byteReturned = _spiPort->transfer(0xFF);
863
- // Note to future self: I think the 0xFF check will cause problems when attempting to process (e.g.) RAWX data
864
- // which could legitimately contain 0xFF within the data stream
870
+
871
+ // Note to future self: I think the 0xFF check might cause problems when attempting to process (e.g.) RAWX data
872
+ // which could legitimately contain 0xFF within the data stream. But the currentSentence check will certainly help!
873
+
874
+ // If we are not receiving a sentence (currentSentence == NONE) and the byteReturned is 0xFF,
875
+ // i.e. the module has no data for us, then delay for
876
+ if ((byteReturned == 0xFF) && (currentSentence == NONE))
877
+ {
878
+ digitalWrite(_csPin, HIGH);
879
+ _spiPort->endTransaction();
880
+ delay(spiPollingWait);
881
+ return (true);
882
+ }
883
+
865
884
while (byteReturned != 0xFF || currentSentence != NONE)
866
885
{
867
886
process(byteReturned, incomingUBX, requestedClass, requestedID);
@@ -3208,7 +3227,7 @@ sfe_ublox_status_e SFE_UBLOX_GNSS::waitForACKResponse(ubxPacket *outgoingUBX, ui
3208
3227
3209
3228
} //checkUbloxInternal == true
3210
3229
3211
- delayMicroseconds(500);
3230
+ delay(1); // Allow an RTOS to get an elbow in (#11)
3212
3231
} //while (millis() - startTime < maxTime)
3213
3232
3214
3233
// We have timed out...
@@ -3318,7 +3337,7 @@ sfe_ublox_status_e SFE_UBLOX_GNSS::waitForNoACKResponse(ubxPacket *outgoingUBX,
3318
3337
}
3319
3338
}
3320
3339
3321
- delayMicroseconds(500);
3340
+ delay(1); // Allow an RTOS to get an elbow in (#11)
3322
3341
}
3323
3342
3324
3343
if (_printDebug == true)
0 commit comments