Skip to content
This repository was archived by the owner on Jan 28, 2021. It is now read-only.

Commit cccf8f8

Browse files
committedApr 28, 2019
Add functional getVal of I2C address with hard-coded keyID. Add example 6 for ZED-F9P.
1 parent 146aa31 commit cccf8f8

File tree

3 files changed

+48
-27
lines changed

3 files changed

+48
-27
lines changed
 

‎keywords.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ setUART2Output KEYWORD2
6161
setUSBOutput KEYWORD2
6262
setSPIOutput KEYWORD2
6363

64-
getVal KEYWORD2
64+
getVal8 KEYWORD2
6565

6666
getSurveyMode KEYWORD2
6767
setSurveyMode KEYWORD2

‎src/SparkFun_Ublox_Arduino_Library.cpp

+36-21
Original file line numberDiff line numberDiff line change
@@ -811,9 +811,32 @@ boolean SFE_UBLOX_GPS::factoryDefault(uint16_t maxWait)
811811
return (true);
812812
}
813813

814+
//Given a group, ID and size, return the value of this config spot
815+
//The 32-bit key is put together from group/ID/size. See other getVal to send key directly.
816+
//Configuration of modern Ublox modules is now done via getVal/setVal/delVal, ie protocol v27 and above found on ZED-F9P
817+
uint8_t SFE_UBLOX_GPS::getVal8(uint16_t group, uint16_t id, uint8_t size, uint8_t layer, uint16_t maxWait)
818+
{
819+
//Create key
820+
uint32_t key = 0;
821+
key |= (uint32_t)id;
822+
key |= (uint32_t)group << 16;
823+
key |= (uint32_t)size << 28;
824+
825+
if (_printDebug == true)
826+
{
827+
_debugSerial->print("key: 0x");
828+
_debugSerial->print(key, HEX);
829+
_debugSerial->println();
830+
}
831+
832+
return getVal8(key, layer, maxWait);
833+
}
834+
814835
//Given a key, return its value
815-
//This is how the new Ublox modules are communicating, ie protocol v27 and above found on ZED-F9P
816-
uint8_t SFE_UBLOX_GPS::getVal(uint16_t group, uint16_t id, uint8_t size, uint8_t layer, uint16_t maxWait)
836+
//This function takes a full 32-bit key
837+
//Default layer is BBR
838+
//Configuration of modern Ublox modules is now done via getVal/setVal/delVal, ie protocol v27 and above found on ZED-F9P
839+
uint8_t SFE_UBLOX_GPS::getVal8(uint32_t key, uint8_t layer, uint16_t maxWait)
817840
{
818841
packetCfg.cls = UBX_CLASS_CFG;
819842
packetCfg.id = UBX_CFG_VALGET;
@@ -825,13 +848,13 @@ uint8_t SFE_UBLOX_GPS::getVal(uint16_t group, uint16_t id, uint8_t size, uint8_t
825848
packetCfg.payload[x] = 0;
826849

827850
payloadCfg[0] = 0; //Message Version - set to 0
828-
payloadCfg[1] = layer; //By default we ask for the flash layer
851+
payloadCfg[1] = layer; //By default we ask for the BBR layer
829852

830-
//Create key
831-
uint32_t key = 0;
832-
key |= (uint32_t)id;
833-
key |= (uint32_t)group << 16;
834-
key |= (uint32_t)size << 28;
853+
//Load key into outgoing payload
854+
payloadCfg[4] = key >> 8 * 0; //Key LSB
855+
payloadCfg[5] = key >> 8 * 1;
856+
payloadCfg[6] = key >> 8 * 2;
857+
payloadCfg[7] = key >> 8 * 3;
835858

836859
if (_printDebug == true)
837860
{
@@ -840,25 +863,17 @@ uint8_t SFE_UBLOX_GPS::getVal(uint16_t group, uint16_t id, uint8_t size, uint8_t
840863
_debugSerial->println();
841864
}
842865

843-
//Load key into outgoing payload
844-
payloadCfg[4] = key >> 8 * 0; //Key LSB
845-
payloadCfg[5] = key >> 8 * 1;
846-
payloadCfg[6] = key >> 8 * 2;
847-
payloadCfg[7] = key >> 8 * 3;
848-
849866
//Send VALGET command with this key
850867
if (sendCommand(packetCfg, maxWait) == false)
851868
return (false); //If command send fails then bail
852869

853-
if (_printDebug == true)
854-
{
855-
_debugSerial->print("response (should be 0x01): 0x");
856-
_debugSerial->print(payloadCfg[0], HEX);
857-
_debugSerial->println();
858-
}
870+
//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?)
871+
//Response is 8 bytes plus cfg data
872+
//if(packet->len > 8+1)
859873

860874
//Pull the requested value from the response
861-
return (extractByte(4)); //Look for our response value at location 4+1*N
875+
//Response starts at 4+1*N with the 32-bit key so the actual data we're looking for is at 8+1*N
876+
return (extractByte(8));
862877
}
863878

864879
//Get the current TimeMode3 settings - these contain survey in statuses

‎src/SparkFun_Ublox_Arduino_Library.h

+11-5
Original file line numberDiff line numberDiff line change
@@ -131,23 +131,28 @@ const uint8_t COM_TYPE_NMEA = (1 << 1);
131131
const uint8_t COM_TYPE_RTCM3 = (1 << 5);
132132

133133
//The following consts are used to generate KEY values for the advanced protocol functions of VELGET/SET/DEL
134-
const uint8_t VAL_SIZE_BIT = 0x01;
135-
const uint8_t VAL_SIZE_BYTE = 0x02;
134+
const uint8_t VAL_SIZE_1 = 0x01; //One bit
135+
const uint8_t VAL_SIZE_8 = 0x02; //One byte
136+
const uint8_t VAL_SIZE_16 = 0x03; //Two bytes
137+
const uint8_t VAL_SIZE_32 = 0x04; //Four bytes
138+
const uint8_t VAL_SIZE_64 = 0x05; //Eight bytes
136139

137140
const uint8_t VAL_LAYER_RAM = 0;
138141
const uint8_t VAL_LAYER_BBR = 1;
139142
const uint8_t VAL_LAYER_FLASH = 2;
140143
const uint8_t VAL_LAYER_DEFAULT = 7;
141144

142-
const uint8_t VAL_GROUP_I2COUTPROT_SIZE = VAL_SIZE_BIT; //All fields in I2C group are currently 1 bit
145+
//Below are various Groups, IDs, and sizes for various settings
146+
//These can be used to call getVal/setVal/delVal
143147
const uint8_t VAL_GROUP_I2COUTPROT = 0x72;
148+
const uint8_t VAL_GROUP_I2COUTPROT_SIZE = VAL_SIZE_1; //All fields in I2C group are currently 1 bit
144149

145150
const uint8_t VAL_ID_I2COUTPROT_UBX = 0x01;
146151
const uint8_t VAL_ID_I2COUTPROT_NMEA = 0x02;
147152
const uint8_t VAL_ID_I2COUTPROT_RTCM3 = 0x03;
148153

149-
const uint8_t VAL_GROUP_I2C_SIZE = VAL_SIZE_BYTE; //All fields in I2C group are currently 1 byte
150154
const uint8_t VAL_GROUP_I2C = 0x51;
155+
const uint8_t VAL_GROUP_I2C_SIZE = VAL_SIZE_8; //All fields in I2C group are currently 1 byte
151156

152157
const uint8_t VAL_ID_I2C_ADDRESS = 0x01;
153158

@@ -242,7 +247,8 @@ class SFE_UBLOX_GPS
242247
boolean setSPIOutput(uint8_t comSettings, uint16_t maxWait = 250); //Configure SPI port to output UBX, NMEA, RTCM3 or a combination thereof
243248

244249
//General configuration (used only on protocol v27 and higher - ie, ZED-F9P)
245-
uint8_t getVal(uint16_t group, uint16_t id, uint8_t size, uint8_t layer = VAL_LAYER_FLASH, uint16_t maxWait = 250); //Returns the value at a given group/id/size location
250+
uint8_t getVal8(uint16_t group, uint16_t id, uint8_t size, uint8_t layer = VAL_LAYER_BBR, uint16_t maxWait = 250); //Returns the value at a given group/id/size location
251+
uint8_t getVal8(uint32_t keyID, uint8_t layer = VAL_LAYER_BBR, uint16_t maxWait = 250); //Returns the value at a given group/id/size location
246252

247253
//Functions used for RTK and base station setup
248254
boolean getSurveyMode(uint16_t maxWait = 250); //Get the current TimeMode3 settings

0 commit comments

Comments
 (0)
This repository has been archived.