Add spiPollingWait and setSPIpollingWait. Change delayMicroseconds(500) to delay(1)
This commit is contained in:
@@ -86,6 +86,8 @@ void setup()
|
||||
while (1);
|
||||
}
|
||||
|
||||
//myGNSS.factoryDefault(); delay(5000); // Uncomment this line to reset the module back to its factory defaults
|
||||
|
||||
myGNSS.setPortOutput(COM_PORT_SPI, COM_TYPE_UBX); //Set the SPI port to output UBX only (turn off NMEA noise)
|
||||
myGNSS.saveConfigSelective(VAL_CFG_SUBSEC_IOPORT); //Save (only) the communications port settings to flash and BBR
|
||||
}
|
||||
|
||||
@@ -79,12 +79,14 @@ void setup()
|
||||
while (1);
|
||||
}
|
||||
|
||||
//myGNSS.factoryDefault(); delay(5000); // Uncomment this line to reset the module back to its factory defaults
|
||||
|
||||
myGNSS.setPortOutput(COM_PORT_SPI, COM_TYPE_UBX); //Set the SPI port to output UBX only (turn off NMEA noise)
|
||||
myGNSS.saveConfigSelective(VAL_CFG_SUBSEC_IOPORT); //Save (only) the communications port settings to flash and BBR
|
||||
|
||||
myGNSS.setNavigationFrequency(2); //Produce two solutions per second
|
||||
myGNSS.setAutoPVT(true); //Tell the GNSS to "send" each solution
|
||||
//myGNSS.saveConfiguration(); //Optional: Save the current settings to flash and BBR
|
||||
//myGNSS.saveConfiguration(); //Optional: Save _all_ the current settings to flash and BBR
|
||||
}
|
||||
|
||||
void loop()
|
||||
|
||||
@@ -53,6 +53,7 @@ setPacketCfgPayloadSize KEYWORD2
|
||||
begin KEYWORD2
|
||||
end KEYWORD2
|
||||
setI2CpollingWait KEYWORD2
|
||||
setSPIpollingWait KEYWORD2
|
||||
setI2CTransactionSize KEYWORD2
|
||||
getI2CTransactionSize KEYWORD2
|
||||
setSpiTransactionSize KEYWORD2
|
||||
|
||||
@@ -514,6 +514,13 @@ void SFE_UBLOX_GNSS::setI2CpollingWait(uint8_t newPollingWait_ms)
|
||||
i2cPollingWait = newPollingWait_ms;
|
||||
}
|
||||
|
||||
// Allow the user to change SPI polling wait
|
||||
// (the minimum interval between SPI data requests when no data is available - to avoid pounding the bus)
|
||||
void SFE_UBLOX_GNSS::setSPIpollingWait(uint8_t newPollingWait_ms)
|
||||
{
|
||||
spiPollingWait = newPollingWait_ms;
|
||||
}
|
||||
|
||||
//Sets the global size for I2C transactions
|
||||
//Most platforms use 32 bytes (the default) but this allows users to increase the transaction
|
||||
//size if the platform supports it
|
||||
@@ -664,7 +671,7 @@ const char *SFE_UBLOX_GNSS::statusString(sfe_ublox_status_e stat)
|
||||
return "None";
|
||||
}
|
||||
|
||||
// Check for the arrival of new I2C/Serial data
|
||||
// Check for the arrival of new I2C/Serial/SPI data
|
||||
|
||||
//Allow the user to disable the "7F" check (e.g.) when logging RAWX data
|
||||
void SFE_UBLOX_GNSS::disableUBX7Fcheck(boolean disabled)
|
||||
@@ -860,8 +867,20 @@ boolean SFE_UBLOX_GNSS::checkUbloxSpi(ubxPacket *incomingUBX, uint8_t requestedC
|
||||
_spiPort->beginTransaction(SPISettings(_spiSpeed, MSBFIRST, SPI_MODE0));
|
||||
digitalWrite(_csPin, LOW);
|
||||
uint8_t byteReturned = _spiPort->transfer(0xFF);
|
||||
// Note to future self: I think the 0xFF check will cause problems when attempting to process (e.g.) RAWX data
|
||||
// which could legitimately contain 0xFF within the data stream
|
||||
|
||||
// Note to future self: I think the 0xFF check might cause problems when attempting to process (e.g.) RAWX data
|
||||
// which could legitimately contain 0xFF within the data stream. But the currentSentence check will certainly help!
|
||||
|
||||
// If we are not receiving a sentence (currentSentence == NONE) and the byteReturned is 0xFF,
|
||||
// i.e. the module has no data for us, then delay for
|
||||
if ((byteReturned == 0xFF) && (currentSentence == NONE))
|
||||
{
|
||||
digitalWrite(_csPin, HIGH);
|
||||
_spiPort->endTransaction();
|
||||
delay(spiPollingWait);
|
||||
return (true);
|
||||
}
|
||||
|
||||
while (byteReturned != 0xFF || currentSentence != NONE)
|
||||
{
|
||||
process(byteReturned, incomingUBX, requestedClass, requestedID);
|
||||
@@ -3208,7 +3227,7 @@ sfe_ublox_status_e SFE_UBLOX_GNSS::waitForACKResponse(ubxPacket *outgoingUBX, ui
|
||||
|
||||
} //checkUbloxInternal == true
|
||||
|
||||
delayMicroseconds(500);
|
||||
delay(1); // Allow an RTOS to get an elbow in (#11)
|
||||
} //while (millis() - startTime < maxTime)
|
||||
|
||||
// We have timed out...
|
||||
@@ -3318,7 +3337,7 @@ sfe_ublox_status_e SFE_UBLOX_GNSS::waitForNoACKResponse(ubxPacket *outgoingUBX,
|
||||
}
|
||||
}
|
||||
|
||||
delayMicroseconds(500);
|
||||
delay(1); // Allow an RTOS to get an elbow in (#11)
|
||||
}
|
||||
|
||||
if (_printDebug == true)
|
||||
|
||||
@@ -577,6 +577,7 @@ public:
|
||||
void end(void); //Stop all automatic message processing. Free all used RAM
|
||||
|
||||
void setI2CpollingWait(uint8_t newPollingWait_ms); // Allow the user to change the I2C polling wait if required
|
||||
void setSPIpollingWait(uint8_t newPollingWait_ms); // Allow the user to change the SPI polling wait if required
|
||||
|
||||
//Set the max number of bytes set in a given I2C transaction
|
||||
uint8_t i2cTransactionSize = 32; //Default to ATmega328 limit
|
||||
@@ -1344,10 +1345,14 @@ private:
|
||||
sfe_ublox_packet_buffer_e activePacketBuffer = SFE_UBLOX_PACKET_PACKETBUF;
|
||||
|
||||
//Limit checking of new data to every X ms
|
||||
//If we are expecting an update every X Hz then we should check every half that amount of time
|
||||
//If we are expecting an update every X Hz then we should check every quarter that amount of time
|
||||
//Otherwise we may block ourselves from seeing new data
|
||||
uint8_t i2cPollingWait = 100; //Default to 100ms. Adjusted when user calls setNavigationFrequency() or setHNRNavigationRate() or setMeasurementRate()
|
||||
|
||||
//The SPI polling wait is a little different. checkUbloxSpi will delay for this amount before returning if
|
||||
//there is no data waiting to be read. This prevents waitForACKResponse from pounding the SPI bus too hard.
|
||||
uint8_t spiPollingWait = 9; //Default to 9ms; waitForACKResponse delays for 1ms on top of this. User can adjust with setSPIPollingWait.
|
||||
|
||||
unsigned long lastCheck = 0;
|
||||
|
||||
uint16_t ubxFrameCounter; //Count all UBX frame bytes. [Fixed header(2bytes), CLS(1byte), ID(1byte), length(2bytes), payload(x bytes), checksums(2bytes)]
|
||||
|
||||
Reference in New Issue
Block a user