Skip to content

Commit 93a3624

Browse files
authored
Merge pull request #15 from sparkfun/release_candidate
v3.0
2 parents 664d3c1 + 76b1df1 commit 93a3624

67 files changed

Lines changed: 14464 additions & 12875 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build-for-release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ on:
55

66
env:
77
FILENAME_PREFIX: GNSSDO_Firmware
8-
FIRMWARE_VERSION_MAJOR: 2
9-
FIRMWARE_VERSION_MINOR: 2
8+
FIRMWARE_VERSION_MAJOR: 3
9+
FIRMWARE_VERSION_MINOR: 0
1010
CORE_VERSION: 3.0.7
1111

1212
jobs:

.github/workflows/non-release-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ jobs:
7171
mv GNSSDO_Firmware.ino.elf ${{ env.ARTIFACT }}
7272
7373
- name: Upload artifact directory to action - avoid double-zip
74-
uses: actions/upload-artifact@v4
74+
uses: actions/upload-artifact@v7
7575
with:
7676
name: ${{ env.ARTIFACT }}
7777
path: ./Firmware/build/${{ env.ARTIFACT }}

Firmware/Dockerfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,14 @@ RUN arduino-cli core install "esp32:esp32@${CORE_VERSION}"
5050
RUN arduino-cli lib install ESP32Time@2.0.0
5151
RUN arduino-cli lib install JC_Button@2.1.2
5252
RUN arduino-cli lib install "SparkFun Qwiic OLED Arduino Library"@1.0.13
53-
RUN arduino-cli lib install "SparkFun Toolkit"@0.9.2
5453
RUN arduino-cli lib install "SparkFun SiT5358 DCTCXO Arduino Library"@1.0.1
5554
RUN arduino-cli lib install "SparkFun SiT5811 OCXO Arduino Library"@1.0.1
56-
RUN arduino-cli lib install "SparkFun STP3593LF OCXO Arduino Library"@1.0.1
55+
RUN arduino-cli lib install "SparkFun STP3593LF OCXO Arduino Library"@1.0.2
5756
RUN arduino-cli lib install "SparkFun PHT MS8607 Arduino Library"@1.0.5
5857

58+
# Install the depends last - to ensure the correct version is installed
59+
RUN arduino-cli lib install "SparkFun Toolkit"@0.9.2
60+
5961
# Enable external libs
6062
#RUN arduino-cli config set library.enable_unsafe_install true
6163

Firmware/GNSSDO_Firmware/Begin.ino

Lines changed: 56 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ void updateErrorLED()
304304

305305
void updateLockLED()
306306
{
307-
digitalWrite(pin_lockLED, (fabs(tcxoClockBias_ms) < settings.rxClkBiasLockLimit_ms) ? HIGH : LOW);
307+
digitalWrite(pin_lockLED, systemState >= STATE_GNSS_PHASE_LOCK ? HIGH : LOW);
308308
}
309309

310310
// Depending on platform and previous power down state, set system state
@@ -506,6 +506,8 @@ void pinI2C2Task(void *pvParameters)
506506
case SFE_GNSSDO_OSC_STP3593LF: {
507507
systemPrintf("0x%02x - STP3593LF TCXO\r\n", addr);
508508
presentSTP3593LF = true;
509+
presentTcxoTemperature = true;
510+
presentTcxoSaveControl = true;
509511
i2cTCXO = i2c_2;
510512
break;
511513
}
@@ -525,7 +527,7 @@ void pinI2C2Task(void *pvParameters)
525527
vTaskDelete(nullptr); // Delete task once it has run once
526528
}
527529

528-
void beginTCXO(TwoWire *i2cBus)
530+
void beginTCXO(TwoWire *i2cBus, bool printOCXO)
529531
{
530532
if (myTCXO != nullptr)
531533
{
@@ -556,12 +558,21 @@ void beginTCXO(TwoWire *i2cBus)
556558
{
557559
// Update the default P and I terms to match a new oscillator
558560
settings.lastSeenTCXO = SFE_GNSSDO_OSC_STP3593LF;
559-
settings.Pk = myTCXO->getDefaultFrequencyByBiasPTerm();
560-
settings.Ik = myTCXO->getDefaultFrequencyByBiasITerm();
561+
settings.PkSteer = 0.2;
562+
settings.IkSteer = 0.5;
563+
settings.PkRamp = 0.4;
564+
settings.IkRamp = 0.4;
565+
settings.Pk = (1.0 / 6.25);
566+
settings.Ik = ((1.0 / 6.25) / 150.0);
567+
settings.tcxoRampRateLimit_sps = 250.0e-9;
568+
settings.tcxoRampStepSize_s = 0.5e-9;
569+
settings.tcxoRampAsymmetry = 1.0;
570+
settings.minimumRampRepeats = 2;
561571
recordSystemSettings();
562572
}
563573

564-
systemPrintln("Using STP3593LF OCXO");
574+
if (printOCXO)
575+
systemPrintln("Using STP3593LF OCXO");
565576
strncpy(oscillatorType, "STP3593LF OCXO", sizeof(oscillatorType));
566577
}
567578
else if (presentSIT5811)
@@ -574,13 +585,23 @@ void beginTCXO(TwoWire *i2cBus)
574585
if (settings.lastSeenTCXO != SFE_GNSSDO_OSC_SIT5811)
575586
{
576587
// Update the default P and I terms to match a new oscillator
588+
// *** TODO ***
577589
settings.lastSeenTCXO = SFE_GNSSDO_OSC_SIT5811;
578-
settings.Pk = myTCXO->getDefaultFrequencyByBiasPTerm();
579-
settings.Ik = myTCXO->getDefaultFrequencyByBiasITerm();
590+
settings.PkSteer = 0.5;
591+
settings.IkSteer = 0.1;
592+
settings.PkRamp = 0.5;
593+
settings.IkRamp = 0.1;
594+
settings.Pk = 0.5;
595+
settings.Ik = 0.1;
596+
settings.tcxoRampRateLimit_sps = 250.0e-9;
597+
settings.tcxoRampStepSize_s = 1.0e-9;
598+
settings.tcxoRampAsymmetry = 1.0;
599+
settings.minimumRampRepeats = 1;
580600
recordSystemSettings();
581601
}
582602

583-
systemPrintln("Using SiT5811 OCXO");
603+
if (printOCXO)
604+
systemPrintln("Using SiT5811 OCXO");
584605
strncpy(oscillatorType, "SiT5811 OCXO", sizeof(oscillatorType));
585606
}
586607
else if (presentSIT5358)
@@ -594,12 +615,21 @@ void beginTCXO(TwoWire *i2cBus)
594615
{
595616
// Update the default P and I terms to match a new oscillator
596617
settings.lastSeenTCXO = SFE_GNSSDO_OSC_SIT5358;
597-
settings.Pk = myTCXO->getDefaultFrequencyByBiasPTerm();
598-
settings.Ik = myTCXO->getDefaultFrequencyByBiasITerm();
618+
settings.PkSteer = 0.63;
619+
settings.IkSteer = 0.151;
620+
settings.PkRamp = 0.63;
621+
settings.IkRamp = 0.5;
622+
settings.Pk = 0.63;
623+
settings.Ik = 0.151;
624+
settings.tcxoRampRateLimit_sps = 500.0e-9;
625+
settings.tcxoRampStepSize_s = 1.0e-9;
626+
settings.tcxoRampAsymmetry = 1.0;
627+
settings.minimumRampRepeats = 1;
599628
recordSystemSettings();
600629
}
601630

602-
systemPrintln("Using SiT5358 TCXO");
631+
if (printOCXO)
632+
systemPrintln("Using SiT5358 TCXO");
603633
strncpy(oscillatorType, "SiT5358 TCXO", sizeof(oscillatorType));
604634
}
605635
else
@@ -616,12 +646,24 @@ void beginTCXO(TwoWire *i2cBus)
616646
online.tcxo = true;
617647
}
618648

619-
// This function updates the TCXO to discipline the frequency
649+
// This function updates the TCXO to discipline the frequency using the latest bias
620650
void updateTCXO()
651+
{
652+
updateTCXO(tcxoClockBias_ms);
653+
}
654+
655+
// This function updates the TCXO using the specified bias and the P&I terms from settings
656+
void updateTCXO(double bias_ms)
657+
{
658+
updateTCXO(bias_ms, settings.Pk, settings.Ik);
659+
}
660+
661+
// This function updates the TCXO using the specified bias and P&I terms
662+
void updateTCXO(double bias_ms, double P, double I)
621663
{
622664
if (online.tcxo)
623665
{
624-
myTCXO->setFrequencyByBiasMillis(tcxoClockBias_ms, settings.Pk, settings.Ik);
666+
myTCXO->setFrequencyByBiasMillis(bias_ms, P, I);
625667
}
626668
}
627669

@@ -645,7 +687,7 @@ int64_t getFrequencyControlWord()
645687
}
646688

647689
// This function updates the tcxoClockBias_ms used to discipline the TCXO frequency
648-
// updateTCXOClockBias is only called by STATE_GNSS_FINETIME when gnssPVTUpdated was true
690+
// updateTCXOClockBias is only called by (e.g.) STATE_GNSS_FINETIME when gnssPVTUpdated was true
649691
// So we know that gnssClockBias_ms is valid
650692
// Use gnssClockBias_ms as the default
651693
// If we have non-composite GPS from FugroTimeOffset, use that - if enabled

Firmware/GNSSDO_Firmware/Display.ino

Lines changed: 39 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -201,24 +201,41 @@ void updateDisplay()
201201
oled->print(textLine);
202202
yPos += 8;
203203

204-
if (tcxoClockBias_ms >= 1.0)
205-
snprintf(textLine, sizeof(textLine), "Bias +%.3fms",
206-
(float)tcxoClockBias_ms);
207-
else if (tcxoClockBias_ms <= -1.0)
208-
snprintf(textLine, sizeof(textLine), "Bias %.3fms",
209-
(float)tcxoClockBias_ms);
210-
else if (tcxoClockBias_ms >= 0.001)
211-
snprintf(textLine, sizeof(textLine), "Bias +%.3fus",
212-
(float)(tcxoClockBias_ms * 1000.0));
213-
else if (tcxoClockBias_ms <= -0.001)
214-
snprintf(textLine, sizeof(textLine), "Bias %.3fus",
215-
(float)(tcxoClockBias_ms * 1000.0));
216-
else if (tcxoClockBias_ms >= 0.0)
217-
snprintf(textLine, sizeof(textLine), "Bias +%.3fns",
218-
(float)(tcxoClockBias_ms * 1000000.0));
204+
if (systemState >= STATE_GNSS_FREQUENCY_LOCK)
205+
{
206+
if (tcxoClockBias_ms >= 1.0)
207+
snprintf(textLine, sizeof(textLine), "Bias +%.3fms",
208+
(float)tcxoClockBias_ms);
209+
else if (tcxoClockBias_ms <= -1.0)
210+
snprintf(textLine, sizeof(textLine), "Bias %.3fms",
211+
(float)tcxoClockBias_ms);
212+
else if (tcxoClockBias_ms >= 0.001)
213+
snprintf(textLine, sizeof(textLine), "Bias +%.3fus",
214+
(float)(tcxoClockBias_ms * 1000.0));
215+
else if (tcxoClockBias_ms <= -0.001)
216+
snprintf(textLine, sizeof(textLine), "Bias %.3fus",
217+
(float)(tcxoClockBias_ms * 1000.0));
218+
else if (tcxoClockBias_ms >= 0.0)
219+
snprintf(textLine, sizeof(textLine), "Bias +%.3fns",
220+
(float)(tcxoClockBias_ms * 1000000.0));
221+
else
222+
snprintf(textLine, sizeof(textLine), "Bias %.3fns",
223+
(float)(tcxoClockBias_ms * 1000000.0));
224+
}
225+
else if (systemState >= STATE_GNSS_FINETIME)
226+
{
227+
snprintf(textLine, sizeof(textLine), "Drift %s%.3e PPM",
228+
tcxoClockDrift_ppm >= 0.0 ? "+" : "",
229+
tcxoClockDrift_ppm);
230+
}
231+
else if (systemState >= STATE_TCXO_WARMUP)
232+
{
233+
snprintf(textLine, sizeof(textLine), "TCXO Warming Up");
234+
}
219235
else
220-
snprintf(textLine, sizeof(textLine), "Bias %.3fns",
221-
(float)(tcxoClockBias_ms * 1000000.0));
236+
{
237+
snprintf(textLine, sizeof(textLine), " ");
238+
}
222239
oled->setCursor(0, yPos);
223240
oled->print(textLine);
224241
}
@@ -405,11 +422,12 @@ void displayMessage(const char *message, uint16_t displayTime)
405422
// Count words based on spaces
406423
uint8_t wordCount = 0;
407424
strncpy(temp, message, sizeof(temp) - 1); // strtok modifies the message so make copy
408-
char *token = strtok(temp, " ");
425+
char *preservedPointer;
426+
char *token = strtok_r(temp, " ", &preservedPointer); // This will blow the ' ' away
409427
while (token != nullptr)
410428
{
411429
wordCount++;
412-
token = strtok(nullptr, " ");
430+
token = strtok_r(nullptr, " ", &preservedPointer);
413431
}
414432

415433
uint8_t yPos = (oled->getHeight() / 2) - ((fontHeight / 2) * wordCount);
@@ -419,11 +437,11 @@ void displayMessage(const char *message, uint16_t displayTime)
419437
// drawFrame();
420438

421439
strncpy(temp, message, sizeof(temp) - 1);
422-
token = strtok(temp, " ");
440+
token = strtok_r(temp, " ", &preservedPointer);
423441
while (token != nullptr)
424442
{
425443
printTextCenter(token, yPos, QW_FONT_8X16, 1, false); // text, y, font type, kerning, inverted
426-
token = strtok(nullptr, " ");
444+
token = strtok_r(nullptr, " ", &preservedPointer);
427445
yPos += fontHeight;
428446
}
429447

Firmware/GNSSDO_Firmware/GNSS.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ bool initializeGNSS()
199199
return false;
200200
}
201201

202-
if (!sendWithResponse("scst, usec500, on\n\r", "ClockSyncThreshold"))
202+
if (!sendWithResponse("scst, usec500, off\n\r", "ClockSyncThreshold"))
203203
{
204204
systemPrintln("GNSS FAIL (ClockSyncThreshold)");
205205
return false;

0 commit comments

Comments
 (0)