Skip to content
This repository was archived by the owner on Jan 28, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
8895c9b
Change Ublox to u-blox
nseidle Oct 23, 2020
6efce21
Change default setVal to RAM+BBR+Flash. Expanding key set.
nseidle Oct 23, 2020
55bb4a2
Move keys to separate file
nseidle Oct 23, 2020
79679f8
Add getVal8/16/32. Add a bunch of keys.
nseidle Oct 23, 2020
583f528
Add getVal8/16/32 support for group/id/size combos.
nseidle Oct 23, 2020
0fb2fcf
Update Example1_GetSetPortSettings.ino
nseidle Oct 23, 2020
872520b
Update library.properties
nseidle Oct 23, 2020
8638c35
Add support for TMOD3 fixed position.
nseidle Oct 23, 2020
7114584
Merge pull request #133 from sparkfun/UBloxTextChange
PaulZC Oct 26, 2020
30bff51
Merge branch 'release_candidate' into Expand-getVal-setVal
PaulZC Oct 26, 2020
32f8583
Change function call vars to be more clear. Fix example with correct …
nseidle Oct 26, 2020
d4975d4
Resort and rename get/setVal examples in one chunk.
nseidle Oct 26, 2020
03a91e5
Remove duplicate define
nseidle Oct 26, 2020
5102d9f
Add MSGOUT keys. Update examples to use defined keys.
nseidle Oct 26, 2020
6239fc2
Adding header guard
nseidle Oct 26, 2020
50086e4
Merge pull request #135 from sparkfun/setStaticPosition
nseidle Oct 26, 2020
8be456c
Merge pull request #134 from sparkfun/Expand-getVal-setVal
nseidle Oct 26, 2020
5e5dcce
Update library.properties
nseidle Oct 26, 2020
5672e91
Merge pull request #136 from sparkfun/increaseLibVersion
nseidle Oct 26, 2020
9f72926
autoHPPOSLLH functions added - work in progress
PaulZC Oct 27, 2020
9bc3a2d
autoHPPOSLLH - almost ready
PaulZC Oct 27, 2020
1075c2e
Removing two incorrect inversions. These were preventing OVERWRITTEN …
PaulZC Oct 27, 2020
47c83da
Adding autoHPPOSLLH. Tested on the ZED-F9P.
PaulZC Oct 27, 2020
722afc4
Merge pull request #139 from sparkfun/autoHPPOSLLH
PaulZC Oct 27, 2020
f3af4a4
Fix typo. Convert keys to const uint32_ts.
Oct 27, 2020
3b30b92
Update Example11_autoHPPOSLLH.ino
PaulZC Oct 27, 2020
8b27b3e
Merge pull request #140 from sparkfun/autoHPPOSLLH
PaulZC Oct 27, 2020
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add getVal8/16/32. Add a bunch of keys.
  • Loading branch information
nseidle committed Oct 23, 2020
commit 79679f8b48bcd87f425fa3747ba9622b28873869
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/*
Configuring port settings using the newer getVal/setVal methods
By: Nathan Seidle
SparkFun Electronics
Date: October 23rd, 2020
License: MIT. See license file for more information but you can
basically do whatever you want with this code.

This example shows how to query a u-blox module for its UART1 settings and
then change them if the settings aren't what we want.

Note: getVal/setVal/delVal are only support in u-blox protocol versions 27 and higher.

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:
Plug a Qwiic cable into the GPS and a RedBoard
If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
Open the serial monitor at 115200 baud to see the output
*/

#include <Wire.h> //Needed for I2C to GPS

#include "SparkFun_Ublox_Arduino_Library.h" //http://librarymanager/All#SparkFun_Ublox_GPS
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 Ublox module using Wire port
{
Serial.println(F("u-blox GPS not detected at default I2C address. Please check wiring. Freezing."));
while (1)
;
}

//Read the settings from RAM (what the module is running right now, not BBR, Flash, or default)
uint8_t currentUART1Setting_ubx = myGPS.getVal8(UBLOX_CFG_UART1INPROT_UBX);
uint8_t currentUART1Setting_nmea = myGPS.getVal8(UBLOX_CFG_UART1INPROT_NMEA);
uint8_t currentUART1Setting_rtcm3 = myGPS.getVal8(UBLOX_CFG_UART1INPROT_RTCM3X);

Serial.print("currentUART1Setting_ubx: ");
Serial.println(currentUART1Setting_ubx);
Serial.print("currentUART1Setting_nmea: ");
Serial.println(currentUART1Setting_nmea);
Serial.print("currentUART1Setting_rtcm3: ");
Serial.println(currentUART1Setting_rtcm3);

//Check if NMEA and RTCM are enabled for UART1
if (currentUART1Setting_ubx == 0 || currentUART1Setting_nmea == 0)
{
Serial.println("Updating UART1 configuration");

//setVal sets the values for RAM, BBR, and Flash automatically so no .saveConfiguration() is needed
bool response = true;
response &= myGPS.setVal8(UBLOX_CFG_UART1INPROT_UBX, 1); //Enable UBX on UART1 Input
response &= myGPS.setVal8(UBLOX_CFG_UART1INPROT_NMEA, 1); //Enable NMEA on UART1 Input
response &= myGPS.setVal8(UBLOX_CFG_UART1INPROT_RTCM3X, 0); //Disable RTCM on UART1 Input

if (response == false)
Serial.println("SetVal failed");
else
Serial.println("SetVal succeeded");
}
else
Serial.println("Nothing to change");

Serial.println("Done");
}

void loop()
{
}
24 changes: 14 additions & 10 deletions examples/ZED-F9P/Example6_GetVal/Example6_GetVal.ino
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/*
Send UBX binary commands to enable RTCM sentences on Ublox ZED-F9P module
Get a device's I2C address using advanced getVal method
By: Nathan Seidle
SparkFun Electronics
Date: January 9th, 2019
License: MIT. See license file for more information but you can
basically do whatever you want with this code.

Ublox changed how to configure their modules in 2019. As of version 23 of the UBX protocol the
u-blox changed how to configure their modules in 2019. As of version 23 of the UBX protocol the
UBX-CFG commands are deprecated; they still work, they just recommend using VALSET, VALGET, and VALDEL
commands instead. This example shows how to use this new command structure.

Expand All @@ -32,27 +32,31 @@ long lastTime = 0; //Simple local timer. Limits amount if I2C traffic to Ublox m
void setup()
{
Serial.begin(115200);
while (!Serial); //Wait for user to open terminal
Serial.println("Ublox getVal example");
while (!Serial)
; //Wait for user to open terminal
Serial.println("u-blox getVal example");

Wire.begin();
Wire.setClock(400000); //Increase I2C clock speed to 400kHz

if (myGPS.begin() == false) //Connect to the Ublox module using Wire port
{
Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing."));
while (1);
Serial.println(F("u-blox GPS not detected at default I2C address. Please check wiring. Freezing."));
while (1)
;
}

myGPS.enableDebugging(); //Enable debug messages over Serial (default)
//myGPS.enableDebugging(SerialUSB); //Enable debug messages over Serial USB

uint8_t currentI2Caddress = myGPS.getVal8(0x20510001);
#define UBLOX_CFG_I2C_ADDRESS 0x20510001

uint8_t currentI2Caddress = myGPS.getVal8(UBLOX_CFG_I2C_ADDRESS);
Serial.print("Current I2C address (should be 0x42): 0x");
Serial.println(currentI2Caddress >> 1, HEX); //Ublox module returns a shifted 8-bit address. Make it 7-bit unshifted.

while(1);

while (1)
;
}

void loop()
Expand Down Expand Up @@ -83,4 +87,4 @@ void loop()

Serial.println();
}
}
}
3 changes: 3 additions & 0 deletions keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ setUART2Output KEYWORD2
setUSBOutput KEYWORD2
setSPIOutput KEYWORD2

getVal KEYWORD2
getVal8 KEYWORD2
getVal16 KEYWORD2
getVal32 KEYWORD2
setVal KEYWORD2
setVal8 KEYWORD2
setVal16 KEYWORD2
Expand Down
80 changes: 52 additions & 28 deletions src/SparkFun_Ublox_Arduino_Library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
This is a library written for the Ublox ZED-F9P and NEO-M8P-2
SparkFun sells these at its website: www.sparkfun.com
Do you like this library? Help support SparkFun. Buy a board!
https://www.sparkfun.com/products/16481
https://www.sparkfun.com/products/15136
https://www.sparkfun.com/products/15005
https://www.sparkfun.com/products/15733
Expand Down Expand Up @@ -1639,32 +1640,11 @@ boolean SFE_UBLOX_GPS::factoryDefault(uint16_t maxWait)
return (sendCommand(&packetCfg, maxWait) == SFE_UBLOX_STATUS_DATA_SENT); // We are only expecting an ACK
}

//Given a group, ID and size, return the value of this config spot
//The 32-bit key is put together from group/ID/size. See other getVal to send key directly.
//Configuration of modern Ublox modules is now done via getVal/setVal/delVal, ie protocol v27 and above found on ZED-F9P
uint8_t SFE_UBLOX_GPS::getVal8(uint16_t group, uint16_t id, uint8_t size, uint8_t layer, uint16_t maxWait)
{
//Create key
uint32_t key = 0;
key |= (uint32_t)id;
key |= (uint32_t)group << 16;
key |= (uint32_t)size << 28;

if (_printDebug == true)
{
_debugSerial->print(F("key: 0x"));
_debugSerial->print(key, HEX);
_debugSerial->println();
}

return getVal8(key, layer, maxWait);
}

//Given a key, return its value
//Given a key, load the payload with data that can then be extracted to 8, 16, or 32 bits
//This function takes a full 32-bit key
//Default layer is RAM
//Configuration of modern Ublox modules is now done via getVal/setVal/delVal, ie protocol v27 and above found on ZED-F9P
uint8_t SFE_UBLOX_GPS::getVal8(uint32_t key, uint8_t layer, uint16_t maxWait)
//Configuration of modern u-blox modules is now done via getVal/setVal/delVal, ie protocol v27 and above found on ZED-F9P
sfe_ublox_status_e SFE_UBLOX_GPS::getVal(uint32_t key, uint8_t layer, uint16_t maxWait)
{
packetCfg.cls = UBX_CLASS_CFG;
packetCfg.id = UBX_CFG_VALGET;
Expand Down Expand Up @@ -1710,17 +1690,61 @@ uint8_t SFE_UBLOX_GPS::getVal8(uint32_t key, uint8_t layer, uint16_t maxWait)
_debugSerial->print(F("getVal8: sendCommand returned: "));
_debugSerial->println(statusString(retVal));
}
if (retVal != SFE_UBLOX_STATUS_DATA_RECEIVED) // We are expecting data and an ACK
return (0); //If command send fails then bail

//Verify the response is the correct length as compared to what the user called (did the module respond with 8-bits but the user called getVal32?)
//Response is 8 bytes plus cfg data
//if(packet->len > 8+1)

//Pull the requested value from the response
//Response starts at 4+1*N with the 32-bit key so the actual data we're looking for is at 8+1*N
//The response is now sitting in payload, ready for extraction
return (retVal);
}

//Given a key, return its value
//This function takes a full 32-bit key
//Default layer is RAM
//Configuration of modern Ublox modules is now done via getVal/setVal/delVal, ie protocol v27 and above found on ZED-F9P
uint8_t SFE_UBLOX_GPS::getVal8(uint32_t key, uint8_t layer, uint16_t maxWait)
{
if (getVal(key, layer, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED)
return (0);

return (extractByte(8));
}
uint16_t SFE_UBLOX_GPS::getVal16(uint32_t key, uint8_t layer, uint16_t maxWait)
{
if (getVal(key, layer, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED)
return (0);

return (extractInt(8));
}
uint32_t SFE_UBLOX_GPS::getVal32(uint32_t key, uint8_t layer, uint16_t maxWait)
{
if (getVal(key, layer, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED)
return (0);

return (extractLong(8));
}

//Given a group, ID and size, return the value of this config spot
//The 32-bit key is put together from group/ID/size. See other getVal to send key directly.
//Configuration of modern Ublox modules is now done via getVal/setVal/delVal, ie protocol v27 and above found on ZED-F9P
uint8_t SFE_UBLOX_GPS::getVal8(uint16_t group, uint16_t id, uint8_t size, uint8_t layer, uint16_t maxWait)
{
//Create key
uint32_t key = 0;
key |= (uint32_t)id;
key |= (uint32_t)group << 16;
key |= (uint32_t)size << 28;

if (_printDebug == true)
{
_debugSerial->print(F("key: 0x"));
_debugSerial->print(key, HEX);
_debugSerial->println();
}

return getVal8(key, layer, maxWait);
}

//Given a key, set a 16-bit value
//This function takes a full 32-bit key
Expand Down
33 changes: 19 additions & 14 deletions src/SparkFun_Ublox_Arduino_Library.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
This is a library written for the Ublox ZED-F9P and NEO-M8P-2
SparkFun sells these at its website: www.sparkfun.com
Do you like this library? Help support SparkFun. Buy a board!
https://www.sparkfun.com/products/16481
https://www.sparkfun.com/products/15136
https://www.sparkfun.com/products/15005
https://www.sparkfun.com/products/15733
Expand Down Expand Up @@ -555,21 +556,25 @@ class SFE_UBLOX_GPS
//General configuration (used only on protocol v27 and higher - ie, ZED-F9P)
//It is probably safe to assume that users of the ZED-F9P will be using I2C / Qwiic.
//If they are using Serial then the higher baud rate will also help. So let's leave maxWait set to 250ms.
sfe_ublox_status_e getVal(uint32_t keyID, uint8_t layer = VAL_LAYER_RAM, uint16_t maxWait = 250); //Load payload with response
uint8_t getVal8(uint32_t keyID, uint8_t layer = VAL_LAYER_RAM, uint16_t maxWait = 250); //Returns the value at a given key location
uint16_t getVal16(uint32_t keyID, uint8_t layer = VAL_LAYER_RAM, uint16_t maxWait = 250); //Returns the value at a given key location
uint32_t getVal32(uint32_t keyID, uint8_t layer = VAL_LAYER_RAM, uint16_t maxWait = 250); //Returns the value at a given key location
uint8_t getVal8(uint16_t group, uint16_t id, uint8_t size, uint8_t layer = VAL_LAYER_RAM, uint16_t maxWait = 250); //Returns the value at a given group/id/size location
uint8_t getVal8(uint32_t keyID, uint8_t layer = VAL_LAYER_RAM, uint16_t maxWait = 250); //Returns the value at a given group/id/size location
uint8_t setVal(uint32_t keyID, uint16_t value, uint8_t layer = VAL_LAYER_ALL, uint16_t maxWait = 250); //Sets the 16-bit value at a given group/id/size location
uint8_t setVal8(uint32_t keyID, uint8_t value, uint8_t layer = VAL_LAYER_ALL, uint16_t maxWait = 250); //Sets the 8-bit value at a given group/id/size location
uint8_t setVal16(uint32_t keyID, uint16_t value, uint8_t layer = VAL_LAYER_ALL, uint16_t maxWait = 250); //Sets the 16-bit value at a given group/id/size location
uint8_t setVal32(uint32_t keyID, uint32_t value, uint8_t layer = VAL_LAYER_ALL, uint16_t maxWait = 250); //Sets the 32-bit value at a given group/id/size location
uint8_t newCfgValset8(uint32_t keyID, uint8_t value, uint8_t layer = VAL_LAYER_BBR); //Define a new UBX-CFG-VALSET with the given KeyID and 8-bit value
uint8_t newCfgValset16(uint32_t keyID, uint16_t value, uint8_t layer = VAL_LAYER_BBR); //Define a new UBX-CFG-VALSET with the given KeyID and 16-bit value
uint8_t newCfgValset32(uint32_t keyID, uint32_t value, uint8_t layer = VAL_LAYER_BBR); //Define a new UBX-CFG-VALSET with the given KeyID and 32-bit value
uint8_t addCfgValset8(uint32_t keyID, uint8_t value); //Add a new KeyID and 8-bit value to an existing UBX-CFG-VALSET ubxPacket
uint8_t addCfgValset16(uint32_t keyID, uint16_t value); //Add a new KeyID and 16-bit value to an existing UBX-CFG-VALSET ubxPacket
uint8_t addCfgValset32(uint32_t keyID, uint32_t value); //Add a new KeyID and 32-bit value to an existing UBX-CFG-VALSET ubxPacket
uint8_t sendCfgValset8(uint32_t keyID, uint8_t value, uint16_t maxWait = 250); //Add the final KeyID and 8-bit value to an existing UBX-CFG-VALSET ubxPacket and send it
uint8_t sendCfgValset16(uint32_t keyID, uint16_t value, uint16_t maxWait = 250); //Add the final KeyID and 16-bit value to an existing UBX-CFG-VALSET ubxPacket and send it
uint8_t sendCfgValset32(uint32_t keyID, uint32_t value, uint16_t maxWait = 250); //Add the final KeyID and 32-bit value to an existing UBX-CFG-VALSET ubxPacket and send it

uint8_t setVal(uint32_t keyID, uint16_t value, uint8_t layer = VAL_LAYER_ALL, uint16_t maxWait = 250); //Sets the 16-bit value at a given group/id/size location
uint8_t setVal8(uint32_t keyID, uint8_t value, uint8_t layer = VAL_LAYER_ALL, uint16_t maxWait = 250); //Sets the 8-bit value at a given group/id/size location
uint8_t setVal16(uint32_t keyID, uint16_t value, uint8_t layer = VAL_LAYER_ALL, uint16_t maxWait = 250); //Sets the 16-bit value at a given group/id/size location
uint8_t setVal32(uint32_t keyID, uint32_t value, uint8_t layer = VAL_LAYER_ALL, uint16_t maxWait = 250); //Sets the 32-bit value at a given group/id/size location
uint8_t newCfgValset8(uint32_t keyID, uint8_t value, uint8_t layer = VAL_LAYER_BBR); //Define a new UBX-CFG-VALSET with the given KeyID and 8-bit value
uint8_t newCfgValset16(uint32_t keyID, uint16_t value, uint8_t layer = VAL_LAYER_BBR); //Define a new UBX-CFG-VALSET with the given KeyID and 16-bit value
uint8_t newCfgValset32(uint32_t keyID, uint32_t value, uint8_t layer = VAL_LAYER_BBR); //Define a new UBX-CFG-VALSET with the given KeyID and 32-bit value
uint8_t addCfgValset8(uint32_t keyID, uint8_t value); //Add a new KeyID and 8-bit value to an existing UBX-CFG-VALSET ubxPacket
uint8_t addCfgValset16(uint32_t keyID, uint16_t value); //Add a new KeyID and 16-bit value to an existing UBX-CFG-VALSET ubxPacket
uint8_t addCfgValset32(uint32_t keyID, uint32_t value); //Add a new KeyID and 32-bit value to an existing UBX-CFG-VALSET ubxPacket
uint8_t sendCfgValset8(uint32_t keyID, uint8_t value, uint16_t maxWait = 250); //Add the final KeyID and 8-bit value to an existing UBX-CFG-VALSET ubxPacket and send it
uint8_t sendCfgValset16(uint32_t keyID, uint16_t value, uint16_t maxWait = 250); //Add the final KeyID and 16-bit value to an existing UBX-CFG-VALSET ubxPacket and send it
uint8_t sendCfgValset32(uint32_t keyID, uint32_t value, uint16_t maxWait = 250); //Add the final KeyID and 32-bit value to an existing UBX-CFG-VALSET ubxPacket and send it

//Functions used for RTK and base station setup
//It is probably safe to assume that users of the RTK will be using I2C / Qwiic. So let's leave maxWait set to 250ms.
Expand Down
Loading