diff --git a/src/shared/sensors/UBXGPS/UBXGPSSerial.cpp b/src/shared/sensors/UBXGPS/UBXGPSSerial.cpp
index c7051b97e07f6faaa5637081e19384a7ce0cc3b2..380d959a90113402681e3cc3ddfb60a85fe446b4 100644
--- a/src/shared/sensors/UBXGPS/UBXGPSSerial.cpp
+++ b/src/shared/sensors/UBXGPS/UBXGPSSerial.cpp
@@ -31,14 +31,11 @@ using namespace miosix;
 namespace Boardcore
 {
 
-UBXGPSSerial::UBXGPSSerial(int baudrate, uint8_t sampleRate,
-                           USARTType* usartNumber, int defaultBaudrate)
+UBXGPSSerial::UBXGPSSerial(USART& usart, uint32_t baudrate, uint8_t sampleRate,
+                           uint32_t defaultBaudrate)
+    : usart(usart), baudrate(baudrate), sampleRate(sampleRate),
+      defaultBaudrate(defaultBaudrate)
 {
-    this->usart           = nullptr;
-    this->baudrate        = baudrate;
-    this->defaultBaudrate = defaultBaudrate;
-    this->sampleRate      = sampleRate;
-    this->usartNumber     = usartNumber;
 }
 
 bool UBXGPSSerial::init()
@@ -170,7 +167,7 @@ bool UBXGPSSerial::setBaudrateAndUBX(bool safe)
 
 bool UBXGPSSerial::setSerialCommunication()
 {
-    usart = new USART(usartNumber, defaultBaudrate);
+    usart.setBaudrate(defaultBaudrate);
     // Change the baudrate only if it is different than the default
     if (baudrate != defaultBaudrate)
     {
@@ -183,7 +180,7 @@ bool UBXGPSSerial::setSerialCommunication()
     }
 
     miosix::Thread::sleep(100);
-    usart->setBaudrate(baudrate);
+    usart.setBaudrate(baudrate);
 
     return true;
 }
@@ -252,8 +249,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])
@@ -273,10 +271,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())
@@ -299,7 +297,7 @@ bool UBXGPSSerial::writeUBXFrame(const UBXFrame& frame)
     uint8_t packedFrame[frame.getLength()];
     frame.writePacked(packedFrame);
 
-    usart->write(packedFrame, frame.getLength());
+    usart.write(packedFrame, frame.getLength());
 
     return true;
 }
diff --git a/src/shared/sensors/UBXGPS/UBXGPSSerial.h b/src/shared/sensors/UBXGPS/UBXGPSSerial.h
index 9187466a692e354a3454855c7d8f43073835a845..dbcb156d5d864512815296d606e3153b86b24c89 100644
--- a/src/shared/sensors/UBXGPS/UBXGPSSerial.h
+++ b/src/shared/sensors/UBXGPS/UBXGPSSerial.h
@@ -56,15 +56,15 @@ 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(int baudrate = 921600, uint8_t sampleRate = 10,
-                 USARTType *usartNumber = USART2, int defaultBaudrate = 38400);
+    explicit UBXGPSSerial(USART& usart, uint32_t baudrate = 921600,
+                          uint8_t sampleRate       = 10,
+                          uint32_t defaultBaudrate = 38400);
 
     /**
      * @brief Sets up the serial port baudrate, disables the NMEA messages,
@@ -139,7 +139,7 @@ private:
      * @param frame The received frame.
      * @return True if a valid frame was read.
      */
-    bool readUBXFrame(UBXFrame &frame);
+    bool readUBXFrame(UBXFrame& frame);
 
     /**
      * @brief Writes a UBX frame.
@@ -147,7 +147,7 @@ private:
      * @param frame The frame to write.
      * @return True if the frame is valid.
      */
-    bool writeUBXFrame(const UBXFrame &frame);
+    bool writeUBXFrame(const UBXFrame& frame);
 
     /**
      * @brief Writes a UBX frame and waits for its acknowledgement.
@@ -155,15 +155,14 @@ private:
      * @param frame The frame to write.
      * @return True if the frame is valid and acknowledged.
      */
-    bool safeWriteUBXFrame(const UBXFrame &frame);
+    bool safeWriteUBXFrame(const UBXFrame& frame);
 
     void run() override;
 
-    int baudrate;
-    int defaultBaudrate;
+    USART& usart;
+    uint32_t baudrate;
     uint8_t sampleRate;  // [Hz]
-    USARTType *usartNumber;
-    USART *usart;  // The usart interface
+    uint32_t defaultBaudrate;
 
     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 e89dc6ce8c0d296a82f10b0ad772fae944944fa3..ed36658da612e61b14dfe87339c1de51fccf6cff 100644
--- a/src/tests/algorithms/NAS/test-nas-parafoil.cpp
+++ b/src/tests/algorithms/NAS/test-nas-parafoil.cpp
@@ -36,6 +36,10 @@ using namespace miosix;
 using namespace Boardcore;
 using namespace Eigen;
 
+// USART2: AF7
+typedef miosix::Gpio<GPIOA_BASE, 2> u2tx1;
+typedef miosix::Gpio<GPIOA_BASE, 3> u2rx1;
+
 NASConfig getEKConfig();
 void setInitialOrientation();
 void init();
@@ -48,11 +52,17 @@ Vector2f startPos = Vector2f(45.501141, 9.156281);
 NAS* nas;
 
 SPIBus spi1(SPI1);
-MPU9250* imu      = nullptr;
+MPU9250* imu = nullptr;
+USART usart(USART2, 38400);
 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());
@@ -112,7 +122,7 @@ void init()
     imu = new MPU9250(spi1, sensors::mpu9250::cs::getPin());
     imu->init();
 
-    gps = new UBXGPSSerial(38400, 10, USART2, 38400);
+    gps = new UBXGPSSerial(usart, 38400, 10, 38400);
     gps->init();
     gps->start();
 
diff --git a/src/tests/sensors/test-ubxgps-serial.cpp b/src/tests/sensors/test-ubxgps-serial.cpp
index 472f3dcde05177c0409262a5aa43c929bb363dc3..0039317c11277a21ef617fa3d98ffe6b2011eb49 100644
--- a/src/tests/sensors/test-ubxgps-serial.cpp
+++ b/src/tests/sensors/test-ubxgps-serial.cpp
@@ -32,12 +32,23 @@ using namespace miosix;
 
 #define RATE 4
 
+// USART2: AF7
+typedef miosix::Gpio<GPIOA_BASE, 2> u2tx1;
+typedef miosix::Gpio<GPIOA_BASE, 3> u2rx1;
+
 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, 38400);
+
     // Keep GPS baud rate at default for easier testing
-    UBXGPSSerial gps(38400, RATE, USART2, 9600);
+    UBXGPSSerial gps(usart, 38400, RATE, 9600);
     UBXGPSData dataGPS;
     printf("Gps allocated\n");
 
@@ -67,13 +78,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