Skip to content

Commit cb24812

Browse files
committed
v1.2 - add support for SiT5811 and STP3593LF OCXOs
1 parent 7c3f963 commit cb24812

File tree

15 files changed

+290
-36
lines changed

15 files changed

+290
-36
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
env:
77
FILENAME_PREFIX: GNSSDO_Firmware
88
FIRMWARE_VERSION_MAJOR: 1
9-
FIRMWARE_VERSION_MINOR: 0
9+
FIRMWARE_VERSION_MINOR: 2
1010
CORE_VERSION: 3.0.1
1111

1212
jobs:
@@ -72,13 +72,17 @@ jobs:
7272
"SparkFun Qwiic OLED Arduino Library"@1.0.13
7373
"SparkFun Toolkit"@0.9.2
7474
# "SparkFun SiT5358 DCTCXO Arduino Library"@1.0.0
75+
# "SparkFun SiT5811 OCXO Arduino Library"@1.0.0
76+
# "SparkFun STP3593LF OCXO Arduino Library"@1.0.0
7577

7678
- name: Enable external libs
7779
run: arduino-cli config set library.enable_unsafe_install true
7880

7981
- name: Get Libraries
8082
run: arduino-cli lib install --git-url
81-
https://github.com/sparkfun/SparkFun_SiT5358_DCTCXO_Arduino_Library.git
83+
https://github.com/sparkfun/SparkFun_SiT5358_DCTCXO_Arduino_Library.git
84+
https://github.com/sparkfun/SparkFun_SiT5811_OCXO_Arduino_Library.git
85+
https://github.com/sparkfun/SparkFun_STP3593LF_OCXO_Arduino_Library.git
8286

8387
- name: Copy custom app3M_fat9M_16MB.csv
8488
run:

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,17 @@ jobs:
7272
"SparkFun Qwiic OLED Arduino Library"@1.0.13
7373
"SparkFun Toolkit"@0.9.2
7474
# "SparkFun SiT5358 DCTCXO Arduino Library"@1.0.0
75+
# "SparkFun SiT5811 OCXO Arduino Library"@1.0.0
76+
# "SparkFun STP3593LF OCXO Arduino Library"@1.0.0
7577

7678
- name: Enable external libs
7779
run: arduino-cli config set library.enable_unsafe_install true
7880

7981
- name: Get Libraries
8082
run: arduino-cli lib install --git-url
8183
https://github.com/sparkfun/SparkFun_SiT5358_DCTCXO_Arduino_Library.git
84+
https://github.com/sparkfun/SparkFun_SiT5811_OCXO_Arduino_Library.git
85+
https://github.com/sparkfun/SparkFun_STP3593LF_OCXO_Arduino_Library.git
8286

8387
- name: Copy custom app3M_fat9M_16MB.csv
8488
run:

Firmware/GNSSDO_Firmware/Begin.ino

Lines changed: 49 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -514,37 +514,42 @@ void pinI2C2Task(void *pvParameters)
514514

515515
void beginTCXO(TwoWire *i2cBus)
516516
{
517-
if (i2cBus == nullptr)
517+
if (!i2cBus)
518518
reportFatalError("Illegal TCXO i2cBus");
519519

520-
if (!myTCXO.begin(*i2cBus, SFE_GNSSDO_OSC_SIT5358)) // Initialize the SiT5358
521-
return;
522-
523-
myTCXO.setBaseFrequencyHz(10000000.0); // Pass the oscillator base frequency into the driver
524-
525-
systemPrint("TCXO base frequency set to ");
526-
systemPrint(myTCXO.getBaseFrequencyHz());
527-
systemPrintln(" Hz");
528-
529-
myTCXO.setPullRangeControl(SiT5358_PULL_RANGE_6ppm25); // Set the pull range control to 6.25ppm
530-
531-
systemPrint("TCXO pull range control set to ");
532-
systemPrintln(myTCXO.getPullRangeControlText(myTCXO.getPullRangeControl()));
520+
// In order of priority: use STP3593LF or SiT5811 if present
521+
if (presentSTP3593LF)
522+
{
523+
myTCXO = (GNSSDO_TCXO *) new GNSSDO_STP3593LF();
533524

534-
myTCXO.setMaxFrequencyChangePPB(3.0); // Set the maximum frequency change in PPB
525+
if (!myTCXO->begin(*i2cBus, SFE_GNSSDO_OSC_STP3593LF))
526+
return;
527+
528+
systemPrintln("Using STP3593LF OCXO");
529+
}
530+
else if (presentSIT5811)
531+
{
532+
myTCXO = (GNSSDO_TCXO *) new GNSSDO_SIT5811();
535533

536-
systemPrint("TCXO maximum frequency change set to ");
537-
systemPrint(myTCXO.getMaxFrequencyChangePPB());
538-
systemPrintln(" PPB");
534+
if (!myTCXO->begin(*i2cBus, SFE_GNSSDO_OSC_SIT5811))
535+
return;
539536

540-
myTCXO.setFrequencyControlWord(settings.tcxoControl);
537+
systemPrintln("Using SiT5811 OCXO");
538+
}
539+
else if (presentSIT5358)
540+
{
541+
myTCXO = (GNSSDO_TCXO *) new GNSSDO_SIT5358();
541542

542-
systemPrint("TCXO frequency control word set to ");
543-
systemPrintln(myTCXO.getFrequencyControlWord());
543+
if (!myTCXO->begin(*i2cBus, SFE_GNSSDO_OSC_SIT5358))
544+
return;
544545

545-
systemPrint("TCXO frequency is ");
546-
systemPrint(myTCXO.getFrequencyHz(), 6);
547-
systemPrintln(" Hz");
546+
systemPrintln("Using SiT5358 TCXO");
547+
}
548+
else
549+
{
550+
// No TCXO present!
551+
return;
552+
}
548553

549554
online.tcxo = true;
550555
}
@@ -554,10 +559,29 @@ void updateTCXO()
554559
{
555560
if (online.tcxo)
556561
{
557-
myTCXO.setFrequencyByBiasMillis(tcxoClockBias_ms, settings.Pk, settings.Ik);
562+
myTCXO->setFrequencyByBiasMillis(tcxoClockBias_ms, settings.Pk, settings.Ik);
563+
}
564+
}
565+
566+
// This function tells the TCXO to save its control value - if supported
567+
void saveTCXO()
568+
{
569+
if (online.tcxo)
570+
{
571+
myTCXO->saveFrequencyControlValue();
558572
}
559573
}
560574

575+
int64_t getFrequencyControlWord()
576+
{
577+
if (online.tcxo)
578+
{
579+
return myTCXO->getFrequencyControlWord();
580+
}
581+
582+
return 0;
583+
}
584+
561585
// This function updates the tcxoClockBias_ms used to discipline the TCXO frequency
562586
// updateTCXOClockBias is only called by STATE_GNSS_FINETIME when gnssPVTUpdated was true
563587
// So we know that gnssClockBias_ms is valid

Firmware/GNSSDO_Firmware/GNSSDO_Firmware.ino

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
On the v1.0 PCB, link:
2020
mosaic COM3 TX (TX3) to ESP32 GPIO 34
2121
mosaic COM3 RX (RX3) to ESP32 GPIO 23
22+
1.2: Add support for SiT5811 and STP3593LF oscillators
2223
*/
2324

2425
// This is passed in from compiler extra flags
@@ -36,6 +37,8 @@
3637
// the minor firmware version
3738
#define RTK_IDENTIFIER (FIRMWARE_VERSION_MAJOR * 0x10 + FIRMWARE_VERSION_MINOR)
3839

40+
#include <Arduino.h>
41+
#include <Wire.h>
3942
#include "settings.h"
4043

4144
#define MAX_CPU_CORES 2
@@ -204,10 +207,7 @@ DisplayType displayType = DISPLAY_MAX_NONE;
204207

205208
// DCTCXO
206209
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
207-
#include <SparkFun_Toolkit.h> // Click here to get the library: http://librarymanager/All#SparkFun_Toolkit
208-
#include <SparkFun_SiT5358.h> // Click here to get the library: http://librarymanager/All#SparkFun_SiT5358
209-
210-
SfeSiT5358ArdI2C myTCXO;
210+
GNSSDO_TCXO *myTCXO;
211211

212212
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
213213

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Class to contain all possible oscillators
2+
3+
#ifndef __SFE_GNSSDO_TCXO__
4+
#define __SFE_GNSSDO_TCXO__
5+
6+
class GNSSDO_TCXO
7+
{
8+
public:
9+
// Constructor
10+
GNSSDO_TCXO() {}
11+
12+
// Begin the oscillator
13+
virtual bool begin(TwoWire &wirePort, const uint8_t &address);
14+
15+
// Get the frequency control word
16+
// SiT5358 is int32_t (26-bit, signed)
17+
// SiT5811 is int64_t (39-bit, signed)
18+
// STP3593LF is uint32_t (20-bit, unsigned)
19+
// int64_t can contain all three
20+
virtual int64_t getFrequencyControlWord(void);
21+
22+
// Set the frequency by bias millis
23+
virtual bool setFrequencyByBiasMillis(double bias, double Pk, double Ik);
24+
25+
// Save the frequency control word - if supported
26+
virtual bool saveFrequencyControlValue(void);
27+
};
28+
29+
#endif // /__SFE_GNSSDO_TCXO__

Firmware/GNSSDO_Firmware/NVM.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ void recordSystemSettingsToFile(File *settingsFile)
9090
settingsFile->printf("%s=%d\r\n", "ppsMaxSyncAge_s", settings.ppsMaxSyncAge_s);
9191
settingsFile->printf("%s=%0.6f\r\n", "ppsPulseWidth_ms", settings.ppsPulseWidth_ms);
9292

93-
settingsFile->printf("%s=%ld\r\n", "tcxoControl", settings.tcxoControl);
93+
settingsFile->printf("%s=%lld\r\n", "tcxoControl", settings.tcxoControl);
9494
settingsFile->printf("%s=%0.3e\r\n", "rxClkBiasInitialLimit_ms", settings.rxClkBiasInitialLimit_ms);
9595
settingsFile->printf("%s=%0.3e\r\n", "rxClkBiasLockLimit_ms", settings.rxClkBiasLockLimit_ms);
9696
settingsFile->printf("%s=%d\r\n", "rxClkBiasLimitCount", settings.rxClkBiasLimitCount);
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#ifndef __SFE_GNSSDO_STP3593LF_TCXO__
2+
#define __SFE_GNSSDO_STP3593LF_TCXO__
3+
4+
#include <SparkFun_Toolkit.h> // Click here to get the library: http://librarymanager/All#SparkFun_Toolkit
5+
#include <SparkFun_STP3593LF.h> // Click here to get the library: http://librarymanager/All#SparkFun_STP3593LF
6+
7+
class GNSSDO_STP3593LF : GNSSDO_TCXO
8+
{
9+
private:
10+
SfeSTP3593LFArdI2C * _STP3593LF = nullptr; // Don't instantiate until we know what oscillators are connected
11+
12+
public:
13+
// Constructor
14+
GNSSDO_STP3593LF() : GNSSDO_TCXO() {}
15+
16+
// Begin the oscillator
17+
bool begin(TwoWire &wirePort, const uint8_t &address);
18+
19+
// Get the frequency control word
20+
int64_t getFrequencyControlWord(void);
21+
22+
// Set the frequency by bias millis
23+
bool setFrequencyByBiasMillis(double bias, double Pk, double Ik);
24+
25+
// Save the frequency control word - if supported
26+
bool saveFrequencyControlValue(void);
27+
};
28+
29+
#endif // /__SFE_GNSSDO_STP3593LF_TCXO__
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Begin the oscillator
2+
bool GNSSDO_STP3593LF::begin(TwoWire &wirePort, const uint8_t &address)
3+
{
4+
_STP3593LF = new SfeSTP3593LFArdI2C();
5+
6+
if (!_STP3593LF->begin(wirePort, address))
7+
return false;
8+
9+
_STP3593LF->setMaxFrequencyChangePPB(3.0); // Set the maximum frequency change in PPB
10+
11+
// Don't restore the frequency control word with the saved value from settings.
12+
// Assume saveFrequencyControlValue has done its job and that the control word
13+
// has already been restored.
14+
15+
return true;
16+
}
17+
18+
// Get the frequency control word
19+
int64_t GNSSDO_STP3593LF::getFrequencyControlWord(void)
20+
{
21+
return (int64_t)_STP3593LF->getFrequencyControlWord();
22+
}
23+
24+
// Set the frequency by bias millis
25+
bool GNSSDO_STP3593LF::setFrequencyByBiasMillis(double bias, double Pk, double Ik)
26+
{
27+
return _STP3593LF->setFrequencyByBiasMillis(bias, Pk, Ik);
28+
}
29+
30+
// Save the frequency control word - if supported
31+
bool GNSSDO_STP3593LF::saveFrequencyControlValue(void)
32+
{
33+
return _STP3593LF->saveFrequencyControlValue();
34+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#ifndef __SFE_GNSSDO_SIT5358_TCXO__
2+
#define __SFE_GNSSDO_SIT5358_TCXO__
3+
4+
#include <SparkFun_Toolkit.h> // Click here to get the library: http://librarymanager/All#SparkFun_Toolkit
5+
#include <SparkFun_SiT5358.h> // Click here to get the library: http://librarymanager/All#SparkFun_SiT5358
6+
7+
class GNSSDO_SIT5358 : GNSSDO_TCXO
8+
{
9+
private:
10+
SfeSiT5358ArdI2C * _SiT5358 = nullptr; // Don't instantiate until we know what oscillators are connected
11+
12+
public:
13+
// Constructor
14+
GNSSDO_SIT5358() : GNSSDO_TCXO() {}
15+
16+
// Begin the oscillator
17+
bool begin(TwoWire &wirePort, const uint8_t &address);
18+
19+
// Get the frequency control word
20+
int64_t getFrequencyControlWord(void);
21+
22+
// Set the frequency by bias millis
23+
bool setFrequencyByBiasMillis(double bias, double Pk, double Ik);
24+
25+
// Save the frequency control word - if supported
26+
bool saveFrequencyControlValue(void);
27+
};
28+
29+
#endif // /__SFE_GNSSDO_SIT5358_TCXO__
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Begin the oscillator
2+
bool GNSSDO_SIT5358::begin(TwoWire &wirePort, const uint8_t &address)
3+
{
4+
_SiT5358 = new SfeSiT5358ArdI2C();
5+
6+
if (!_SiT5358->begin(wirePort, address))
7+
return false;
8+
9+
_SiT5358->setBaseFrequencyHz(10000000.0); // Pass the oscillator base frequency into the driver
10+
_SiT5358->setPullRangeControl(sfe_SiT5358_pull_range_control_t::SiT5358_PULL_RANGE_6ppm25); // Set the pull range control to 6.25ppm
11+
_SiT5358->setMaxFrequencyChangePPB(3.0); // Set the maximum frequency change in PPB
12+
_SiT5358->setFrequencyControlWord((int32_t)settings.tcxoControl); // Restore the saved control word
13+
14+
return true;
15+
}
16+
17+
// Get the frequency control word
18+
int64_t GNSSDO_SIT5358::getFrequencyControlWord(void)
19+
{
20+
return (int64_t)_SiT5358->getFrequencyControlWord();
21+
}
22+
23+
// Set the frequency by bias millis
24+
bool GNSSDO_SIT5358::setFrequencyByBiasMillis(double bias, double Pk, double Ik)
25+
{
26+
return _SiT5358->setFrequencyByBiasMillis(bias, Pk, Ik);
27+
}
28+
29+
// Save the frequency control word - if supported
30+
bool GNSSDO_SIT5358::saveFrequencyControlValue(void)
31+
{
32+
return false;
33+
}

0 commit comments

Comments
 (0)