diff --git a/Firmware/RTK_Everywhere/Begin.ino b/Firmware/RTK_Everywhere/Begin.ino index 07750e652..5cecf09ed 100644 --- a/Firmware/RTK_Everywhere/Begin.ino +++ b/Firmware/RTK_Everywhere/Begin.ino @@ -159,6 +159,7 @@ void beginBoard() pin_GNSS_TimePulse = 39; // PPS on UM980 + pin_muxA = 18; //Controls U12 switch between ESP UART1 to UM980 or LoRa pin_usbSelect = 21; pin_powerAdapterDetect = 36; // Goes low when USB cable is plugged in @@ -208,6 +209,9 @@ void beginBoard() pinMode(pin_usbSelect, OUTPUT); digitalWrite(pin_usbSelect, HIGH); // Keep CH340 connected to USB bus + pinMode(pin_muxA, OUTPUT); + digitalWrite(pin_muxA, LOW); // Keep ESP UART1 connected to UM980 + settings.dataPortBaud = 115200; // Override settings. Use UM980 at 115200bps. pinMode(pin_loraRadio_power, OUTPUT); @@ -783,7 +787,7 @@ void pinGnssUartTask(void *pvParameters) serialGNSS = new HardwareSerial(2); // Use UART2 on the ESP32 for communication with the GNSS module serialGNSS->setRxBufferSize( - settings.uartReceiveBufferSize); // TODO: work out if we can reduce or skip this when using SPI GNSS + settings.uartReceiveBufferSize); serialGNSS->setTimeout(settings.serialTimeoutGNSS); // Requires serial traffic on the UART pins for detection if (pin_GnssUart_RX == -1 || pin_GnssUart_TX == -1) diff --git a/Firmware/RTK_Everywhere/menuSystem.ino b/Firmware/RTK_Everywhere/menuSystem.ino index 49db749de..3b4e2c1b3 100644 --- a/Firmware/RTK_Everywhere/menuSystem.ino +++ b/Firmware/RTK_Everywhere/menuSystem.ino @@ -505,23 +505,48 @@ void menuDebugHardware() } else if (incoming == 13 && present.gnss_um980) { - systemPrintln("Press ! to exit"); + // Stop all UART tasks + tasksStopGnssUart(); + + systemPrintln("Entering UM980 direct connect at 115200bps for firmware update and configuration. Use " + "UPrecise to update " + "the firmware. Power cycle RTK Torch to " + "return to normal operation."); + + // Make sure ESP-UART1 is connected to UM980 + digitalWrite(pin_muxA, LOW); + + // UPrecise needs to query the device before entering bootload mode + // Wait for UPrecise to send bootloader trigger (character T followed by character @) before resetting UM980 + bool inBootMode = false; // Echo everything to/from UM980 while (1) { - while (serialGNSS->available()) + // Data coming from UM980 to external USB + if (serialGNSS->available()) systemWrite(serialGNSS->read()); + // Data coming from external USB to UM980 if (systemAvailable()) { byte incoming = systemRead(); - if (incoming == '!') - break; - else if (incoming == '1') - serialGNSS->println("mask"); - else if (incoming == '2') - serialGNSS->println("config"); + serialGNSS->write(incoming); + + // Detect bootload sequence + if (inBootMode == false && incoming == 'T') + { + byte nextIncoming = Serial.peek(); + if (nextIncoming == '@') + { + // Reset UM980 + um980Reset(); + delay(25); + um980Boot(); + + inBootMode = true; + } + } } } } diff --git a/Firmware/RTK_Everywhere/settings.h b/Firmware/RTK_Everywhere/settings.h index b501e4061..fbb1a6fcc 100644 --- a/Firmware/RTK_Everywhere/settings.h +++ b/Firmware/RTK_Everywhere/settings.h @@ -1686,7 +1686,7 @@ struct struct_present bool needsExternalPpl = false; - float antennaReferencePoint_mm = 0.0; + float antennaReferencePoint_mm = 0.0; //Used to setup tilt compensation } present; // Monitor which devices on the device are on or offline.