Initial commit - based on v2_candidate

This commit is contained in:
PaulZC
2021-01-09 06:44:12 +00:00
commit 6627841e7d
89 changed files with 31927 additions and 0 deletions
@@ -0,0 +1,60 @@
/*
Send command to reset module over I2C
By: Nathan Seidle
Date: January 29rd, 2019
License: MIT. See license file for more information but you can
basically do whatever you want with this code.
This example shows how to reset the U-Blox module to factory defaults over I2C.
Feel like supporting open source hardware?
Buy a board from SparkFun!
ZED-F9P RTK2: https://www.sparkfun.com/products/15136
NEO-M8P RTK: https://www.sparkfun.com/products/15005
SAM-M8Q: https://www.sparkfun.com/products/15106
Hardware Connections:
Connect the U-Blox serial port to Serial1
If you're using an Uno or don't have a 2nd serial port (Serial1), consider using software serial
Open the serial monitor at 115200 baud to see the output
*/
#include <SparkFun_Ublox_Arduino_Library.h> //http://librarymanager/All#SparkFun_u-blox_GNSS
SFE_UBLOX_GPS myGPS;
void setup()
{
Serial.begin(115200);
while (!Serial); //Wait for user to open terminal
Serial.println("SparkFun u-blox Example");
Wire.begin();
if (myGPS.begin() == false) //Connect to the u-blox module using Wire port
{
Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring. Freezing."));
while (1);
}
while (Serial.available()) Serial.read(); //Trash any incoming chars
Serial.println("Press a key to reset module to factory defaults");
while (Serial.available() == false) ; //Wait for user to send character
myGPS.factoryReset(); //Reset everything: baud rate, I2C address, update rate, everything.
delay(5000); // Wait while the module restarts
while (myGPS.begin() == false) //Attempt to re-connect
{
delay(1000);
Serial.println(F("Attempting to re-connect to u-blox GNSS..."));
}
Serial.println("Unit has now been factory reset. Freezing...");
while(1); // Do nothing more
}
void loop()
{
}
@@ -0,0 +1,110 @@
/*
Test baud rate changes on serial, factory reset, and hard reset.
By: Thorsten von Eicken
Date: January 29rd, 2019
License: MIT. See license file for more information but you can
basically do whatever you want with this code.
This example shows how to reset the U-Blox module to factory defaults over serial.
Feel like supporting open source hardware?
Buy a board from SparkFun!
ZED-F9P RTK2: https://www.sparkfun.com/products/15136
NEO-M8P RTK: https://www.sparkfun.com/products/15005
SAM-M8Q: https://www.sparkfun.com/products/15106
Hardware Connections:
Connect the U-Blox serial port to Serial1
If you're using a Uno or don't have a 2nd serial port (Serial1), use SoftwareSerial instead (see below)
Open the serial monitor at 115200 baud to see the output
*/
#include <SparkFun_Ublox_Arduino_Library.h> //http://librarymanager/All#SparkFun_u-blox_GNSS
SFE_UBLOX_GPS myGPS;
#include <SoftwareSerial.h>
//#define mySerial Serial1 // Uncomment this line to connect via Serial1
// - or -
SoftwareSerial mySerial(10, 11); // Uncomment this line to connect via SoftwareSerial(RX, TX). Connect pin 10 to GNSS TX pin.
#define defaultRate 9600 // Uncomment this line if you are using an M8 - which defaults to 9600 Baud on UART1
// - or -
//#define defaultRate 38400 // Uncomment this line if you are using an F9 - which defaults to 38400 Baud on UART1
int state = 0; // steps through auto-baud, reset, etc states
void setup()
{
Serial.begin(115200);
while (!Serial); //Wait for user to open terminal
Serial.println("SparkFun u-blox Example");
//myGPS.enableDebugging(); // Uncomment this line to enable helpful debug messages on Serial
}
void loop()
{
Serial.print("===== STATE ");
Serial.println(state);
switch (state) {
case 0: // auto-baud connection, then switch to 38400 and save config
do {
Serial.println("GNSS: trying 38400 baud");
mySerial.begin(38400);
if (myGPS.begin(mySerial)) break;
delay(100);
Serial.println("GNSS: trying 9600 baud");
mySerial.begin(9600);
if (myGPS.begin(mySerial)) {
Serial.println("GNSS: connected at 9600 baud, switching to 38400");
myGPS.setSerialRate(38400);
delay(100);
} else {
delay(2000); //Wait a bit before trying again to limit the Serial output flood
}
} while(1);
myGPS.setUART1Output(COM_TYPE_UBX); //Set the UART port to output UBX only
myGPS.saveConfiguration(); //Save the current settings to flash and BBR
Serial.println("GNSS serial connected, saved config");
state++;
break;
case 1: // hardReset, expect to see GNSS back at 38400 baud
Serial.println("Issuing hardReset (cold start)");
myGPS.hardReset();
delay(2000);
mySerial.begin(38400);
if (myGPS.begin(mySerial)) {
Serial.println("Success.");
state++;
} else {
Serial.println("*** GNSS did not respond at 38400 baud, starting over.");
state = 0;
}
break;
case 2: // factoryReset, expect to see GNSS back at defaultRate baud
Serial.println("Issuing factoryReset");
myGPS.factoryReset();
delay(5000); // takes more than one second... a loop to resync would be best
mySerial.begin(defaultRate);
if (myGPS.begin(mySerial)) {
Serial.println("Success.");
state++;
} else {
Serial.println("*** GNSS did not come back at defaultRate baud, starting over.");
state = 0;
}
break;
case 3: // print version info
// Note: this may fail on boards like the UNO (ATmega328P) with modules like the ZED-F9P
// because getProtocolVersion returns a lot of data - more than the UNO's serial buffer can hold
Serial.print("GNSS protocol version: ");
Serial.print(myGPS.getProtocolVersionHigh());
Serial.print('.');
Serial.println(myGPS.getProtocolVersionLow());
Serial.println("All finished! Freezing...");
while(1);
}
delay(1000);
}