mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-25 17:25:20 +03:00
If GPS serial data remains, reschedule task to run again after 1ms
This commit is contained in:
parent
aa4f0f7517
commit
7f147479fc
3 changed files with 13 additions and 4 deletions
|
@ -683,13 +683,19 @@ void gpsUpdate(timeUs_t currentTimeUs)
|
|||
timeUs_t executeTimeUs;
|
||||
gpsState_e gpsCurState = gpsData.state;
|
||||
|
||||
|
||||
// read out available GPS bytes
|
||||
if (gpsPort) {
|
||||
while (serialRxBytesWaiting(gpsPort) && (cmpTimeUs(micros(), currentTimeUs) < GPS_MAX_WAIT_DATA_RX)) {
|
||||
while (serialRxBytesWaiting(gpsPort)) {
|
||||
if (cmpTimeUs(micros(), currentTimeUs) > GPS_MAX_WAIT_DATA_RX) {
|
||||
// Wait 1ms and come back
|
||||
rescheduleTask(TASK_SELF, TASK_PERIOD_HZ(TASK_GPS_RATE_FAST));
|
||||
return;
|
||||
}
|
||||
gpsNewData(serialRead(gpsPort));
|
||||
}
|
||||
} else if (GPS_update & GPS_MSP_UPDATE) { // GPS data received via MSP
|
||||
// Restore default task rate
|
||||
rescheduleTask(TASK_SELF, TASK_PERIOD_HZ(TASK_GPS_RATE));
|
||||
} else if (GPS_update & GPS_MSP_UPDATE) { // GPS data received via MSP
|
||||
gpsSetState(GPS_STATE_RECEIVING_DATA);
|
||||
gpsData.lastMessage = millis();
|
||||
sensorsSet(SENSOR_GPS);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue