mirror of
https://github.com/meshtastic/firmware.git
synced 2025-06-08 22:22:05 +00:00
Cleanup GPS, add UC6580 autodetect (#4319)
* Cleanup GPS, add UC6580 autodetect Our GPS code autodetects devices by default. Previously UC6580 was statically assigned, and had its own baudrate configuration inside the GPS code. This change adds autodetect functionality for the UC6580 and moves any 'special' GPS baud rate requirements for a variant out into the variant configuration. Thereby cleaning up core GPS code a little, saving the whales, and curing global warming. New Functionality: * If GPS_BAUDRATE is defined in variant.h, GPS autodetection will try that baudrate first. * UC6580 GPS chips are now automatically detected * Only run speedSelect skip the first time * Cleanup GPS, add UC6580 autodetect Our GPS code autodetects devices by default. Previously UC6580 was statically assigned, and had its own baudrate configuration inside the GPS code. This change adds autodetect functionality for the UC6580 and moves any 'special' GPS baud rate requirements for a variant out into the variant configuration. Thereby cleaning up core GPS code a little, saving the whales, and curing global warming. New Functionality: * If GPS_BAUDRATE is defined in variant.h, GPS autodetection will try that baudrate first. * UC6580 GPS chips are now automatically detected * Cleanup GPS, add UC6580 autodetect Our GPS code autodetects devices by default. Previously UC6580 was statically assigned, and had its own baudrate configuration inside the GPS code. This change adds autodetect functionality for the UC6580 and moves any 'special' GPS baud rate requirements for a variant out into the variant configuration. Thereby cleaning up core GPS code a little, saving the whales, and curing global warming. New Functionality: * If GPS_BAUDRATE is defined in variant.h, GPS autodetection will try that baudrate first. * UC6580 GPS chips are now automatically detected * Remove Airoha baud rate code It's no longer needed.
This commit is contained in:
parent
0d2a9b6282
commit
316928deb0
@ -171,10 +171,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// GPS
|
// GPS
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
#ifndef GPS_BAUDRATE
|
|
||||||
#define GPS_BAUDRATE 9600
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef GPS_THREAD_INTERVAL
|
#ifndef GPS_THREAD_INTERVAL
|
||||||
#define GPS_THREAD_INTERVAL 200
|
#define GPS_THREAD_INTERVAL 200
|
||||||
#endif
|
#endif
|
||||||
@ -185,6 +181,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
/* Step #1: offer chance for variant-specific defines */
|
/* Step #1: offer chance for variant-specific defines */
|
||||||
#include "variant.h"
|
#include "variant.h"
|
||||||
|
|
||||||
|
#ifndef GPS_BAUDRATE
|
||||||
|
#define GPS_BAUDRATE 9600
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Step #2: follow with defines common to the architecture;
|
/* Step #2: follow with defines common to the architecture;
|
||||||
also enable HAS_ option not specifically disabled by variant.h */
|
also enable HAS_ option not specifically disabled by variant.h */
|
||||||
#include "architecture.h"
|
#include "architecture.h"
|
||||||
@ -313,4 +313,4 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "DebugConfiguration.h"
|
#include "DebugConfiguration.h"
|
||||||
#include "RF95Configuration.h"
|
#include "RF95Configuration.h"
|
||||||
|
@ -400,14 +400,14 @@ bool GPS::setup()
|
|||||||
int msglen = 0;
|
int msglen = 0;
|
||||||
|
|
||||||
if (!didSerialInit) {
|
if (!didSerialInit) {
|
||||||
#ifdef GNSS_Airoha // change by WayenWeng
|
|
||||||
if (tx_gpio && gnssModel == GNSS_MODEL_UNKNOWN) {
|
|
||||||
probe(GPS_BAUDRATE);
|
|
||||||
LOG_INFO("GPS setting to %d.\n", GPS_BAUDRATE);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
#if !defined(GPS_UC6580)
|
|
||||||
if (tx_gpio && gnssModel == GNSS_MODEL_UNKNOWN) {
|
if (tx_gpio && gnssModel == GNSS_MODEL_UNKNOWN) {
|
||||||
|
|
||||||
|
// if GPS_BAUDRATE is specified in variant (i.e. not 9600), skip to the specified rate.
|
||||||
|
if (speedSelect == 0 && GPS_BAUDRATE != serialSpeeds[speedSelect]) {
|
||||||
|
speedSelect = std::find(serialSpeeds, std::end(serialSpeeds), GPS_BAUDRATE) - serialSpeeds;
|
||||||
|
}
|
||||||
|
|
||||||
LOG_DEBUG("Probing for GPS at %d \n", serialSpeeds[speedSelect]);
|
LOG_DEBUG("Probing for GPS at %d \n", serialSpeeds[speedSelect]);
|
||||||
gnssModel = probe(serialSpeeds[speedSelect]);
|
gnssModel = probe(serialSpeeds[speedSelect]);
|
||||||
if (gnssModel == GNSS_MODEL_UNKNOWN) {
|
if (gnssModel == GNSS_MODEL_UNKNOWN) {
|
||||||
@ -423,9 +423,6 @@ bool GPS::setup()
|
|||||||
} else {
|
} else {
|
||||||
gnssModel = GNSS_MODEL_UNKNOWN;
|
gnssModel = GNSS_MODEL_UNKNOWN;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
gnssModel = GNSS_MODEL_UC6580;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (gnssModel == GNSS_MODEL_MTK) {
|
if (gnssModel == GNSS_MODEL_MTK) {
|
||||||
/*
|
/*
|
||||||
@ -777,7 +774,6 @@ bool GPS::setup()
|
|||||||
LOG_INFO("GNSS module configuration saved!\n");
|
LOG_INFO("GNSS module configuration saved!\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // !GNSS_Airoha
|
|
||||||
didSerialInit = true;
|
didSerialInit = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1191,6 +1187,15 @@ GnssModel_t GPS::probe(int serialSpeed)
|
|||||||
_serial_gps->write("$PCAS03,0,0,0,0,0,0,0,0,0,0,,,0,0*02\r\n");
|
_serial_gps->write("$PCAS03,0,0,0,0,0,0,0,0,0,0,,,0,0*02\r\n");
|
||||||
delay(20);
|
delay(20);
|
||||||
|
|
||||||
|
// get version information from Unicore UFirebirdII Series
|
||||||
|
// Works for: UC6580, UM620, UM621, UM670A, UM680A, or UM681A
|
||||||
|
_serial_gps->write("$PDTINFO\r\n");
|
||||||
|
delay(750);
|
||||||
|
if (getACK("UC6580", 500) == GNSS_RESPONSE_OK) {
|
||||||
|
LOG_INFO("UC6580 detected, using UC6580 Module\n");
|
||||||
|
return GNSS_MODEL_UC6580;
|
||||||
|
}
|
||||||
|
|
||||||
// Get version information
|
// Get version information
|
||||||
clearBuffer();
|
clearBuffer();
|
||||||
_serial_gps->write("$PCAS06,1*1A\r\n");
|
_serial_gps->write("$PCAS06,1*1A\r\n");
|
||||||
@ -1398,13 +1403,6 @@ GPS *GPS::createGps()
|
|||||||
#else
|
#else
|
||||||
_serial_gps->begin(GPS_BAUDRATE);
|
_serial_gps->begin(GPS_BAUDRATE);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
|
||||||
* T-Beam-S3-Core will be preset to use gps Probe here, and other boards will not be changed first
|
|
||||||
*/
|
|
||||||
#if defined(GPS_UC6580)
|
|
||||||
_serial_gps->updateBaudRate(115200);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
return new_gps;
|
return new_gps;
|
||||||
}
|
}
|
||||||
|
@ -52,6 +52,7 @@
|
|||||||
|
|
||||||
#define GPS_RESET_MODE LOW
|
#define GPS_RESET_MODE LOW
|
||||||
#define GPS_UC6580
|
#define GPS_UC6580
|
||||||
|
#define GPS_BAUDRATE 115200
|
||||||
|
|
||||||
#define USE_SX1262
|
#define USE_SX1262
|
||||||
#define LORA_DIO0 -1 // a No connect on the SX1262 module
|
#define LORA_DIO0 -1 // a No connect on the SX1262 module
|
||||||
|
@ -49,6 +49,7 @@
|
|||||||
|
|
||||||
#define GPS_RESET_MODE LOW
|
#define GPS_RESET_MODE LOW
|
||||||
#define GPS_UC6580
|
#define GPS_UC6580
|
||||||
|
#define GPS_BAUDRATE 11520
|
||||||
|
|
||||||
#define USE_SX1262
|
#define USE_SX1262
|
||||||
#define LORA_DIO0 -1 // a No connect on the SX1262 module
|
#define LORA_DIO0 -1 // a No connect on the SX1262 module
|
||||||
|
@ -48,6 +48,7 @@
|
|||||||
|
|
||||||
#define GPS_RESET_MODE LOW
|
#define GPS_RESET_MODE LOW
|
||||||
#define GPS_UC6580
|
#define GPS_UC6580
|
||||||
|
#define GPS_BAUDRATE 115200
|
||||||
|
|
||||||
#define USE_SX1262
|
#define USE_SX1262
|
||||||
#define LORA_DIO0 -1 // a No connect on the SX1262 module
|
#define LORA_DIO0 -1 // a No connect on the SX1262 module
|
||||||
@ -87,4 +88,4 @@
|
|||||||
{ \
|
{ \
|
||||||
26, 37, 17, 16, 15, 7 \
|
26, 37, 17, 16, 15, 7 \
|
||||||
}
|
}
|
||||||
// #end keyboard
|
// #end keyboard
|
||||||
|
@ -72,6 +72,7 @@
|
|||||||
|
|
||||||
#define GPS_RESET_MODE LOW
|
#define GPS_RESET_MODE LOW
|
||||||
#define GPS_UC6580
|
#define GPS_UC6580
|
||||||
|
#define GPS_BAUDRATE 115200
|
||||||
|
|
||||||
#define USE_SX1262
|
#define USE_SX1262
|
||||||
#define LORA_DIO0 -1 // a No connect on the SX1262 module
|
#define LORA_DIO0 -1 // a No connect on the SX1262 module
|
||||||
@ -111,4 +112,4 @@
|
|||||||
{ \
|
{ \
|
||||||
26, 37, 17, 16, 15, 7 \
|
26, 37, 17, 16, 15, 7 \
|
||||||
}
|
}
|
||||||
// #end keyboard
|
// #end keyboard
|
||||||
|
@ -50,6 +50,7 @@
|
|||||||
|
|
||||||
#define GPS_RESET_MODE LOW
|
#define GPS_RESET_MODE LOW
|
||||||
#define GPS_UC6580
|
#define GPS_UC6580
|
||||||
|
#define GPS_BAUDRATE 115200
|
||||||
|
|
||||||
#define USE_SX1262
|
#define USE_SX1262
|
||||||
#define LORA_DIO0 -1 // a No connect on the SX1262 module
|
#define LORA_DIO0 -1 // a No connect on the SX1262 module
|
||||||
@ -89,4 +90,4 @@
|
|||||||
{ \
|
{ \
|
||||||
26, 37, 17, 16, 15, 7 \
|
26, 37, 17, 16, 15, 7 \
|
||||||
}
|
}
|
||||||
// #end keyboard
|
// #end keyboard
|
||||||
|
Loading…
Reference in New Issue
Block a user