free serial pins if gps_disabled is set

This commit is contained in:
Thomas Göttgens 2022-03-24 18:22:31 +01:00 committed by GitHub
parent cef1614770
commit 72f443c519
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -322,36 +322,38 @@ GPS *createGps()
#ifdef NO_GPS #ifdef NO_GPS
return nullptr; return nullptr;
#else #else
if (!radioConfig.preferences.gps_disabled){
#ifdef GPS_ALTITUDE_HAE #ifdef GPS_ALTITUDE_HAE
DEBUG_MSG("Using HAE altitude model\n"); DEBUG_MSG("Using HAE altitude model\n");
#else #else
DEBUG_MSG("Using MSL altitude model\n"); DEBUG_MSG("Using MSL altitude model\n");
#endif #endif
// If we don't have bidirectional comms, we can't even try talking to UBLOX // If we don't have bidirectional comms, we can't even try talking to UBLOX
#ifdef GPS_TX_PIN #ifdef GPS_TX_PIN
// Init GPS - first try ublox // Init GPS - first try ublox
UBloxGPS *ublox = new UBloxGPS(); UBloxGPS *ublox = new UBloxGPS();
if (!ublox->setup()) { if (!ublox->setup()) {
DEBUG_MSG("ERROR: No UBLOX GPS found\n"); DEBUG_MSG("ERROR: No UBLOX GPS found\n");
delete ublox; delete ublox;
ublox = NULL; ublox = NULL;
} else { } else {
return ublox; return ublox;
} }
#endif #endif
if (GPS::_serial_gps) { if (GPS::_serial_gps) {
// Some boards might have only the TX line from the GPS connected, in that case, we can't configure it at all. Just // Some boards might have only the TX line from the GPS connected, in that case, we can't configure it at all. Just
// assume NMEA at 9600 baud. // assume NMEA at 9600 baud.
DEBUG_MSG("Hoping that NMEA might work\n"); DEBUG_MSG("Hoping that NMEA might work\n");
#ifdef HAS_AIR530_GPS #ifdef HAS_AIR530_GPS
GPS *new_gps = new Air530GPS(); GPS *new_gps = new Air530GPS();
#else #else
GPS *new_gps = new NMEAGPS(); GPS *new_gps = new NMEAGPS();
#endif #endif
new_gps->setup(); new_gps->setup();
return new_gps; return new_gps;
}
} }
return nullptr; return nullptr;
#endif #endif