@@ -94,23 +94,42 @@ void identifyBoard()
94
94
// 0x08 - HUSB238 - USB C PD Sink Controller
95
95
bool husb238Present = i2cIsDevicePresent (i2c_0, 0x08 );
96
96
97
+ // Flex has everything a Torch does and a display
98
+ // 0x3C - SSD1306 OLED Driver
99
+ // If a display is present, it's not a Torch
100
+ // bool displayPresent = i2cIsDevicePresent(i2c_0, 0x3C);
101
+ bool displayPresent = i2cIsDevicePresent (i2c_0, 0x10 );
102
+
97
103
i2c_0->end ();
98
104
99
- if (bq40z50Present || mp2762aPresent || husb238Present)
100
- productVariant = RTK_TORCH;
105
+ // Proceed with Torch ID only if display is absent
106
+ if (displayPresent == false )
107
+ {
108
+ if (bq40z50Present || mp2762aPresent || husb238Present)
109
+ {
110
+ productVariant = RTK_TORCH;
111
+ }
101
112
102
- if (productVariant == RTK_TORCH && bq40z50Present == false )
103
- systemPrintln (" Error: Torch ID'd with no BQ40Z50 present" );
113
+ if (productVariant == RTK_TORCH && bq40z50Present == false )
114
+ systemPrintln (" Error: Torch ID'd with no BQ40Z50 present" );
104
115
105
- if (productVariant == RTK_TORCH && mp2762aPresent == false )
106
- systemPrintln (" Error: Torch ID'd with no MP2762A present" );
116
+ if (productVariant == RTK_TORCH && mp2762aPresent == false )
117
+ systemPrintln (" Error: Torch ID'd with no MP2762A present" );
107
118
108
- if (productVariant == RTK_TORCH && husb238Present == false )
109
- systemPrintln (" Error: Torch ID'd with no HUSB238 present" );
119
+ if (productVariant == RTK_TORCH && husb238Present == false )
120
+ systemPrintln (" Error: Torch ID'd with no HUSB238 present" );
121
+ }
110
122
}
111
123
112
124
if (productVariant == RTK_UNKNOWN)
113
125
{
126
+ // TODO remove once v1.1 Flex has ID resistors
127
+ if (i2c_0 == nullptr )
128
+ i2c_0 = new TwoWire (0 );
129
+ int pin_SDA = 15 ;
130
+ int pin_SCL = 4 ;
131
+ i2c_0->begin (pin_SDA, pin_SCL); // SDA, SCL
132
+
114
133
// Use ADC to check the resistor divider
115
134
int pin_deviceID = 35 ;
116
135
uint16_t idValue = analogReadMilliVolts (pin_deviceID);
@@ -139,13 +158,23 @@ void identifyBoard()
139
158
else if (idWithAdc (idValue, 12.1 , 1.5 , 8.5 ))
140
159
productVariant = RTK_FACET_V2_LBAND;
141
160
142
- // Facet v2: 10.0/2.7 --> 612mV < 702mV < 801mV (8.5% tolerance)
143
- else if (idWithAdc (idValue, 10.0 , 2.7 , 8.5 ))
144
- productVariant = RTK_FACET_V2;
161
+ // Facet Flex: 10.0/20.0 --> 2071mV < 2200mV < 2322mV (8.5% tolerance)
162
+ else if (idWithAdc (idValue, 10.0 , 20.0 , 8.5 ))
163
+ productVariant = RTK_FLEX;
164
+
165
+ // 0x3C - SSD1306 OLED Driver found in RTK Flex
166
+ // TODO remove once v1.1 hardware has ID resistors
167
+ // else if (i2cIsDevicePresent(i2c_0, 0x3C) == true || i2cIsDevicePresent(i2c_0, 0x10) == true)
168
+ // productVariant = RTK_FLEX;
145
169
146
170
// Postcard: 3.3/10 --> 2371mV < 2481mV < 2582mV (8.5% tolerance)
147
171
else if (idWithAdc (idValue, 3.3 , 10 , 8.5 ))
148
172
productVariant = RTK_POSTCARD;
173
+
174
+ productVariant = RTK_FLEX; // TODO remove hard override
175
+
176
+ // TODO remove once v1.1 Flex has ID resistors
177
+ i2c_0->end ();
149
178
}
150
179
151
180
if (ENABLE_DEVELOPER)
@@ -273,7 +302,7 @@ void beginBoard()
273
302
pinMode (pin_GNSS_TimePulse, INPUT);
274
303
275
304
pinMode (pin_GNSS_DR_Reset, OUTPUT);
276
- um980Boot (); // Tell UM980 and DR to boot
305
+ gnssBoot (); // Tell UM980 and DR to boot
277
306
278
307
pinMode (pin_powerAdapterDetect, INPUT); // Has 10k pullup
279
308
@@ -699,7 +728,7 @@ void beginBoard()
699
728
present.i2c0BusSpeed_400 = true ; // Run display bus at higher speed
700
729
present.display_type = DISPLAY_128x64;
701
730
present.microSd = true ;
702
- present.gpioExpander = true ;
731
+ present.gpioExpanderButtons = true ;
703
732
present.microSdCardDetectGpioExpanderHigh = true ; // CD is on GPIO 5 of expander. High = SD in place.
704
733
705
734
// We can't enable here because we don't know if lg290pFirmwareVersion is >= v05
@@ -734,12 +763,92 @@ void beginBoard()
734
763
pinMode (pin_GNSS_TimePulse, INPUT);
735
764
736
765
pinMode (pin_GNSS_Reset, OUTPUT);
737
- lg290pBoot (); // Tell LG290P to boot
766
+ gnssBoot (); // Tell LG290P to boot
738
767
739
768
// Disable the microSD card
740
769
pinMode (pin_microSD_CS, OUTPUT);
741
770
sdDeselectCard ();
742
771
}
772
+
773
+ else if (productVariant == RTK_FLEX)
774
+ {
775
+ // #ifdef COMPILE_LG290P
776
+ // gnss = (GNSS *)new GNSS_LG290P();
777
+ // #else // COMPILE_LGP290P
778
+ // gnss = (GNSS *)new GNSS_None();
779
+ // systemPrintln("<<<<<<<<<< !!!!!!!!!! LG290P NOT COMPILED !!!!!!!!!! >>>>>>>>>>");
780
+ // #endif // COMPILE_LGP290P
781
+
782
+ present.brand = BRAND_SPARKPNT;
783
+ present.psram_2mb = true ;
784
+
785
+ present.gnss_lg290p = true ;
786
+
787
+ present.antennaPhaseCenter_mm = 42.0 ; // Default to SPK6618H APC, average of L1/L2
788
+ present.radio_lora = true ;
789
+ present.fuelgauge_bq40z50 = true ;
790
+ present.charger_mp2762a = true ;
791
+
792
+ // TODO Change to MFi present.encryption_atecc608a = true;
793
+
794
+ present.button_powerHigh = true ; // Button is pressed when high
795
+ present.beeper = true ;
796
+ present.gnss_to_uart = true ;
797
+ present.needsExternalPpl = true ; // Uses the PointPerfect Library
798
+
799
+ // TODO this will need to be based on module ID
800
+ present.minCno = true ;
801
+ present.minElevation = true ;
802
+ present.dynamicModel = true ;
803
+
804
+ present.gpioExpanderSwitches = true ;
805
+
806
+ present.display_i2c0 = true ;
807
+ // present.i2c0BusSpeed_400 = true; // Run display bus at higher speed
808
+ present.display_type = DISPLAY_128x64_INVERTED;
809
+ present.tiltPossible = true ;
810
+
811
+ pin_I2C0_SDA = 15 ;
812
+ pin_I2C0_SCL = 4 ;
813
+
814
+ pin_GnssUart_RX = 26 ;
815
+ pin_GnssUart_TX = 27 ;
816
+
817
+ pin_powerButton = 34 ;
818
+
819
+ pin_IMU_RX = 14 ; // ESP32 UART2
820
+ pin_IMU_TX = 17 ;
821
+
822
+ pin_powerAdapterDetect = 36 ; // Goes low when USB cable is plugged in
823
+
824
+ pin_bluetoothStatusLED = 32 ;
825
+ pin_gnssStatusLED = 13 ;
826
+
827
+ pin_beeper = 33 ;
828
+
829
+ pin_gpioExpanderInterrupt = 2 ; // Not used since all GPIO expanded pins are outputs
830
+
831
+ DMW_if systemPrintf (" pin_bluetoothStatusLED: %d\r\n " , pin_bluetoothStatusLED);
832
+ pinMode (pin_bluetoothStatusLED, OUTPUT);
833
+
834
+ DMW_if systemPrintf (" pin_gnssStatusLED: %d\r\n " , pin_gnssStatusLED);
835
+ pinMode (pin_gnssStatusLED, OUTPUT);
836
+
837
+ // Turn on Bluetooth, GNSS, and Battery LEDs to indicate power on
838
+ bluetoothLedOn ();
839
+ gnssStatusLedOn ();
840
+
841
+ pinMode (pin_beeper, OUTPUT);
842
+ beepOff ();
843
+
844
+ pinMode (pin_powerButton, INPUT);
845
+
846
+ pinMode (pin_powerAdapterDetect, INPUT); // Has 10k pullup
847
+
848
+ // We don't disable peripherals (aka set pins on the GPIO expander) here because I2C has not yet been started
849
+
850
+ // GNSS receiver type is determined later in gnssDetectReceiverType()
851
+ }
743
852
}
744
853
745
854
void beginVersion ()
@@ -1050,6 +1159,21 @@ void pinGnssUartTask(void *pvParameters)
1050
1159
// LG290P communicates at 460800bps.
1051
1160
platformGnssCommunicationRate = 115200 * 4 ;
1052
1161
}
1162
+ else if (productVariant == RTK_FLEX)
1163
+ {
1164
+ Serial.println (" Starting UART for flex" );
1165
+ if (settings.detectedGnssReceiver == GNSS_RECEIVER_LG290P)
1166
+ {
1167
+ Serial.println (" Starting UART for LG290P" );
1168
+ // LG290P communicates at 460800bps.
1169
+ platformGnssCommunicationRate = 115200 * 4 ;
1170
+ }
1171
+ else
1172
+ {
1173
+ // If we don't know the GNSS receiver, default to 115200
1174
+ platformGnssCommunicationRate = 115200 ;
1175
+ }
1176
+ }
1053
1177
1054
1178
serialGNSS->begin (platformGnssCommunicationRate, SERIAL_8N1, pin_GnssUart_RX,
1055
1179
pin_GnssUart_TX); // Start UART on platform dependent pins for SPP. The GNSS will be
@@ -1283,7 +1407,7 @@ void beginCharger()
1283
1407
void beginButtons ()
1284
1408
{
1285
1409
if (present.button_powerHigh == false && present.button_powerLow == false && present.button_mode == false &&
1286
- present.gpioExpander == false )
1410
+ present.gpioExpanderButtons == false )
1287
1411
return ;
1288
1412
1289
1413
TaskHandle_t taskHandle;
@@ -1296,16 +1420,16 @@ void beginButtons()
1296
1420
buttonCount++;
1297
1421
if (present.button_mode == true )
1298
1422
buttonCount++;
1299
- if (present.gpioExpander == true )
1423
+ if (present.gpioExpanderButtons == true )
1300
1424
buttonCount++;
1301
1425
if (buttonCount > 1 )
1302
1426
reportFatalError (" Illegal button assignment." );
1303
1427
1304
1428
// Postcard button uses an I2C expander
1305
1429
// Avoid using the button library
1306
- if (present.gpioExpander == true )
1430
+ if (present.gpioExpanderButtons == true )
1307
1431
{
1308
- if (beginGpioExpander (0x20 ) == false )
1432
+ if (beginGpioExpanderButtons (0x20 ) == false )
1309
1433
{
1310
1434
systemPrintln (" Directional pad not detected" );
1311
1435
return ;
@@ -1337,7 +1461,7 @@ void beginButtons()
1337
1461
online.button = true ;
1338
1462
}
1339
1463
1340
- if (online.button == true || online.gpioExpander == true )
1464
+ if (online.button == true || online.gpioExpanderButtons == true )
1341
1465
{
1342
1466
// Starts task for monitoring button presses
1343
1467
if (!task.buttonCheckTaskRunning )
@@ -1412,6 +1536,15 @@ void beginSystemState()
1412
1536
if (systemState == STATE_BASE_NOT_STARTED)
1413
1537
firstRoverStart = false ;
1414
1538
}
1539
+ else if (productVariant == RTK_FLEX)
1540
+ {
1541
+ // Return to either Rover or Base Not Started. The last state previous to power down.
1542
+ systemState = settings.lastState ;
1543
+
1544
+ firstRoverStart = true ; // Allow user to enter test screen during first rover start
1545
+ if (systemState == STATE_BASE_NOT_STARTED)
1546
+ firstRoverStart = false ;
1547
+ }
1415
1548
else
1416
1549
{
1417
1550
systemPrintf (" beginSystemState: Unknown product variant: %d\r\n " , productVariant);
@@ -1592,6 +1725,11 @@ bool i2cBusInitialization(TwoWire *i2cBus, int sda, int scl, int clockKHz)
1592
1725
break ;
1593
1726
}
1594
1727
1728
+ case 0x10 : {
1729
+ systemPrintf (" 0x%02X - MFi Authentication Coprocessor\r\n " , addr);
1730
+ break ;
1731
+ }
1732
+
1595
1733
case 0x18 : {
1596
1734
systemPrintf (" 0x%02X - PCA9557 GPIO Expander with Reset\r\n " , addr);
1597
1735
break ;
@@ -1603,7 +1741,12 @@ bool i2cBusInitialization(TwoWire *i2cBus, int sda, int scl, int clockKHz)
1603
1741
}
1604
1742
1605
1743
case 0x20 : {
1606
- systemPrintf (" 0x%02X - PCA9554 GPIO Expander with Interrupt\r\n " , addr);
1744
+ systemPrintf (" 0x%02X - PCA9554 GPIO Expander with Interrupt (Postcard)\r\n " , addr);
1745
+ break ;
1746
+ }
1747
+
1748
+ case 0x21 : {
1749
+ systemPrintf (" 0x%02X - PCA9554 GPIO Expander with Interrupt (Flex)\r\n " , addr);
1607
1750
break ;
1608
1751
}
1609
1752
@@ -1617,13 +1760,18 @@ bool i2cBusInitialization(TwoWire *i2cBus, int sda, int scl, int clockKHz)
1617
1760
break ;
1618
1761
}
1619
1762
1763
+ case 0x3C : {
1764
+ systemPrintf (" 0x%02X - SSD1306 OLED Driver (Flex)\r\n " , addr);
1765
+ break ;
1766
+ }
1767
+
1620
1768
case 0x3D : {
1621
- systemPrintf (" 0x%02X - SSD1306 OLED Driver\r\n " , addr);
1769
+ systemPrintf (" 0x%02X - SSD1306 OLED Driver (Postcard/EVK/mosaic) \r\n " , addr);
1622
1770
break ;
1623
1771
}
1624
1772
1625
1773
case 0x42 : {
1626
- systemPrintf (" 0x%02X - u-blox ZED-F9P GNSS Receiver\r\n " , addr);
1774
+ systemPrintf (" 0x%02X - u-blox GNSS Receiver\r\n " , addr);
1627
1775
break ;
1628
1776
}
1629
1777
0 commit comments