@@ -202,6 +202,10 @@ int pin_gnssStatusLED = PIN_UNDEFINED; // LED on Torch
202
202
203
203
int pin_muxA = PIN_UNDEFINED;
204
204
int pin_muxB = PIN_UNDEFINED;
205
+ int pin_mux1 = PIN_UNDEFINED;
206
+ int pin_mux2 = PIN_UNDEFINED;
207
+ int pin_mux3 = PIN_UNDEFINED;
208
+ int pin_mux4 = PIN_UNDEFINED;
205
209
int pin_powerSenseAndControl = PIN_UNDEFINED; // Power button and power down I/O on Facet
206
210
int pin_modeButton = PIN_UNDEFINED; // Mode button on EVK
207
211
int pin_powerButton = PIN_UNDEFINED; // Power and general purpose button on Torch
@@ -273,6 +277,16 @@ int gpioExpander_right = 2;
273
277
int gpioExpander_left = 3 ;
274
278
int gpioExpander_center = 4 ;
275
279
int gpioExpander_cardDetect = 5 ;
280
+
281
+ int gpioExpanderSwitch_S1 = 0 ; // Controls U16 switch 1: connect ESP UART0 to CH342 or SW2
282
+ int gpioExpanderSwitch_S2 = 1 ; // Controls U17 switch 2: connect SW1 to RS232 Output or GNSS UART4
283
+ int gpioExpanderSwitch_S3 = 2 ; // Controls U18 switch 3: connect ESP UART2 to GNSS UART3 or LoRa UART2
284
+ int gpioExpanderSwitch_S4 = 3 ; // Controls U19 switch 4: connect GNSS UART2 to 4-pin JST TTL Serial or LoRa UART0
285
+ int gpioExpanderSwitch_LoraEnable = 4 ; // LoRa_EN
286
+ int gpioExpanderSwitch_GNSS_Reset = 5 ; // RST_GNSS
287
+ int gpioExpanderSwitch_LoraBoot = 6 ; // LoRa_BOOT0 - Used for bootloading the STM32 radio IC
288
+ int gpioExpanderSwitch_PowerFastOff = 7 ; // PWRKILL
289
+
276
290
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
277
291
278
292
// I2C for GNSS, battery gauge, display
@@ -374,7 +388,7 @@ bool wifiEspNowRunning; // False: stopped, True: starting, running, stop
374
388
uint32_t wifiReconnectionTimer; // Delay before reconnection, timer running when non-zero
375
389
bool wifiSoftApOnline; // WiFi soft AP started successfully
376
390
bool wifiSoftApRunning; // False: stopped, True: starting, running, stopping
377
- bool wifiSoftApConnected; // False: no client connected, True: client connected
391
+ bool wifiSoftApConnected; // False: no client connected, True: client connected
378
392
bool wifiStationOnline; // WiFi station started successfully
379
393
bool wifiStationRunning; // False: stopped, True: starting, running, stopping
380
394
@@ -758,6 +772,8 @@ uint8_t gpioExpander_lastReleased = 255;
758
772
#define GPIO_EXPANDER_CARD_INSERTED 1
759
773
#define GPIO_EXPANDER_CARD_REMOVED 0
760
774
775
+ SFE_PCA95XX *gpioExpanderSwitches = nullptr ;
776
+
761
777
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
762
778
763
779
// Global variables
@@ -1206,14 +1222,16 @@ void setup()
1206
1222
1207
1223
DMW_b (" beginMux" );
1208
1224
beginMux (); // Must come before I2C activity to avoid external devices from corrupting the bus. See issue #474:
1209
- // https://github.com/sparkfun/SparkFun_RTK_Firmware/issues/474
1225
+ // https://github.com/sparkfun/SparkFun_RTK_Firmware/issues/474
1210
1226
1211
1227
DMW_b (" peripheralsOn" );
1212
1228
peripheralsOn (); // Enable power for the display, SD, etc
1213
1229
1214
1230
DMW_b (" beginI2C" );
1215
1231
beginI2C (); // Requires settings and peripheral power (if applicable).
1216
1232
1233
+ beginGpioExpanderSwitches (); // Start the GPIO expander for switch control
1234
+
1217
1235
DMW_b (" beginDisplay" );
1218
1236
beginDisplay (i2cDisplay); // Start display to be able to display any errors
1219
1237
@@ -1222,24 +1240,29 @@ void setup()
1222
1240
1223
1241
beginVersion (); // Assemble platform name. Requires settings/LFS.
1224
1242
1243
+ DMW_b (" displaySplash" );
1244
+ displaySplash (); // Display the RTK product name and firmware version
1245
+
1246
+ DMW_b (" beginSD" );
1247
+ beginSD (); // Requires settings. Test if SD is present
1248
+
1249
+ DMW_b (" loadSettings" );
1250
+ loadSettings (); // Attempt to load settings after SD is started so we can read the settings file if available
1251
+
1252
+ gnssDetectReceiverType (); // If we don't know the receiver from the platform, auto-detect it. Uses settings.
1253
+
1225
1254
DMW_b (" beginGnssUart" );
1226
1255
beginGnssUart (); // Requires settings. Start the UART connected to the GNSS receiver on core 0. Start before
1227
1256
// gnssBegin in case it is needed (Torch).
1228
1257
1229
1258
DMW_b (" beginGnssUart2" );
1230
1259
beginGnssUart2 ();
1231
1260
1232
- DMW_b (" displaySplash" );
1233
- displaySplash (); // Display the RTK product name and firmware version
1234
-
1235
1261
DMW_b (" gnss->begin" );
1236
1262
gnss->begin (); // Requires settings. Connect to GNSS to get module type
1237
1263
1238
- DMW_b (" beginSD" );
1239
- beginSD (); // Requires settings. Test if SD is present
1240
1264
1241
- DMW_b (" loadSettings" );
1242
- loadSettings (); // Attempt to load settings after SD is started so we can read the settings file if available
1265
+ tiltDetect (); // If we don't know if there is a tilt compensation sensor, auto-detect it. Uses settings.
1243
1266
1244
1267
// DEBUG_NEARLY_EVERYTHING // Debug nearly all the things
1245
1268
// DEBUG_THE_ESSENTIALS // Debug the essentials - handy for measuring the boot time after a factory reset
@@ -1286,7 +1309,8 @@ void setup()
1286
1309
beginSystemState (); // Determine initial system state.
1287
1310
1288
1311
DMW_b (" rtcUpdate" );
1289
- rtcUpdate (); // The GNSS likely has a time/date. Update ESP32 RTC to match. Needed for PointPerfect key expiration.
1312
+ rtcUpdate (); // The GNSS likely has a time/date. Update ESP32 RTC to match. Needed for PointPerfect key
1313
+ // expiration.
1290
1314
1291
1315
systemFlush (); // Complete any previous prints
1292
1316
0 commit comments