From 25079f6e89411d0b0a62ef20faf4d29d6b9c173a Mon Sep 17 00:00:00 2001 From: Tom Fifield Date: Tue, 17 Sep 2024 09:03:19 +0800 Subject: [PATCH] Increase GPS FIFO Buffer Size for RP2040 As discovered and tested by @Mictronics, default Serial FIFO size on the Pico is 32bytes, which is not enough for GPS messages. This patch increases the Serial GPS FIFO buffer size to 256 for the RP2040 Architecture fixes https://github.com/meshtastic/firmware/issues/3989 --- src/gps/GPS.cpp | 17 +++++++++++++++-- src/gps/GPS.h | 2 +- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/gps/GPS.cpp b/src/gps/GPS.cpp index 8abb4edb1c..01fa65816e 100644 --- a/src/gps/GPS.cpp +++ b/src/gps/GPS.cpp @@ -26,6 +26,8 @@ #if defined(NRF52840_XXAA) || defined(NRF52833_XXAA) || defined(ARCH_ESP32) || defined(ARCH_PORTDUINO) HardwareSerial *GPS::_serial_gps = &Serial1; +#elif defined(ARCH_RP2040) +SerialUART *GPS::_serial_gps = &Serial1; #else HardwareSerial *GPS::_serial_gps = NULL; #endif @@ -1198,9 +1200,13 @@ int GPS::prepareDeepSleep(void *unused) GnssModel_t GPS::probe(int serialSpeed) { -#if defined(ARCH_NRF52) || defined(ARCH_PORTDUINO) || defined(ARCH_RP2040) || defined(ARCH_STM32WL) +#if defined(ARCH_NRF52) || defined(ARCH_PORTDUINO) || defined(ARCH_STM32WL) _serial_gps->end(); _serial_gps->begin(serialSpeed); +#elif defined(ARCH_RP2040) + _serial_gps->end(); + _serial_gps->setFIFOSize(256); + _serial_gps->begin(serialSpeed); #else if (_serial_gps->baudRate() != serialSpeed) { LOG_DEBUG("Setting Baud to %i\n", serialSpeed); @@ -1265,9 +1271,13 @@ GnssModel_t GPS::probe(int serialSpeed) _serial_gps->write(_message_prt, sizeof(_message_prt)); delay(500); serialSpeed = 9600; -#if defined(ARCH_NRF52) || defined(ARCH_PORTDUINO) || defined(ARCH_RP2040) || defined(ARCH_STM32WL) +#if defined(ARCH_NRF52) || defined(ARCH_PORTDUINO) || defined(ARCH_STM32WL) _serial_gps->end(); _serial_gps->begin(serialSpeed); +#elif defined(ARCH_RP2040) + _serial_gps->end(); + _serial_gps->setFIFOSize(256); + _serial_gps->begin(serialSpeed); #else _serial_gps->updateBaudRate(serialSpeed); #endif @@ -1428,6 +1438,9 @@ GPS *GPS::createGps() LOG_DEBUG("Using GPIO%d for GPS RX\n", new_gps->rx_gpio); LOG_DEBUG("Using GPIO%d for GPS TX\n", new_gps->tx_gpio); _serial_gps->begin(GPS_BAUDRATE, SERIAL_8N1, new_gps->rx_gpio, new_gps->tx_gpio); +#elif defined(ARCH_RP2040) + _serial_gps->setFIFOSize(256); + _serial_gps->begin(GPS_BAUDRATE); #else _serial_gps->begin(GPS_BAUDRATE); #endif diff --git a/src/gps/GPS.h b/src/gps/GPS.h index caff48f32e..3423edb686 100644 --- a/src/gps/GPS.h +++ b/src/gps/GPS.h @@ -102,7 +102,7 @@ class GPS : private concurrency::OSThread public: /** If !NULL we will use this serial port to construct our GPS */ -#if defined(RPI_PICO_WAVESHARE) +#if defined(ARCH_RP2040) static SerialUART *_serial_gps; #else static HardwareSerial *_serial_gps;