Skip to content

Commit 48ea1ee

Browse files
committed
Convert Timepulse to get/set val
1 parent c7a2223 commit 48ea1ee

File tree

6 files changed

+28
-48
lines changed

6 files changed

+28
-48
lines changed

Firmware/RTK_Surveyor/Base.ino

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,6 @@ bool surveyInStart()
129129
//Slightly modified method for restarting survey-in from: https://portal.u-blox.com/s/question/0D52p00009IsVoMCAV/restarting-surveyin-on-an-f9p
130130
bool surveyInReset()
131131
{
132-
int maxWait = 2000;
133-
134132
bool response = true;
135133

136134
//Disable survey-in mode
@@ -165,7 +163,6 @@ bool surveyInReset()
165163
bool startFixedBase()
166164
{
167165
bool response = true;
168-
int maxWait = 2000;
169166

170167
if (settings.fixedBaseCoordinateType == COORD_TYPE_ECEF)
171168
{

Firmware/RTK_Surveyor/Begin.ino

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -654,41 +654,32 @@ bool beginExternalTriggers()
654654
}
655655

656656
if (settings.dataPortChannel != MUX_PPS_EVENTTRIGGER)
657-
return(true); //No need to configure PPS if port is not selected
657+
return (true); //No need to configure PPS if port is not selected
658658

659-
UBX_CFG_TP5_data_t timePulseParameters;
659+
bool response = true;
660660

661-
if (i2cGNSS.getTimePulseParameters(&timePulseParameters) == false)
662-
log_e("getTimePulseParameters failed!");
663-
664-
timePulseParameters.tpIdx = 0; // Select the TIMEPULSE pin
661+
response &= i2cGNSS.newCfgValset8(UBLOX_CFG_TP_USE_LOCKED_TP1, 1); //Use CFG-TP-PERIOD_LOCK_TP1 and CFG-TP-LEN_LOCK_TP1 as soon as GNSS time is valid
662+
response &= i2cGNSS.addCfgValset8(UBLOX_CFG_TP_TP1_ENA, settings.enableExternalPulse); //Enable/disable timepulse
663+
response &= i2cGNSS.addCfgValset8(UBLOX_CFG_TP_PULSE_DEF, 0); //Time pulse definition is a period (in us)
664+
response &= i2cGNSS.addCfgValset8(UBLOX_CFG_TP_PULSE_LENGTH_DEF, 1); //Define timepulse by length (not ratio)
665+
response &= i2cGNSS.addCfgValset8(UBLOX_CFG_TP_POL_TP1, settings.externalPulsePolarity); //0 = falling, 1 = raising edge
665666

666667
// While the module is _locking_ to GNSS time, turn off pulse
667-
timePulseParameters.freqPeriod = 1000000; //Set the period between pulses in us
668-
timePulseParameters.pulseLenRatio = 0; //Set the pulse length in us
668+
response &= i2cGNSS.addCfgValset32(UBLOX_CFG_TP_PERIOD_TP1, 1000000); //Set the period between pulses in us
669+
response &= i2cGNSS.addCfgValset32(UBLOX_CFG_TP_LEN_TP1, 0); //Set the pulse length in us
669670

670671
// When the module is _locked_ to GNSS time, make it generate 1kHz
671-
timePulseParameters.freqPeriodLock = settings.externalPulseTimeBetweenPulse_us; //Set the period between pulses is us
672-
timePulseParameters.pulseLenRatioLock = settings.externalPulseLength_us; //Set the pulse length in us
673-
674-
timePulseParameters.flags.bits.active = settings.enableExternalPulse; //Make sure the active flag is set to enable the time pulse. (Set to 0 to disable.)
675-
timePulseParameters.flags.bits.lockedOtherSet = 1; //Tell the module to use freqPeriod while locking and freqPeriodLock when locked to GNSS time
676-
timePulseParameters.flags.bits.isFreq = 0; //Tell the module that we want to set the period
677-
timePulseParameters.flags.bits.isLength = 1; //Tell the module that pulseLenRatio is a length (in us)
678-
timePulseParameters.flags.bits.polarity = (uint8_t)settings.externalPulsePolarity; //Rising or failling edge type pulse
672+
response &= i2cGNSS.addCfgValset32(UBLOX_CFG_TP_PERIOD_LOCK_TP1, settings.externalPulseTimeBetweenPulse_us); //Set the period between pulses is us
673+
response &= i2cGNSS.sendCfgValset32(UBLOX_CFG_TP_LEN_LOCK_TP1, settings.externalPulseLength_us); //Set the pulse length in us
679674

680-
if (i2cGNSS.setTimePulseParameters(&timePulseParameters, 1000) == false)
681-
log_e("setTimePulseParameters failed!");
675+
if (response == false)
676+
Serial.println("beginExternalTriggers config failed");
682677

683678
if (settings.enableExternalHardwareEventLogging == true)
684679
i2cGNSS.setAutoTIMTM2callback(&eventTriggerReceived); //Enable automatic TIM TM2 messages with callback to eventTriggerReceived
685680
else
686681
i2cGNSS.setAutoTIMTM2callback(NULL);
687682

688-
bool response = i2cGNSS.saveConfiguration(); //Save the current settings to flash and BBR
689-
if (response == false)
690-
Serial.println("Module failed to save.");
691-
692683
return (response);
693684
}
694685

Firmware/RTK_Surveyor/menuGNSS.ino

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,6 @@ void menuGNSS()
232232
printUnknown(incoming);
233233
}
234234

235-
int maxWait = 2000;
236-
237235
// Set dynamic model
238236
i2cGNSS.setVal8(UBLOX_CFG_NAVSPG_DYNMODEL, (dynModel)settings.dynamicModel); // Set dynamic model
239237

@@ -354,23 +352,6 @@ bool setRate(double secondsBetweenSolutions)
354352
return (true);
355353
}
356354

357-
//We need to know our overall measurement frequency for things like setting the GSV NMEA sentence rate.
358-
//This returns a float of the rate based on settings that is the readings per second (Hz).
359-
float getMeasurementFrequency()
360-
{
361-
uint16_t currentMeasurementRate = i2cGNSS.getMeasurementRate();
362-
uint16_t currentNavigationRate = i2cGNSS.getNavigationRate();
363-
364-
currentNavigationRate = i2cGNSS.getNavigationRate();
365-
//The ZED-F9P will report an incorrect nav rate if we have rececently changed it.
366-
//Reading a second time insures a correct read.
367-
368-
//Serial.printf("currentMeasurementRate / currentNavigationRate: %d / %d\r\n", currentMeasurementRate, currentNavigationRate);
369-
370-
float measurementFrequency = (1000.0 / currentMeasurementRate) / currentNavigationRate;
371-
return (measurementFrequency);
372-
}
373-
374355
//Print the module type and firmware version
375356
void printZEDInfo()
376357
{

Firmware/RTK_Surveyor/menuMessages.ino

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -707,8 +707,6 @@ void updateLogTest()
707707

708708
beginLogging(fileName);
709709

710-
i2cGNSS.setPortOutput(COM_PORT_USB, COM_TYPE_NMEA | COM_TYPE_UBX | COM_TYPE_RTCM3); //Duplicate UART1
711-
712710
rate = 4;
713711
messages = 5;
714712
semaphoreWait = 10;

Firmware/RTK_Surveyor/menuPP.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,7 @@ void pointperfectApplyKeys()
791791

792792
i2cGNSS.setVal8(UBLOX_CFG_MSGOUT_UBX_RXM_COR_I2C, 1); // Enable UBX-RXM-COR messages on I2C
793793

794-
i2cGNSS.setDGNSSConfiguration(SFE_UBLOX_DGNSS_MODE_FIXED); // Set the differential mode - ambiguities are fixed whenever possible
794+
i2cGNSS.setVal8(UBLOX_CFG_NAVHPG_DGSNSSMODE, 3); // Set the differential mode - ambiguities are fixed whenever possible
795795

796796
bool response = i2cGNSS.setDynamicSPARTNKeys(
797797
currentKeyLengthBytes, currentKeyGPSWeek, currentKeyGPSToW, settings.pointPerfectCurrentKey,

Firmware/RTK_Surveyor/menuPorts.ino

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ void menuPortsMultiplexed()
234234
//Most often used for logging events (inputs) and when external triggers (outputs) occur
235235
void menuPortHardwareTriggers()
236236
{
237+
bool updateSettings = false;
237238
while (1)
238239
{
239240
Serial.println();
@@ -269,6 +270,7 @@ void menuPortHardwareTriggers()
269270
if (incoming == 1)
270271
{
271272
settings.enableExternalPulse ^= 1;
273+
updateSettings = true;
272274
}
273275
else if (incoming == 2 && settings.enableExternalPulse == true)
274276
{
@@ -285,6 +287,8 @@ void menuPortHardwareTriggers()
285287

286288
if (pulseTime < (settings.externalPulseLength_us / 1000)) //pulseTime must be longer than pulseLength
287289
settings.externalPulseLength_us = settings.externalPulseTimeBetweenPulse_us / 2; //Force pulse length to be 1/2 time between pulses
290+
291+
updateSettings = true;
288292
}
289293
}
290294

@@ -299,7 +303,10 @@ void menuPortHardwareTriggers()
299303
if (pulseLength > (settings.externalPulseTimeBetweenPulse_us / 1000)) //pulseLength must be shorter than pulseTime
300304
Serial.println("Error: Pulse length must be shorter than time between pulses");
301305
else
306+
{
302307
settings.externalPulseLength_us = pulseLength * 1000;
308+
updateSettings = true;
309+
}
303310
}
304311
}
305312
else if (incoming == 4 && settings.enableExternalPulse == true)
@@ -308,10 +315,12 @@ void menuPortHardwareTriggers()
308315
settings.externalPulsePolarity = PULSE_FALLING_EDGE;
309316
else
310317
settings.externalPulsePolarity = PULSE_RISING_EDGE;
318+
updateSettings = true;
311319
}
312320
else if (incoming == 5)
313321
{
314322
settings.enableExternalHardwareEventLogging ^= 1;
323+
updateSettings = true;
315324
}
316325
else if (incoming == 'x')
317326
break;
@@ -325,7 +334,11 @@ void menuPortHardwareTriggers()
325334

326335
clearBuffer(); //Empty buffer of any newline chars
327336

328-
beginExternalTriggers(); //Update with new settings
337+
if (updateSettings)
338+
{
339+
settings.updateZEDSettings = true; //Force update
340+
beginExternalTriggers(); //Update with new settings
341+
}
329342
}
330343

331344
void eventTriggerReceived(UBX_TIM_TM2_data_t ubxDataStruct)

0 commit comments

Comments
 (0)