Skip to content

Commit 59f341c

Browse files
committed
Fix Serial1.end() hang on nRF52: pull up RX before UART shutdown
When GPS powers down, its TX line drops LOW, putting the nRF52 UARTE RX in a continuous break condition. Uart::end() waits for RXTO (receiver timeout) which only fires after the receiver is idle for one character period — never happening during a break. Result: infinite hang. Fix: pull up the MCU's RX pin (PIN_GPS_TX = "toward CPU") before calling Serial1.end(), ensuring the line is in idle state so RXTO fires promptly.
1 parent b9eb9a3 commit 59f341c

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

src/helpers/sensors/EnvironmentSensorManager.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,10 @@ void EnvironmentSensorManager::initBasicGPS() {
583583
MESH_DEBUG_PRINTLN("No GPS detected");
584584
}
585585
_location->stop();
586+
// Pull up MCU's RX pin before ending UART. When GPS powers down, its TX
587+
// line drops LOW (break condition) which prevents nRF52 UARTE's RXTO event
588+
// from firing, causing Serial1.end() to hang indefinitely.
589+
pinMode(PIN_GPS_TX, INPUT_PULLUP); // PIN_GPS_TX = toward CPU = MCU's RX
586590
Serial1.end(); // Disable UART peripheral to save power (significant on nRF52)
587591
gps_active = false; //Set GPS visibility off until setting is changed
588592
}
@@ -706,6 +710,8 @@ void EnvironmentSensorManager::stop_gps() {
706710
#endif
707711

708712
_location->stop();
713+
// Pull up MCU's RX pin before ending UART - see comment in initBasicGPS()
714+
pinMode(PIN_GPS_TX, INPUT_PULLUP);
709715
Serial1.end(); // Disable UART peripheral to save power (significant on nRF52)
710716

711717
#ifndef PIN_GPS_EN

0 commit comments

Comments
 (0)