Skip to content

Commit 4231f4f

Browse files
committed
Compiling
1 parent a221007 commit 4231f4f

File tree

13 files changed

+548
-444
lines changed

13 files changed

+548
-444
lines changed

Firmware/RTK_Everywhere/Begin.ino

Lines changed: 120 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ void identifyBoard()
7777
// First, test for devices that do not have ID resistors
7878
if (productVariant == RTK_UNKNOWN)
7979
{
80-
// Torch
8180
// Check if unique ICs are on the I2C bus
8281
if (i2c_0 == nullptr)
8382
i2c_0 = new TwoWire(0);
@@ -95,30 +94,26 @@ void identifyBoard()
9594
// 0x08 - HUSB238 - USB C PD Sink Controller
9695
bool husb238Present = i2cIsDevicePresent(i2c_0, 0x08);
9796

98-
// Flex has everything a Torch does and a display
99-
// 0x3C - SSD1306 OLED Driver
100-
// If a display is present, it's not a Torch
101-
// bool displayPresent = i2cIsDevicePresent(i2c_0, 0x3C);
102-
bool displayPresent = i2cIsDevicePresent(i2c_0, 0x10);
97+
// 0x10 -MFI343S00177 Authentication Coprocessor
98+
bool mfiPresent = i2cIsDevicePresent(i2c_0, 0x10);
10399

104100
i2c_0->end();
105101

106-
// Proceed with Torch ID only if display is absent
107-
if (displayPresent == false)
102+
// Proceed with Torch ID only if MFi is absent (Torch X2 has MFi, and ID resistors)
103+
if (mfiPresent == false)
108104
{
109105
if (bq40z50Present || mp2762aPresent || husb238Present)
110106
{
111107
productVariant = RTK_TORCH;
112-
}
113-
114-
if (productVariant == RTK_TORCH && bq40z50Present == false)
115-
systemPrintln("Error: Torch ID'd with no BQ40Z50 present");
108+
if (bq40z50Present == false)
109+
systemPrintln("Error: Torch ID'd with no BQ40Z50 present");
116110

117-
if (productVariant == RTK_TORCH && mp2762aPresent == false)
118-
systemPrintln("Error: Torch ID'd with no MP2762A present");
111+
if (mp2762aPresent == false)
112+
systemPrintln("Error: Torch ID'd with no MP2762A present");
119113

120-
if (productVariant == RTK_TORCH && husb238Present == false)
121-
systemPrintln("Error: Torch ID'd with no HUSB238 present");
114+
if (husb238Present == false)
115+
systemPrintln("Error: Torch ID'd with no HUSB238 present");
116+
}
122117
}
123118
}
124119

@@ -159,11 +154,20 @@ void identifyBoard()
159154
// Postcard: 3.3/10 --> 2371mV < 2481mV < 2582mV (8.5% tolerance)
160155
else if (idWithAdc(idValue, 3.3, 10, 8.5))
161156
productVariant = RTK_POSTCARD;
162-
157+
158+
// Torch X2: 8.2/3.3 --> 836mV < 947mV < 1067mV (8.5% tolerance)
159+
else if (idWithAdc(idValue, 8.2, 3.3, 8.5))
160+
productVariant = RTK_TORCH_X2;
161+
163162
#ifndef NOT_FACET_FLEX
164163
systemPrintln("<<<<<<<<<< !!!!!!!!!! FLEX FORCED !!!!!!!!!! >>>>>>>>>>");
165164
productVariant = RTK_FLEX; // TODO remove once v1.1 Flex has ID resistors
166165
#endif
166+
167+
#ifndef NOT_TORCH_X2
168+
systemPrintln("<<<<<<<<<< !!!!!!!!!! TORCH X2 FORCED !!!!!!!!!! >>>>>>>>>>");
169+
productVariant = RTK_TORCH_X2; // TODO remove once v1.1 Torch X2 has ID resistors
170+
#endif
167171
}
168172

169173
if (ENABLE_DEVELOPER)
@@ -722,7 +726,7 @@ void beginBoard()
722726
present.fuelgauge_max17048 = true;
723727
present.display_i2c0 = true;
724728
present.i2c0BusSpeed_400 = true; // Run display bus at higher speed
725-
present.i2c1 = true; // Qwiic bus
729+
present.i2c1 = true; // Qwiic bus
726730
present.display_type = DISPLAY_128x64;
727731
present.microSd = true;
728732
present.gpioExpanderButtons = true;
@@ -849,6 +853,91 @@ void beginBoard()
849853

850854
// GNSS receiver type is determined later in gnssDetectReceiverType()
851855
}
856+
857+
else if (productVariant == RTK_TORCH_X2)
858+
{
859+
// Specify the GNSS radio
860+
#ifdef COMPILE_LG290P
861+
gnss = (GNSS *)new GNSS_LG290P();
862+
#else // COMPILE_UM980
863+
gnss = (GNSS *)new GNSS_None();
864+
systemPrintln("<<<<<<<<<< !!!!!!!!!! LG290P NOT COMPILED !!!!!!!!!! >>>>>>>>>>");
865+
#endif // COMPILE_UM980
866+
867+
present.brand = BRAND_SPARKPNT;
868+
present.psram_2mb = true;
869+
present.gnss_lg290p = true;
870+
present.antennaPhaseCenter_mm = 116.5; // Default to Torch helical APC, average of L1/L2
871+
present.fuelgauge_bq40z50 = true;
872+
present.charger_mp2762a = true;
873+
present.button_powerHigh = true; // Button is pressed when high
874+
present.beeper = true;
875+
present.gnss_to_uart = true;
876+
present.needsExternalPpl = true; // Uses the PointPerfect Library
877+
878+
// We can't enable GNSS features here because we don't know if lg290pFirmwareVersion is >= v05
879+
// present.minElevation = true;
880+
// present.minCno = true;
881+
882+
pin_I2C0_SDA = 15;
883+
pin_I2C0_SCL = 4;
884+
885+
pin_GnssUart_RX = 14; //Torch X2 uses UART2 of ESP32 to communicate with LG290P
886+
pin_GnssUart_TX = 17;
887+
pin_GNSS_DR_Reset = 22; // Push low to reset GNSS/DR.
888+
889+
pin_GNSS_TimePulse = 39; // PPS on UM980
890+
891+
pin_muxB = 12;
892+
pin_usbSelect = 12; // Controls U18 switch between ESP UART0 to USB or GNSS UART1
893+
pin_powerAdapterDetect = 36; // Goes low when USB cable is plugged in
894+
895+
pin_batteryStatusLED = 0;
896+
pin_bluetoothStatusLED = 32;
897+
pin_gnssStatusLED = 13;
898+
899+
pin_beeper = 33;
900+
901+
pin_powerButton = 34;
902+
pin_powerSenseAndControl = 18; // PWRKILL
903+
904+
pin_loraRadio_power = 19; // LoRa_EN
905+
// pin_loraRadio_boot = 23; // LoRa_BOOT0
906+
// pin_loraRadio_reset = 5; // LoRa_NRST
907+
908+
DMW_if systemPrintf("pin_bluetoothStatusLED: %d\r\n", pin_bluetoothStatusLED);
909+
pinMode(pin_bluetoothStatusLED, OUTPUT);
910+
911+
DMW_if systemPrintf("pin_gnssStatusLED: %d\r\n", pin_gnssStatusLED);
912+
pinMode(pin_gnssStatusLED, OUTPUT);
913+
914+
DMW_if systemPrintf("pin_batteryStatusLED: %d\r\n", pin_batteryStatusLED);
915+
pinMode(pin_batteryStatusLED, OUTPUT);
916+
917+
// Turn on Bluetooth, GNSS, and Battery LEDs to indicate power on
918+
bluetoothLedOn();
919+
gnssStatusLedOn();
920+
batteryStatusLedOn();
921+
922+
pinMode(pin_beeper, OUTPUT);
923+
beepOff();
924+
925+
pinMode(pin_powerButton, INPUT);
926+
927+
pinMode(pin_GNSS_TimePulse, INPUT);
928+
929+
pinMode(pin_GNSS_DR_Reset, OUTPUT);
930+
gnssBoot(); // Tell GNSS to boot
931+
932+
pinMode(pin_powerAdapterDetect, INPUT); // Has 10k pullup
933+
934+
pinMode(pin_usbSelect, OUTPUT);
935+
digitalWrite(pin_usbSelect, LOW); // Keep ESP32 connected to CH342 (not GNSS UART1)
936+
937+
// LoRa not mounted in X2, but power down to be sure
938+
pinMode(pin_loraRadio_power, OUTPUT);
939+
loraPowerOff(); // Keep LoRa powered down for now
940+
}
852941
}
853942

854943
void beginVersion()
@@ -1137,7 +1226,7 @@ void forceGnssCommunicationRate(uint32_t &platformGnssCommunicationRate)
11371226
// Override user setting. Required because beginGnssUart() is called before beginBoard().
11381227
platformGnssCommunicationRate = 115200;
11391228
}
1140-
else if (productVariant == RTK_POSTCARD)
1229+
else if (productVariant == RTK_POSTCARD || productVariant == RTK_TORCH_X2)
11411230
{
11421231
// LG290P communicates at 460800bps.
11431232
platformGnssCommunicationRate = 115200 * 4;
@@ -1553,6 +1642,14 @@ void beginSystemState()
15531642
if (systemState == STATE_BASE_NOT_STARTED)
15541643
firstRoverStart = false;
15551644
}
1645+
else if (productVariant == RTK_TORCH_X2)
1646+
{
1647+
// Do not allow user to enter test screen during first rover start because there is no screen
1648+
firstRoverStart = false;
1649+
1650+
// Return to either Base or Rover Not Started. The last state previous to power down.
1651+
systemState = settings.lastState;
1652+
}
15561653
else
15571654
{
15581655
systemPrintf("beginSystemState: Unknown product variant: %d\r\n", productVariant);
@@ -1736,13 +1833,15 @@ bool i2cBusInitialization(TwoWire *i2cBus, int sda, int scl, int clockKHz)
17361833
break;
17371834
}
17381835

1739-
case 0x10: {
1836+
case 0x10:
1837+
{
17401838
systemPrintf(" 0x%02X - MFI343S00177 Authentication Coprocessor\r\n", addr);
17411839
i2cAuthCoPro = i2cBus; // Record the bus
17421840
break;
17431841
}
17441842

1745-
case 0x18: {
1843+
case 0x18:
1844+
{
17461845
systemPrintf(" 0x%02X - PCA9557 GPIO Expander with Reset\r\n", addr);
17471846
break;
17481847
}

Firmware/RTK_Everywhere/GNSS.ino

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ static void pushGPGGA(char *ggaData)
8888
{
8989
static char storedGPGGA[100];
9090

91-
static SemaphoreHandle_t reentrant = xSemaphoreCreateMutex(); // Create the mutex
91+
static SemaphoreHandle_t reentrant = xSemaphoreCreateMutex(); // Create the mutex
9292

9393
if (xSemaphoreTake(reentrant, 10 / portTICK_PERIOD_MS) == pdPASS)
9494
{
@@ -144,15 +144,16 @@ void gnssDetectReceiverType()
144144
// Note: with this in place, the X5 detection will take a lot longer due to the baud rate change
145145
#ifndef NOT_FACET_FLEX
146146
systemPrintln("<<<<<<<<<< !!!!!!!!!! FLEX FORCED !!!!!!!!!! >>>>>>>>>>");
147-
//settings.detectedGnssReceiver = GNSS_RECEIVER_UNKNOWN; // This may be causing weirdness on the LG290P. Commenting for now
147+
// settings.detectedGnssReceiver = GNSS_RECEIVER_UNKNOWN; // This may be causing weirdness on the LG290P. Commenting for now
148148
#endif
149149

150150
// Start auto-detect if NVM is not yet set
151151
if (settings.detectedGnssReceiver == GNSS_RECEIVER_UNKNOWN)
152152
{
153153
// The COMPILE guards prevent else if
154154
// Use a do while (0) so we can break when GNSS is detected
155-
do {
155+
do
156+
{
156157
#ifdef COMPILE_LG290P
157158
if (lg290pIsPresent() == true)
158159
{
@@ -174,7 +175,7 @@ void gnssDetectReceiverType()
174175
break;
175176
}
176177
#else // COMPILE_MOSAICX5
177-
systemPrintln("<<<<<<<<<< !!!!!!!!!! MOSAICX5 NOT COMPILED !!!!!!!!!! >>>>>>>>>>");
178+
systemPrintln("<<<<<<<<<< !!!!!!!!!! MOSAICX5 NOT COMPILED !!!!!!!!!! >>>>>>>>>>");
178179
#endif // COMPILE_MOSAICX5
179180
} while (0);
180181
}
@@ -221,6 +222,10 @@ void gnssBoot()
221222
{
222223
digitalWrite(pin_GNSS_DR_Reset, HIGH); // Tell UM980 and DR to boot
223224
}
225+
else if (productVariant == RTK_TORCH_X2)
226+
{
227+
digitalWrite(pin_GNSS_DR_Reset, HIGH); // Tell LG290P to boot
228+
}
224229
else if (productVariant == RTK_FLEX)
225230
{
226231
gpioExpanderGnssBoot(); // Drive the GNSS reset pin high
@@ -238,6 +243,10 @@ void gnssReset()
238243
{
239244
digitalWrite(pin_GNSS_DR_Reset, LOW); // Tell UM980 and DR to reset
240245
}
246+
else if (productVariant == RTK_TORCH_X2)
247+
{
248+
digitalWrite(pin_GNSS_Reset, LOW); // Tell LG290P to reset
249+
}
241250
else if (productVariant == RTK_FLEX)
242251
{
243252
gpioExpanderGnssReset(); // Drive the GNSS reset pin low
@@ -315,9 +324,10 @@ void gnssFirmwareBeginUpdate()
315324

316325
systemPrintln();
317326
systemPrintf("Entering GNSS direct connect for firmware update and configuration. Disconnect this terminal "
318-
"connection. Use the GNSS manufacturer software "
319-
"to update the firmware. Baudrate: %dbps. Press the %s button to return "
320-
"to normal operation.\r\n", serialBaud, present.button_mode ? "mode" : "power");
327+
"connection. Use the GNSS manufacturer software "
328+
"to update the firmware. Baudrate: %dbps. Press the %s button to return "
329+
"to normal operation.\r\n",
330+
serialBaud, present.button_mode ? "mode" : "power");
321331
systemFlush();
322332

323333
Serial.end(); // We must end before we begin otherwise the UART settings are corrupted
@@ -347,25 +357,25 @@ void gnssFirmwareBeginUpdate()
347357
Serial.write(serialGNSS->read());
348358

349359
// Button task will gnssFirmwareRemoveUpdate and restart
350-
360+
351361
// Temporary fix for buttonless Flex. TODO - remove
352362
if ((productVariant == RTK_FLEX) && (millis() > (lastSerial + 30000)))
353363
{
354-
// Beep to indicate exit
355-
beepOn();
356-
delay(300);
357-
beepOff();
358-
delay(100);
359-
beepOn();
360-
delay(300);
361-
beepOff();
364+
// Beep to indicate exit
365+
beepOn();
366+
delay(300);
367+
beepOff();
368+
delay(100);
369+
beepOn();
370+
delay(300);
371+
beepOff();
362372

363-
gnssFirmwareRemoveUpdate();
373+
gnssFirmwareRemoveUpdate();
364374

365-
systemPrintln("Exiting direct connection (passthrough) mode");
366-
systemFlush(); // Complete prints
375+
systemPrintln("Exiting direct connection (passthrough) mode");
376+
systemFlush(); // Complete prints
367377

368-
ESP.restart();
378+
ESP.restart();
369379
}
370380
}
371381
}

Firmware/RTK_Everywhere/GNSS_LG290P.ino

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ const char *GNSS_LG290P::getRtcmLowDataRateString()
6767
void GNSS_LG290P::begin()
6868
{
6969
// During identifyBoard(), the GNSS UART and DR pins are set
70+
Serial.println("LG begin");
7071

7172
// The GNSS UART is already started. We can now pass it to the library.
7273
if (serialGNSS == nullptr)
@@ -85,13 +86,13 @@ void GNSS_LG290P::begin()
8586
if (_lg290p->begin(*serialGNSS) == false) // Give the serial port over to the library
8687
{
8788
if (settings.debugGnss)
88-
systemPrintln("GNSS Failed to begin. Trying again.");
89+
systemPrintln("GNSS LG290P failed to begin. Trying again.");
8990

9091
// Try again with power on delay
9192
delay(1000);
9293
if (_lg290p->begin(*serialGNSS) == false)
9394
{
94-
systemPrintln("GNSS offline");
95+
systemPrintln("GNSS LG290P offline");
9596
displayGNSSFail(1000);
9697
return;
9798
}

Firmware/RTK_Everywhere/GNSS_UM980.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,13 @@ void GNSS_UM980::begin()
8686
if (_um980->begin(*serialGNSS) == false) // Give the serial port over to the library
8787
{
8888
if (settings.debugGnss)
89-
systemPrintln("GNSS Failed to begin. Trying again.");
89+
systemPrintln("GNSS UM980 failed to begin. Trying again.");
9090

9191
// Try again with power on delay
9292
delay(1000);
9393
if (_um980->begin(*serialGNSS) == false)
9494
{
95-
systemPrintln("GNSS offline");
95+
systemPrintln("GNSS UM980 offline");
9696
displayGNSSFail(1000);
9797
return;
9898
}

Firmware/RTK_Everywhere/GNSS_ZED.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ void GNSS_ZED::begin()
137137

138138
if (_zed->begin(*i2c_0) == false)
139139
{
140-
systemPrintln("GNSS Failed to begin. Trying again.");
140+
systemPrintln("GNSS ZED failed to begin. Trying again.");
141141

142142
// Try again with power on delay
143143
delay(1000); // Wait for ZED-F9P to power up before it can respond to ACK

0 commit comments

Comments
 (0)