@@ -514,6 +514,13 @@ void SFE_UBLOX_GNSS::setI2CpollingWait(uint8_t newPollingWait_ms)
514514 i2cPollingWait = newPollingWait_ms;
515515}
516516
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+
517524// Sets the global size for I2C transactions
518525// Most platforms use 32 bytes (the default) but this allows users to increase the transaction
519526// size if the platform supports it
@@ -664,7 +671,7 @@ const char *SFE_UBLOX_GNSS::statusString(sfe_ublox_status_e stat)
664671 return " None" ;
665672}
666673
667- // Check for the arrival of new I2C/Serial data
674+ // Check for the arrival of new I2C/Serial/SPI data
668675
669676// Allow the user to disable the "7F" check (e.g.) when logging RAWX data
670677void SFE_UBLOX_GNSS::disableUBX7Fcheck (boolean disabled)
@@ -860,8 +867,20 @@ boolean SFE_UBLOX_GNSS::checkUbloxSpi(ubxPacket *incomingUBX, uint8_t requestedC
860867 _spiPort->beginTransaction (SPISettings (_spiSpeed, MSBFIRST, SPI_MODE0));
861868 digitalWrite (_csPin, LOW);
862869 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+
865884 while (byteReturned != 0xFF || currentSentence != NONE)
866885 {
867886 process (byteReturned, incomingUBX, requestedClass, requestedID);
@@ -3208,7 +3227,7 @@ sfe_ublox_status_e SFE_UBLOX_GNSS::waitForACKResponse(ubxPacket *outgoingUBX, ui
32083227
32093228 } // checkUbloxInternal == true
32103229
3211- delayMicroseconds ( 500 );
3230+ delay ( 1 ); // Allow an RTOS to get an elbow in (#11)
32123231 } // while (millis() - startTime < maxTime)
32133232
32143233 // We have timed out...
@@ -3318,7 +3337,7 @@ sfe_ublox_status_e SFE_UBLOX_GNSS::waitForNoACKResponse(ubxPacket *outgoingUBX,
33183337 }
33193338 }
33203339
3321- delayMicroseconds ( 500 );
3340+ delay ( 1 ); // Allow an RTOS to get an elbow in (#11)
33223341 }
33233342
33243343 if (_printDebug == true )
0 commit comments