@@ -73,13 +73,19 @@ void identifyBoard()
73
73
else if (idWithAdc (idValue, 10 , 100 ))
74
74
productVariant = RTK_EVK;
75
75
76
+ // Facet mosaic: 1/4.7 --> 2674mV < 2721mV < 2766mV
77
+ else if (idWithAdc (idValue, 1 , 4.7 ))
78
+ productVariant = RTK_FACET_MOSAIC;
79
+
76
80
// ID resistors do not exist for the following:
77
81
// Torch
78
82
else
79
83
{
80
84
log_d (" Out of band or nonexistent resistor IDs" );
81
85
82
86
// Check if a bq40Z50 battery manager is on the I2C bus
87
+ if (i2c_0 == nullptr )
88
+ i2c_0 = new TwoWire (0 );
83
89
int pin_SDA = 15 ;
84
90
int pin_SCL = 4 ;
85
91
@@ -161,6 +167,10 @@ void beginBoard()
161
167
162
168
pin_beeper = 33 ;
163
169
170
+ pin_loraRadio_power = 19 ; // LoRa_EN
171
+ pin_loraRadio_boot = 23 ; // LoRa_BOOT0
172
+ pin_loraRadio_reset = 5 ; // LoRa_NRST
173
+
164
174
DMW_if systemPrintf (" pin_bluetoothStatusLED: %d\r\n " , pin_bluetoothStatusLED);
165
175
pinMode (pin_bluetoothStatusLED, OUTPUT);
166
176
@@ -176,6 +186,13 @@ void beginBoard()
176
186
batteryStatusLedOn ();
177
187
178
188
pinMode (pin_beeper, OUTPUT);
189
+
190
+ // Beep at power on if we are not locally compiled or a release candidate
191
+ if (ENABLE_DEVELOPER == false )
192
+ {
193
+ beepOn ();
194
+ delay (250 );
195
+ }
179
196
beepOff ();
180
197
181
198
pinMode (pin_powerButton, INPUT);
@@ -191,6 +208,15 @@ void beginBoard()
191
208
digitalWrite (pin_usbSelect, HIGH); // Keep CH340 connected to USB bus
192
209
193
210
settings.dataPortBaud = 115200 ; // Override settings. Use UM980 at 115200bps.
211
+
212
+ pinMode (pin_loraRadio_power, OUTPUT);
213
+ digitalWrite (pin_loraRadio_power, LOW); // Keep LoRa powered down
214
+
215
+ pinMode (pin_loraRadio_boot, OUTPUT);
216
+ digitalWrite (pin_loraRadio_boot, LOW);
217
+
218
+ pinMode (pin_loraRadio_reset, OUTPUT);
219
+ digitalWrite (pin_loraRadio_reset, LOW); // Keep LoRa in reset
194
220
}
195
221
196
222
else if (productVariant == RTK_EVK)
@@ -208,7 +234,9 @@ void beginBoard()
208
234
present.antennaShortOpen = true ;
209
235
present.timePulseInterrupt = true ;
210
236
present.i2c0BusSpeed_400 = true ; // Run bus at higher speed
211
- present.display_128x64_i2c1 = true ;
237
+ present.i2c1 = true ;
238
+ present.display_i2c1 = true ;
239
+ present.display_type = DISPLAY_128x64;
212
240
present.i2c1BusSpeed_400 = true ; // Run display bus at higher speed
213
241
214
242
// Pin Allocations:
@@ -252,6 +280,10 @@ void beginBoard()
252
280
pin_microSD_CardDetect = 36 ;
253
281
// 5, A39 : Unused analog pin - used to generate random values for SSL
254
282
283
+ // Select the I2C 0 data structure
284
+ if (i2c_0 == nullptr )
285
+ i2c_0 = new TwoWire (0 );
286
+
255
287
// Disable the Ethernet controller
256
288
DMW_if systemPrintf (" pin_Ethernet_CS: %d\r\n " , pin_Ethernet_CS);
257
289
pinMode (pin_Ethernet_CS, OUTPUT);
@@ -274,12 +306,14 @@ void beginBoard()
274
306
pinMode (pin_peripheralPowerControl, OUTPUT);
275
307
peripheralsOn (); // Turn on power to OLED, SD, ZED, NEO, USB Hub,
276
308
}
309
+
277
310
else if (productVariant == RTK_FACET_V2)
278
311
{
279
- present.psram_2mb = true ;
312
+ present.psram_4mb = true ;
280
313
present.gnss_zedf9p = true ;
281
314
present.microSd = true ;
282
- present.display_64x48_i2c0 = true ;
315
+ present.display_i2c0 = true ;
316
+ present.display_type = DISPLAY_64x48;
283
317
present.button_powerLow = true ; // Button is pressed when low
284
318
present.battery_max17048 = true ;
285
319
present.portDataMux = true ;
@@ -294,6 +328,47 @@ void beginBoard()
294
328
pinMode (pin_powerFastOff, OUTPUT);
295
329
digitalWrite (pin_powerFastOff, HIGH); // Stay on
296
330
}
331
+
332
+ else if (productVariant == RTK_FACET_MOSAIC)
333
+ {
334
+ present.psram_4mb = true ;
335
+ present.gnss_mosaic = true ;
336
+ present.display_i2c0 = true ;
337
+ present.display_type = DISPLAY_64x48;
338
+ present.i2c0BusSpeed_400 = true ;
339
+ present.peripheralPowerControl = true ;
340
+ present.button_powerLow = true ; // Button is pressed when low
341
+ present.battery_max17048 = true ;
342
+ present.portDataMux = true ;
343
+ present.fastPowerOff = true ;
344
+
345
+ pin_batteryStatusLED = 34 ;
346
+ pin_muxA = 18 ;
347
+ pin_muxB = 19 ;
348
+ pin_powerSenseAndControl = 32 ;
349
+ pin_powerFastOff = 33 ;
350
+ pin_muxDAC = 26 ;
351
+ pin_muxADC = 39 ;
352
+ pin_peripheralPowerControl = 27 ;
353
+ pin_I2C0_SDA = 21 ;
354
+ pin_I2C0_SCL = 22 ;
355
+ pin_GnssUart_RX = 13 ;
356
+ pin_GnssUart_TX = 14 ;
357
+ pin_GnssLBandUart_RX = 4 ;
358
+ pin_GnssLBandUart_TX = 25 ;
359
+
360
+ pinMode (pin_muxA, OUTPUT);
361
+ pinMode (pin_muxB, OUTPUT);
362
+
363
+ // pinMode(pin_powerFastOff, OUTPUT);
364
+ // digitalWrite(pin_powerFastOff, HIGH); // Stay on
365
+ pinMode (pin_powerFastOff, INPUT);
366
+
367
+ // Turn on power to the mosaic and OLED
368
+ DMW_if systemPrintf (" pin_peripheralPowerControl: %d\r\n " , pin_peripheralPowerControl);
369
+ pinMode (pin_peripheralPowerControl, OUTPUT);
370
+ peripheralsOn (); // Turn on power to OLED, SD, ZED, NEO, USB Hub,
371
+ }
297
372
}
298
373
299
374
void beginVersion ()
@@ -744,13 +819,25 @@ void tickerBegin()
744
819
}
745
820
}
746
821
822
+ // Stop any ticker tasks and PWM control
823
+ void tickerStop ()
824
+ {
825
+ bluetoothLedTask.detach ();
826
+ gnssLedTask.detach ();
827
+ batteryLedTask.detach ();
828
+
829
+ ledcDetachPin (pin_bluetoothStatusLED);
830
+ ledcDetachPin (pin_gnssStatusLED);
831
+ ledcDetachPin (pin_batteryStatusLED);
832
+ }
833
+
747
834
// Configure the battery fuel gauge
748
835
void beginFuelGauge ()
749
836
{
750
837
if (present.battery_max17048 == true )
751
838
{
752
839
// Set up the MAX17048 LiPo fuel gauge
753
- if (lipo.begin () == false )
840
+ if (lipo.begin (*i2c_0 ) == false )
754
841
{
755
842
systemPrintln (" Fuel gauge not detected" );
756
843
return ;
@@ -793,7 +880,7 @@ void beginFuelGauge()
793
880
return ;
794
881
}
795
882
796
- if (bq40z50Battery->begin () == false )
883
+ if (bq40z50Battery->begin (*i2c_0 ) == false )
797
884
{
798
885
systemPrintln (" BQ40Z50 not detected" );
799
886
delete bq40z50Battery;
@@ -810,14 +897,21 @@ void beginFuelGauge()
810
897
// Check to see if we are dangerously low
811
898
if ((batteryLevelPercent < 5 ) && (isCharging () == false )) // 5% and not charging
812
899
{
813
- systemPrintln (" Battery too low. Please charge. Shutting down..." );
900
+ // Currently only the Torch uses the BQ40Z50 and it does not have software shutdown
901
+ // So throw a warning, but don't do anything else.
902
+ systemPrintln (" Battery too low. Please charge." );
814
903
815
- if (online. display == true )
816
- displayMessage ( " Charge Battery " , 0 );
904
+ // If future platforms use the BQ40Z50 and have software shutdown, allow it
905
+ // but avoid blocking Torch with the infinite loop of powerDown().
817
906
818
- delay ( 2000 );
907
+ // systemPrintln("Battery too low. Please charge. Shutting down..." );
819
908
820
- powerDown (false ); // Don't display 'Shutting Down'
909
+ // if (online.display == true)
910
+ // displayMessage("Charge Battery", 0);
911
+
912
+ // delay(2000);
913
+
914
+ // powerDown(false); // Don't display 'Shutting Down'
821
915
}
822
916
}
823
917
#endif // COMPILE_BQ40Z50
@@ -898,9 +992,19 @@ void beginSystemState()
898
992
firstRoverStart = false ;
899
993
}
900
994
else if (productVariant == RTK_EVK)
995
+ {
996
+ firstRoverStart = false ; // Screen should have been tested when it was made ;-)
997
+ // Return to either NTP, Base or Rover Not Started. The last state previous to power down.
998
+ systemState = settings.lastState ;
999
+ }
1000
+ else if (productVariant == RTK_FACET_MOSAIC)
901
1001
{
902
1002
// Return to either NTP, Base or Rover Not Started. The last state previous to power down.
903
1003
systemState = settings.lastState ;
1004
+
1005
+ firstRoverStart = true ; // Allow user to enter test screen during first rover start
1006
+ if (systemState == STATE_BASE_NOT_STARTED)
1007
+ firstRoverStart = false ;
904
1008
}
905
1009
else if (productVariant == RTK_TORCH)
906
1010
{
@@ -944,10 +1048,30 @@ void beginI2C()
944
1048
{
945
1049
TaskHandle_t taskHandle;
946
1050
947
- if (present.display_128x64_i2c1 == true )
1051
+ if (i2c_0 == nullptr ) // i2c_0 could have been instantiated by identifyBoard
1052
+ i2c_0 = new TwoWire (0 );
1053
+
1054
+ if (present.i2c1 == true )
1055
+ {
1056
+ if (i2c_1 == nullptr )
1057
+ i2c_1 = new TwoWire (1 );
1058
+ }
1059
+
1060
+ if ((present.display_i2c0 == true ) && (present.display_i2c1 == true ))
1061
+ reportFatalError (" Displays on both i2c_0 and i2c_1" );
1062
+
1063
+ if (present.display_i2c0 == true )
1064
+ {
1065
+ // Display is on standard Wire bus
1066
+ i2cDisplay = i2c_0;
1067
+ }
1068
+
1069
+ if (present.display_i2c1 == true )
948
1070
{
1071
+ if (present.i2c1 == false )
1072
+ reportFatalError (" No i2c1 for display_i2c1" );
1073
+
949
1074
// Display is on I2C bus 1
950
- i2c_1 = new TwoWire (1 );
951
1075
i2cDisplay = i2c_1;
952
1076
953
1077
// Display splash screen for at least 1 second
@@ -994,7 +1118,7 @@ void pinI2CTask(void *pvParameters)
994
1118
online.i2c = true ;
995
1119
996
1120
// Initialize I2C bus 1
997
- if (i2c_1 )
1121
+ if (present. i2c1 )
998
1122
{
999
1123
int bus1speed = 100 ;
1000
1124
if (present.i2c1BusSpeed_400 == true )
@@ -1157,6 +1281,18 @@ void deleteSDSizeCheckTask()
1157
1281
}
1158
1282
}
1159
1283
1284
+ // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
1285
+
1286
+ // Check and initialize any arrays that won't be initialized by gnssConfigure (checkGNSSArrayDefaults)
1287
+ // TODO: find a better home for this
1288
+ void checkArrayDefaults ()
1289
+ {
1290
+ if (!validateCorrectionPriorities ())
1291
+ initializeCorrectionPriorities ();
1292
+ if (!validateCorrectionPriorities ())
1293
+ reportFatalError (" initializeCorrectionPriorities failed." );
1294
+ }
1295
+
1160
1296
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
1161
1297
// Time Pulse ISR
1162
1298
// Triggered by the rising edge of the time pulse signal, indicates the top-of-second.
0 commit comments