Skip to content

Commit 0b69428

Browse files
committed
Starting to reinstate settings.updateGNSSSettings as settings.gnssConfiguredOnce/Base/Rover
1 parent 7c4a5ae commit 0b69428

File tree

2 files changed

+69
-41
lines changed

2 files changed

+69
-41
lines changed

Firmware/RTK_Everywhere/GNSS_ZED.ino

Lines changed: 63 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -207,80 +207,94 @@ void GNSS_ZED::begin()
207207
}
208208

209209
printModuleInfo(); // Print module type and firmware version
210-
}
211210

212-
UBX_SEC_UNIQID_data_t chipID;
213-
if (_zed->getUniqueChipId(&chipID))
214-
{
215-
snprintf(gnssUniqueId, sizeof(gnssUniqueId), "%s", _zed->getUniqueChipIdStr(&chipID));
216-
}
211+
UBX_SEC_UNIQID_data_t chipID;
212+
if (_zed->getUniqueChipId(&chipID))
213+
{
214+
snprintf(gnssUniqueId, sizeof(gnssUniqueId), "%s", _zed->getUniqueChipIdStr(&chipID));
217215

218-
systemPrintln("GNSS ZED online");
216+
systemPrintln("GNSS ZED online");
217+
online.gnss = true;
218+
return;
219+
}
220+
}
219221

220-
online.gnss = true;
222+
systemPrintln("GNSS ZED offline");
223+
displayGNSSFail(1000);
221224
}
222225

223226
//----------------------------------------
224-
// Setup the timepulse output on the PPS pin for external triggering
225-
// Setup TM2 time stamp input as need
227+
// Setup the timepulse output on the PPS pin for external triggering.
228+
// Setup TM2 time stamp input as need.
229+
// Allow this to be called multiple times so that the callback can be
230+
// set or cleared as needed.
231+
// This will be called once by setup and possibly multiple times by
232+
// menuPortsMultiplexed.
226233
//----------------------------------------
227234
bool GNSS_ZED::beginExternalEvent()
228235
{
229236
if (online.gnss == false)
230237
return (false);
231238

232-
if (settings.dataPortChannel != MUX_PPS_EVENTTRIGGER)
233-
return (true); // No need to configure PPS if port is not selected
234-
235239
bool response = true;
236240

237-
if (settings.enableExternalHardwareEventLogging)
241+
// Assumes EXTINT is always routed through the multiplexer...
242+
if (settings.enableExternalHardwareEventLogging && (settings.dataPortChannel == MUX_PPS_EVENTTRIGGER))
238243
{
239-
_zed->setAutoTIMTM2callbackPtr(
244+
response &= _zed->setAutoTIMTM2callbackPtr(
240245
&eventTriggerReceived); // Enable automatic TIM TM2 messages with callback to eventTriggerReceived
241246
}
242247
else
243-
_zed->setAutoTIMTM2callbackPtr(nullptr);
248+
{
249+
response &= _zed->setAutoTIMTM2callbackPtr(nullptr);
250+
}
251+
252+
if (response == false)
253+
systemPrintln("beginExternalEvent failed");
244254

245255
return (response);
246256
}
247257

248258
//----------------------------------------
249259
// Setup the timepulse output on the PPS pin for external triggering
260+
// Allow this to be called multiple times.
261+
// This will be called once by setup and possibly multiple times by
262+
// menuPortsMultiplexed.
250263
//----------------------------------------
251264
bool GNSS_ZED::beginPPS()
252265
{
253266
if (online.gnss == false)
254267
return (false);
255268

256-
if (settings.dataPortChannel != MUX_PPS_EVENTTRIGGER)
257-
return (true); // No need to configure PPS if port is not selected
258-
259269
bool response = true;
260270

261-
response &= _zed->newCfgValset();
262-
response &= _zed->addCfgValset(UBLOX_CFG_TP_PULSE_DEF, 0); // Time pulse definition is a period (in us)
263-
response &= _zed->addCfgValset(UBLOX_CFG_TP_PULSE_LENGTH_DEF, 1); // Define timepulse by length (not ratio)
264-
response &=
265-
_zed->addCfgValset(UBLOX_CFG_TP_USE_LOCKED_TP1,
266-
1); // Use CFG-TP-PERIOD_LOCK_TP1 and CFG-TP-LEN_LOCK_TP1 as soon as GNSS time is valid
267-
response &= _zed->addCfgValset(UBLOX_CFG_TP_TP1_ENA, settings.enableExternalPulse); // Enable/disable timepulse
268-
response &=
269-
_zed->addCfgValset(UBLOX_CFG_TP_POL_TP1, settings.externalPulsePolarity); // 0 = falling, 1 = rising edge
271+
// Assumes PPS is always routed through the multiplexer...
272+
if (settings.dataPortChannel == MUX_PPS_EVENTTRIGGER)
273+
{
274+
response &= _zed->newCfgValset();
275+
response &= _zed->addCfgValset(UBLOX_CFG_TP_PULSE_DEF, 0); // Time pulse definition is a period (in us)
276+
response &= _zed->addCfgValset(UBLOX_CFG_TP_PULSE_LENGTH_DEF, 1); // Define timepulse by length (not ratio)
277+
response &=
278+
_zed->addCfgValset(UBLOX_CFG_TP_USE_LOCKED_TP1,
279+
1); // Use CFG-TP-PERIOD_LOCK_TP1 and CFG-TP-LEN_LOCK_TP1 as soon as GNSS time is valid
280+
response &= _zed->addCfgValset(UBLOX_CFG_TP_TP1_ENA, settings.enableExternalPulse); // Enable/disable timepulse
281+
response &=
282+
_zed->addCfgValset(UBLOX_CFG_TP_POL_TP1, settings.externalPulsePolarity); // 0 = falling, 1 = rising edge
270283

271-
// While the module is _locking_ to GNSS time, turn off pulse
272-
response &= _zed->addCfgValset(UBLOX_CFG_TP_PERIOD_TP1, 1000000); // Set the period between pulses in us
273-
response &= _zed->addCfgValset(UBLOX_CFG_TP_LEN_TP1, 0); // Set the pulse length in us
284+
// While the module is _locking_ to GNSS time, turn off pulse
285+
response &= _zed->addCfgValset(UBLOX_CFG_TP_PERIOD_TP1, 1000000); // Set the period between pulses in us
286+
response &= _zed->addCfgValset(UBLOX_CFG_TP_LEN_TP1, 0); // Set the pulse length in us
274287

275-
// When the module is _locked_ to GNSS time, make it generate 1Hz (Default is 100ms high, 900ms low)
276-
response &= _zed->addCfgValset(UBLOX_CFG_TP_PERIOD_LOCK_TP1,
277-
settings.externalPulseTimeBetweenPulse_us); // Set the period between pulses is us
278-
response &=
279-
_zed->addCfgValset(UBLOX_CFG_TP_LEN_LOCK_TP1, settings.externalPulseLength_us); // Set the pulse length in us
280-
response &= _zed->sendCfgValset();
288+
// When the module is _locked_ to GNSS time, make it generate 1Hz (Default is 100ms high, 900ms low)
289+
response &= _zed->addCfgValset(UBLOX_CFG_TP_PERIOD_LOCK_TP1,
290+
settings.externalPulseTimeBetweenPulse_us); // Set the period between pulses is us
291+
response &=
292+
_zed->addCfgValset(UBLOX_CFG_TP_LEN_LOCK_TP1, settings.externalPulseLength_us); // Set the pulse length in us
293+
response &= _zed->sendCfgValset();
294+
}
281295

282296
if (response == false)
283-
systemPrintln("beginExternalTriggers config failed");
297+
systemPrintln("beginPPS failed");
284298

285299
return (response);
286300
}
@@ -313,6 +327,13 @@ bool GNSS_ZED::configureBase()
313327
if (online.gnss == false)
314328
return (false);
315329

330+
if (settings.gnssConfiguredBase)
331+
{
332+
if (settings.debugGnss)
333+
systemPrintln("Skipping ZED Base configuration");
334+
return true;
335+
}
336+
316337
update(); // Regularly poll to get latest data
317338

318339
_zed->setNMEAGPGGAcallbackPtr(
@@ -394,9 +415,10 @@ bool GNSS_ZED::configureBase()
394415

395416
if (!success)
396417
systemPrintln("Base config fail");
397-
else
398-
// Save the current configuration into non-volatile memory (NVM)
399-
saveConfiguration();
418+
419+
// The configuration should be saved to RAM and BBR. No need to saveConfiguration here.
420+
421+
settings.gnssConfiguredBase = success;
400422

401423
return (success);
402424
}

Firmware/RTK_Everywhere/settings.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -654,6 +654,9 @@ struct Settings
654654
uint16_t measurementRateMs = 250; // Elapsed ms between GNSS measurements. 25ms to 65535ms. Default 4Hz.
655655
uint16_t navigationRate =
656656
1; // Ratio between number of measurements and navigation solutions. Default 1 for 4Hz (with measurementRate).
657+
bool gnssConfiguredOnce = false; // Flags to indicate how the GNSS is configured (Once, Base, Rover, etc.)
658+
bool gnssConfiguredBase = false;
659+
bool gnssConfiguredRover = false;
657660

658661
// GNSS UART
659662
uint16_t serialGNSSRxFullThreshold = 50; // RX FIFO full interrupt. Max of ~128. See pinUART2Task().
@@ -1246,6 +1249,9 @@ const RTK_Settings_Entry rtkSettingsEntries[] =
12461249
{ 0, 0, 0, 1, 1, 1, 1, 1, 1, _bool, 0, & settings.enablePrintPosition, "enablePrintPosition", },
12471250
{ 0, 1, 0, 1, 1, 1, 1, 1, 1, _uint16_t, 0, & settings.measurementRateMs, "measurementRateMs", },
12481251
{ 0, 1, 0, 1, 1, 1, 1, 1, 1, _uint16_t, 0, & settings.navigationRate, "navigationRate", },
1252+
{ 0, 0, 0, 1, 1, 1, 1, 1, 1, _bool, 0, & settings.gnssConfiguredOnce, "gnssConfiguredOnce", },
1253+
{ 0, 0, 0, 1, 1, 1, 1, 1, 1, _bool, 0, & settings.gnssConfiguredBase, "gnssConfiguredBase", },
1254+
{ 0, 0, 0, 1, 1, 1, 1, 1, 1, _bool, 0, & settings.gnssConfiguredRover, "gnssConfiguredRover", },
12491255

12501256
// Hardware
12511257
{ 1, 1, 0, 1, 1, 1, 0, 1, 0, _bool, 0, & settings.enableExternalHardwareEventLogging, "enableExternalHardwareEventLogging", },

0 commit comments

Comments
 (0)