gpsread.cpp: add yield for thread safety
This commit is contained in:
parent
7d9d6d81c4
commit
fb82d05cae
@ -146,12 +146,14 @@ void gps_loop(void *pvParameters) {
|
|||||||
// feed GPS decoder with serial NMEA data from GPS device
|
// feed GPS decoder with serial NMEA data from GPS device
|
||||||
while (GPS_Serial.available()) {
|
while (GPS_Serial.available()) {
|
||||||
gps.encode(GPS_Serial.read());
|
gps.encode(GPS_Serial.read());
|
||||||
|
yield();
|
||||||
}
|
}
|
||||||
#elif defined GPS_I2C
|
#elif defined GPS_I2C
|
||||||
Wire.requestFrom(GPS_ADDR, 32); // caution: this is a blocking call
|
Wire.requestFrom(GPS_ADDR, 32); // caution: this is a blocking call
|
||||||
while (Wire.available()) {
|
while (Wire.available()) {
|
||||||
gps.encode(Wire.read());
|
gps.encode(Wire.read());
|
||||||
delay(2); // 2ms delay according L76 datasheet
|
delay(2); // 2ms delay according L76 datasheet
|
||||||
|
yield();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -170,7 +172,7 @@ void gps_loop(void *pvParameters) {
|
|||||||
// gps.passedChecksum(), gps.failedChecksum(),
|
// gps.passedChecksum(), gps.failedChecksum(),
|
||||||
// gps.sentencesWithFix());
|
// gps.sentencesWithFix());
|
||||||
|
|
||||||
delay(2); // yield to CPU
|
yield(); // yield to CPU
|
||||||
|
|
||||||
} // end of infinite loop
|
} // end of infinite loop
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user