Skip to content

Commit 05ed7b9

Browse files
committed
Add new functions to setup
1 parent c25c2fe commit 05ed7b9

File tree

1 file changed

+34
-10
lines changed

1 file changed

+34
-10
lines changed

Firmware/RTK_Everywhere/RTK_Everywhere.ino

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,10 @@ int pin_gnssStatusLED = PIN_UNDEFINED; // LED on Torch
202202

203203
int pin_muxA = PIN_UNDEFINED;
204204
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;
205209
int pin_powerSenseAndControl = PIN_UNDEFINED; // Power button and power down I/O on Facet
206210
int pin_modeButton = PIN_UNDEFINED; // Mode button on EVK
207211
int pin_powerButton = PIN_UNDEFINED; // Power and general purpose button on Torch
@@ -273,6 +277,16 @@ int gpioExpander_right = 2;
273277
int gpioExpander_left = 3;
274278
int gpioExpander_center = 4;
275279
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+
276290
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
277291

278292
// I2C for GNSS, battery gauge, display
@@ -374,7 +388,7 @@ bool wifiEspNowRunning; // False: stopped, True: starting, running, stop
374388
uint32_t wifiReconnectionTimer; // Delay before reconnection, timer running when non-zero
375389
bool wifiSoftApOnline; // WiFi soft AP started successfully
376390
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
378392
bool wifiStationOnline; // WiFi station started successfully
379393
bool wifiStationRunning; // False: stopped, True: starting, running, stopping
380394

@@ -758,6 +772,8 @@ uint8_t gpioExpander_lastReleased = 255;
758772
#define GPIO_EXPANDER_CARD_INSERTED 1
759773
#define GPIO_EXPANDER_CARD_REMOVED 0
760774

775+
SFE_PCA95XX *gpioExpanderSwitches = nullptr;
776+
761777
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
762778

763779
// Global variables
@@ -1206,14 +1222,16 @@ void setup()
12061222

12071223
DMW_b("beginMux");
12081224
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
12101226

12111227
DMW_b("peripheralsOn");
12121228
peripheralsOn(); // Enable power for the display, SD, etc
12131229

12141230
DMW_b("beginI2C");
12151231
beginI2C(); // Requires settings and peripheral power (if applicable).
12161232

1233+
beginGpioExpanderSwitches(); // Start the GPIO expander for switch control
1234+
12171235
DMW_b("beginDisplay");
12181236
beginDisplay(i2cDisplay); // Start display to be able to display any errors
12191237

@@ -1222,24 +1240,29 @@ void setup()
12221240

12231241
beginVersion(); // Assemble platform name. Requires settings/LFS.
12241242

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+
12251254
DMW_b("beginGnssUart");
12261255
beginGnssUart(); // Requires settings. Start the UART connected to the GNSS receiver on core 0. Start before
12271256
// gnssBegin in case it is needed (Torch).
12281257

12291258
DMW_b("beginGnssUart2");
12301259
beginGnssUart2();
12311260

1232-
DMW_b("displaySplash");
1233-
displaySplash(); // Display the RTK product name and firmware version
1234-
12351261
DMW_b("gnss->begin");
12361262
gnss->begin(); // Requires settings. Connect to GNSS to get module type
12371263

1238-
DMW_b("beginSD");
1239-
beginSD(); // Requires settings. Test if SD is present
12401264

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.
12431266

12441267
// DEBUG_NEARLY_EVERYTHING // Debug nearly all the things
12451268
// DEBUG_THE_ESSENTIALS // Debug the essentials - handy for measuring the boot time after a factory reset
@@ -1286,7 +1309,8 @@ void setup()
12861309
beginSystemState(); // Determine initial system state.
12871310

12881311
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.
12901314

12911315
systemFlush(); // Complete any previous prints
12921316

0 commit comments

Comments
 (0)