diff --git a/src/shared/sensors/UBXGPS/UBXGPSSerial.cpp b/src/shared/sensors/UBXGPS/UBXGPSSerial.cpp
index 0cfb238dfbf79073cc7653ddf5a26cf4f7075dc9..02ef13b4c5b75d61a48d4740dd8637ed33b0b1ca 100644
--- a/src/shared/sensors/UBXGPS/UBXGPSSerial.cpp
+++ b/src/shared/sensors/UBXGPS/UBXGPSSerial.cpp
@@ -31,15 +31,12 @@ using namespace miosix;
 namespace Boardcore
 {
 
-UBXGPSSerial::UBXGPSSerial(USARTInterface::Baudrate baudrate,
-                           uint8_t sampleRate, USARTType* usartNumber,
+UBXGPSSerial::UBXGPSSerial(USART& usart, USARTInterface::Baudrate baudrate,
+                           uint8_t sampleRate,
                            USARTInterface::Baudrate defaultBaudrate)
+    : usart(usart), baudrate(baudrate), defaultBaudrate(defaultBaudrate),
+      sampleRate(sampleRate)
 {
-    this->usart           = nullptr;
-    this->baudrate        = baudrate;
-    this->defaultBaudrate = defaultBaudrate;
-    this->sampleRate      = sampleRate;
-    this->usartNumber     = usartNumber;
 }
 
 bool UBXGPSSerial::init()
@@ -173,8 +170,8 @@ bool UBXGPSSerial::setBaudrateAndUBX(bool safe)
 
 bool UBXGPSSerial::setSerialCommunication()
 {
-    usart = new USART(usartNumber, defaultBaudrate);
-    usart->init();
+    usart.setBaudrate(defaultBaudrate);
+    usart.init();
     // Change the baudrate only if it is different than the default
     if (baudrate != defaultBaudrate)
     {
@@ -187,7 +184,7 @@ bool UBXGPSSerial::setSerialCommunication()
     }
 
     miosix::Thread::sleep(100);
-    usart->setBaudrate(baudrate);
+    usart.setBaudrate(baudrate);
 
     return true;
 }
@@ -256,8 +253,9 @@ bool UBXGPSSerial::readUBXFrame(UBXFrame& frame)
     size_t i = 0;
     while (i < 2)
     {
+        // TODO: Check if this can deadlock
         uint8_t c;
-        if (usart->read(&c, 1) <= 0)  // No more data available
+        if (usart.read(&c, 1) <= 0)  // No more data available
             return false;
 
         if (c == UBXFrame::PREAMBLE[i])
@@ -277,10 +275,10 @@ bool UBXGPSSerial::readUBXFrame(UBXFrame& frame)
         }
     }
 
-    if (usart->read(&frame.message, 2) <= 0 ||
-        usart->read(&frame.payloadLength, 2) <= 0 ||
-        usart->read(frame.payload, frame.getRealPayloadLength()) <= 0 ||
-        usart->read(frame.checksum, 2) <= 0)
+    if (usart.read(&frame.message, 2) <= 0 ||
+        usart.read(&frame.payloadLength, 2) <= 0 ||
+        usart.read(frame.payload, frame.getRealPayloadLength()) <= 0 ||
+        usart.read(frame.checksum, 2) <= 0)
         return false;
 
     if (!frame.isValid())
@@ -303,7 +301,7 @@ bool UBXGPSSerial::writeUBXFrame(const UBXFrame& frame)
     uint8_t packedFrame[frame.getLength()];
     frame.writePacked(packedFrame);
 
-    if (usart->write(packedFrame, frame.getLength()) < 0)
+    if (usart.write(packedFrame, frame.getLength()) < 0)
     {
         LOG_ERR(logger, "Failed to write ubx message");
         return false;
diff --git a/src/shared/sensors/UBXGPS/UBXGPSSerial.h b/src/shared/sensors/UBXGPS/UBXGPSSerial.h
index 55cba451ca6db1a4e078f24e74ca76cdedc7e56e..02fb535e894f52b6fca010733dd9b6001c54e4e4 100644
--- a/src/shared/sensors/UBXGPS/UBXGPSSerial.h
+++ b/src/shared/sensors/UBXGPS/UBXGPSSerial.h
@@ -56,16 +56,16 @@ public:
     /**
      * @brief Construct a new UBXGPSSerial object.
      *
+     * @param usart USART bus to be used for communication.
      * @param baudrate Baudrate to communicate with the device (max: 921600,
      * min: 4800 for NEO-M9N).
      * @param sampleRate GPS sample rate (max: 25 for NEO-M9N).
-     * @param serialPortNumber Number of the serial port connected to the GPS.
-     * @param serialPortName Name of the file for the gps device.
      * @param defaultBaudrate Startup baudrate (38400 for NEO-M9N).
      */
-    UBXGPSSerial(
+    explicit UBXGPSSerial(
+        USART &usart,
         USARTInterface::Baudrate baudrate = USARTInterface::Baudrate::B921600,
-        uint8_t sampleRate = 10, USARTType *usartNumber = USART2,
+        uint8_t sampleRate                = 10,
         USARTInterface::Baudrate defaultBaudrate =
             USARTInterface::Baudrate::B38400);
 
@@ -161,11 +161,10 @@ private:
 
     void run() override;
 
+    USART &usart;  // The usart interface
     Boardcore::USARTInterface::Baudrate baudrate;
     Boardcore::USARTInterface::Baudrate defaultBaudrate;
     uint8_t sampleRate;  // [Hz]
-    USARTType *usartNumber;
-    USART *usart;  // The usart interface
 
     mutable miosix::FastMutex mutex;
     UBXGPSData threadSample{};
diff --git a/src/tests/algorithms/NAS/test-nas-parafoil.cpp b/src/tests/algorithms/NAS/test-nas-parafoil.cpp
index 7af7e41c3861b95483cd136018fe2977216046e1..96af56025c99528bd932649aa81b0c7c7911689f 100644
--- a/src/tests/algorithms/NAS/test-nas-parafoil.cpp
+++ b/src/tests/algorithms/NAS/test-nas-parafoil.cpp
@@ -48,11 +48,17 @@ Vector2f startPos = Vector2f(45.501141, 9.156281);
 NAS* nas;
 
 SPIBus spi1(SPI1);
-MPU9250* imu      = nullptr;
+MPU9250* imu = nullptr;
+USART usart(USART2, USARTInterface::Baudrate::B38400);
 UBXGPSSerial* gps = nullptr;
 
 int main()
 {
+    u2rx1::getPin().alternateFunction(7);
+    u2rx1::getPin().mode(Mode::ALTERNATE);
+    u2tx1::getPin().alternateFunction(7);
+    u2tx1::getPin().mode(Mode::ALTERNATE);
+
     init();
 
     nas = new NAS(getEKConfig());
@@ -109,10 +115,12 @@ void setInitialOrientation()
 
 void init()
 {
+    usart.init();
+
     imu = new MPU9250(spi1, sensors::mpu9250::cs::getPin());
     imu->init();
 
-    gps = new UBXGPSSerial(USARTInterface::Baudrate::B38400, 10, USART2,
+    gps = new UBXGPSSerial(usart, USARTInterface::Baudrate::B38400, 10,
                            USARTInterface::Baudrate::B38400);
     gps->init();
     gps->start();
diff --git a/src/tests/sensors/test-ubxgps-serial.cpp b/src/tests/sensors/test-ubxgps-serial.cpp
index 063bf6df80625e5bd485b29109501cb292ed2814..ef44cf5c80cd233dd8ac5b0ab193b81ab5ef02e9 100644
--- a/src/tests/sensors/test-ubxgps-serial.cpp
+++ b/src/tests/sensors/test-ubxgps-serial.cpp
@@ -36,8 +36,15 @@ int main()
 {
     printf("Welcome to the ublox test\n");
 
+    u2rx1::getPin().alternateFunction(7);
+    u2rx1::getPin().mode(Mode::ALTERNATE);
+    u2tx1::getPin().alternateFunction(7);
+    u2tx1::getPin().mode(Mode::ALTERNATE);
+
+    USART usart(USART2, USARTInterface::Baudrate::B38400);
+
     // Keep GPS baud rate at default for easier testing
-    UBXGPSSerial gps(USARTInterface::Baudrate::B38400, RATE, USART2,
+    UBXGPSSerial gps(usart, USARTInterface::Baudrate::B38400, RATE,
                      USARTInterface::Baudrate::B9600);
     UBXGPSData dataGPS;
     printf("Gps allocated\n");
@@ -68,13 +75,11 @@ int main()
 
     while (true)
     {
-        printf("a\n");
         // Give time to the thread
         Thread::sleep(1000 / RATE);
 
         // Sample
         gps.sample();
-        printf("b\n");
         dataGPS = gps.getLastSample();
 
         // Print out the latest sample