@@ -73,13 +73,19 @@ void identifyBoard()
7373 else if (idWithAdc (idValue, 10 , 100 ))
7474 productVariant = RTK_EVK;
7575
76+ // Facet mosaic: 1/4.7 --> 2674mV < 2721mV < 2766mV
77+ else if (idWithAdc (idValue, 1 , 4.7 ))
78+ productVariant = RTK_FACET_MOSAIC;
79+
7680 // ID resistors do not exist for the following:
7781 // Torch
7882 else
7983 {
8084 log_d (" Out of band or nonexistent resistor IDs" );
8185
8286 // Check if a bq40Z50 battery manager is on the I2C bus
87+ if (i2c_0 == nullptr )
88+ i2c_0 = new TwoWire (0 );
8389 int pin_SDA = 15 ;
8490 int pin_SCL = 4 ;
8591
@@ -161,6 +167,10 @@ void beginBoard()
161167
162168 pin_beeper = 33 ;
163169
170+ pin_loraRadio_power = 19 ; // LoRa_EN
171+ pin_loraRadio_boot = 23 ; // LoRa_BOOT0
172+ pin_loraRadio_reset = 5 ; // LoRa_NRST
173+
164174 DMW_if systemPrintf (" pin_bluetoothStatusLED: %d\r\n " , pin_bluetoothStatusLED);
165175 pinMode (pin_bluetoothStatusLED, OUTPUT);
166176
@@ -176,6 +186,13 @@ void beginBoard()
176186 batteryStatusLedOn ();
177187
178188 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+ }
179196 beepOff ();
180197
181198 pinMode (pin_powerButton, INPUT);
@@ -191,6 +208,15 @@ void beginBoard()
191208 digitalWrite (pin_usbSelect, HIGH); // Keep CH340 connected to USB bus
192209
193210 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
194220 }
195221
196222 else if (productVariant == RTK_EVK)
@@ -208,7 +234,9 @@ void beginBoard()
208234 present.antennaShortOpen = true ;
209235 present.timePulseInterrupt = true ;
210236 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;
212240 present.i2c1BusSpeed_400 = true ; // Run display bus at higher speed
213241
214242 // Pin Allocations:
@@ -252,6 +280,10 @@ void beginBoard()
252280 pin_microSD_CardDetect = 36 ;
253281 // 5, A39 : Unused analog pin - used to generate random values for SSL
254282
283+ // Select the I2C 0 data structure
284+ if (i2c_0 == nullptr )
285+ i2c_0 = new TwoWire (0 );
286+
255287 // Disable the Ethernet controller
256288 DMW_if systemPrintf (" pin_Ethernet_CS: %d\r\n " , pin_Ethernet_CS);
257289 pinMode (pin_Ethernet_CS, OUTPUT);
@@ -274,12 +306,14 @@ void beginBoard()
274306 pinMode (pin_peripheralPowerControl, OUTPUT);
275307 peripheralsOn (); // Turn on power to OLED, SD, ZED, NEO, USB Hub,
276308 }
309+
277310 else if (productVariant == RTK_FACET_V2)
278311 {
279- present.psram_2mb = true ;
312+ present.psram_4mb = true ;
280313 present.gnss_zedf9p = true ;
281314 present.microSd = true ;
282- present.display_64x48_i2c0 = true ;
315+ present.display_i2c0 = true ;
316+ present.display_type = DISPLAY_64x48;
283317 present.button_powerLow = true ; // Button is pressed when low
284318 present.battery_max17048 = true ;
285319 present.portDataMux = true ;
@@ -294,6 +328,47 @@ void beginBoard()
294328 pinMode (pin_powerFastOff, OUTPUT);
295329 digitalWrite (pin_powerFastOff, HIGH); // Stay on
296330 }
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+ }
297372}
298373
299374void beginVersion ()
@@ -744,13 +819,25 @@ void tickerBegin()
744819 }
745820}
746821
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+
747834// Configure the battery fuel gauge
748835void beginFuelGauge ()
749836{
750837 if (present.battery_max17048 == true )
751838 {
752839 // Set up the MAX17048 LiPo fuel gauge
753- if (lipo.begin () == false )
840+ if (lipo.begin (*i2c_0 ) == false )
754841 {
755842 systemPrintln (" Fuel gauge not detected" );
756843 return ;
@@ -793,7 +880,7 @@ void beginFuelGauge()
793880 return ;
794881 }
795882
796- if (bq40z50Battery->begin () == false )
883+ if (bq40z50Battery->begin (*i2c_0 ) == false )
797884 {
798885 systemPrintln (" BQ40Z50 not detected" );
799886 delete bq40z50Battery;
@@ -810,14 +897,21 @@ void beginFuelGauge()
810897 // Check to see if we are dangerously low
811898 if ((batteryLevelPercent < 5 ) && (isCharging () == false )) // 5% and not charging
812899 {
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." );
814903
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().
817906
818- delay ( 2000 );
907+ // systemPrintln("Battery too low. Please charge. Shutting down..." );
819908
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'
821915 }
822916 }
823917#endif // COMPILE_BQ40Z50
@@ -898,9 +992,19 @@ void beginSystemState()
898992 firstRoverStart = false ;
899993 }
900994 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)
9011001 {
9021002 // Return to either NTP, Base or Rover Not Started. The last state previous to power down.
9031003 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 ;
9041008 }
9051009 else if (productVariant == RTK_TORCH)
9061010 {
@@ -944,10 +1048,30 @@ void beginI2C()
9441048{
9451049 TaskHandle_t taskHandle;
9461050
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 )
9481070 {
1071+ if (present.i2c1 == false )
1072+ reportFatalError (" No i2c1 for display_i2c1" );
1073+
9491074 // Display is on I2C bus 1
950- i2c_1 = new TwoWire (1 );
9511075 i2cDisplay = i2c_1;
9521076
9531077 // Display splash screen for at least 1 second
@@ -994,7 +1118,7 @@ void pinI2CTask(void *pvParameters)
9941118 online.i2c = true ;
9951119
9961120 // Initialize I2C bus 1
997- if (i2c_1 )
1121+ if (present. i2c1 )
9981122 {
9991123 int bus1speed = 100 ;
10001124 if (present.i2c1BusSpeed_400 == true )
@@ -1157,6 +1281,18 @@ void deleteSDSizeCheckTask()
11571281 }
11581282}
11591283
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+
11601296// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
11611297// Time Pulse ISR
11621298// Triggered by the rising edge of the time pulse signal, indicates the top-of-second.
0 commit comments