diff --git a/src/bsps/stm32f205rc_ciuti/config/miosix_settings.h b/src/bsps/stm32f205rc_ciuti/config/miosix_settings.h
index 22c33aa669e90ce3ce872c672a623f431203bc2d..49bd06ca471287e548728be3a4a33cd3e8d63a20 100644
--- a/src/bsps/stm32f205rc_ciuti/config/miosix_settings.h
+++ b/src/bsps/stm32f205rc_ciuti/config/miosix_settings.h
@@ -27,8 +27,8 @@
 // The PARSING_FROM_IDE is because Netbeans gets confused by this, it is never
 // defined when compiling the code.
 #ifndef PARSING_FROM_IDE
-//#error This error is a reminder that you have not edited miosix_settings.h
-// yet.
+// #error This error is a reminder that you have not edited miosix_settings.h
+//  yet.
 #endif  // PARSING_FROM_IDE
 
 /**
diff --git a/src/bsps/stm32f205rc_ciuti/interfaces-impl/bsp.cpp b/src/bsps/stm32f205rc_ciuti/interfaces-impl/bsp.cpp
index 39c47a1384b699e1917634cf2085ff22cd1f1123..07e96ca016c8ad7b526f04abcb8aec7d6815304e 100644
--- a/src/bsps/stm32f205rc_ciuti/interfaces-impl/bsp.cpp
+++ b/src/bsps/stm32f205rc_ciuti/interfaces-impl/bsp.cpp
@@ -67,42 +67,41 @@ void IRQbspInit()
     GPIOD->OSPEEDR = 0xaaaaaaaa;
 
     using namespace interfaces;
-
     spi1::cs::mode(Mode::OUTPUT);
     spi1::cs::high();
-    spi1::sck::mode(Mode::ALTERNATE);
     spi1::sck::alternateFunction(5);
-    spi1::miso::mode(Mode::ALTERNATE);
+    spi1::sck::mode(Mode::ALTERNATE);
     spi1::miso::alternateFunction(5);
-    spi1::mosi::mode(Mode::ALTERNATE);
+    spi1::miso::mode(Mode::ALTERNATE);
     spi1::mosi::alternateFunction(5);
+    spi1::mosi::mode(Mode::ALTERNATE);
 
-    spi2::sck::mode(Mode::ALTERNATE);
     spi2::sck::alternateFunction(5);
-    spi2::miso::mode(Mode::ALTERNATE);
+    spi2::sck::mode(Mode::ALTERNATE);
     spi2::miso::alternateFunction(5);
-    spi2::mosi::mode(Mode::ALTERNATE);
+    spi2::miso::mode(Mode::ALTERNATE);
     spi2::mosi::alternateFunction(5);
+    spi2::mosi::mode(Mode::ALTERNATE);
 
-    usart1::rx::mode(Mode::ALTERNATE);
     usart1::rx::alternateFunction(7);
-    usart1::tx::mode(Mode::ALTERNATE);
+    usart1::rx::mode(Mode::ALTERNATE);
     usart1::tx::alternateFunction(7);
+    usart1::tx::mode(Mode::ALTERNATE);
 
-    usart2::rx::mode(Mode::ALTERNATE);
     usart2::rx::alternateFunction(7);
-    usart2::tx::mode(Mode::ALTERNATE);
+    usart2::rx::mode(Mode::ALTERNATE);
     usart2::tx::alternateFunction(7);
+    usart2::tx::mode(Mode::ALTERNATE);
 
-    usart3::rx::mode(Mode::ALTERNATE);
     usart3::rx::alternateFunction(7);
-    usart3::tx::mode(Mode::ALTERNATE);
+    usart3::rx::mode(Mode::ALTERNATE);
     usart3::tx::alternateFunction(7);
+    usart3::tx::mode(Mode::ALTERNATE);
 
-    can1::rx::mode(Mode::ALTERNATE);
     can1::rx::alternateFunction(9);
-    can1::tx::mode(Mode::ALTERNATE);
+    can1::rx::mode(Mode::ALTERNATE);
     can1::tx::alternateFunction(9);
+    can1::tx::mode(Mode::ALTERNATE);
 
     using namespace devices;
 
@@ -124,8 +123,8 @@ void IRQbspInit()
     buttons::bypass::mode(Mode::INPUT);
     buttons::record::mode(Mode::INPUT);
 
-    buzzer::drive::mode(Mode::ALTERNATE);
     buzzer::drive::alternateFunction(3);
+    buzzer::drive::mode(Mode::ALTERNATE);
 
     leds::led1::mode(Mode::OUTPUT);
     leds::led1::low();
diff --git a/src/bsps/stm32f429zi_con_rig/config/miosix_settings.h b/src/bsps/stm32f429zi_con_rig/config/miosix_settings.h
index 5bb339e02447493b119574e5027f4970721d88bf..fb5d771285246a5b7cfd087bd8bb4b522d06967a 100644
--- a/src/bsps/stm32f429zi_con_rig/config/miosix_settings.h
+++ b/src/bsps/stm32f429zi_con_rig/config/miosix_settings.h
@@ -27,8 +27,8 @@
 // The PARSING_FROM_IDE is because Netbeans gets confused by this, it is never
 // defined when compiling the code.
 #ifndef PARSING_FROM_IDE
-//#error This error is a reminder that you have not edited miosix_settings.h
-// yet.
+// #error This error is a reminder that you have not edited miosix_settings.h
+//  yet.
 #endif  // PARSING_FROM_IDE
 
 /**
@@ -70,14 +70,14 @@ namespace miosix
 // Uncomment only *one* of those
 
 #define SCHED_TYPE_PRIORITY
-//#define SCHED_TYPE_CONTROL_BASED
-//#define SCHED_TYPE_EDF
+// #define SCHED_TYPE_CONTROL_BASED
+// #define SCHED_TYPE_EDF
 
 /// \def WITH_CPU_TIME_COUNTER
 /// Allows to enable/disable CPUTimeCounter to save code size and remove its
 /// overhead from the scheduling process. By default it is not defined
 /// (CPUTimeCounter is disabled).
-//#define WITH_CPU_TIME_COUNTER
+// #define WITH_CPU_TIME_COUNTER
 
 //
 // Filesystem options
@@ -110,7 +110,7 @@ const unsigned char MAX_OPEN_FILES = 8;
 /// This enables the dynamic loader to load elf programs, the extended system
 /// call service and, if the hardware supports it, the MPU to provide memory
 /// isolation of processes
-//#define WITH_PROCESSES
+// #define WITH_PROCESSES
 
 #if defined(WITH_PROCESSES) && defined(__NO_EXCEPTIONS)
 #error Processes require C++ exception support
@@ -145,7 +145,7 @@ const unsigned char MAX_OPEN_FILES = 8;
 /// \def WITH_DEEP_SLEEP
 /// Adds interfaces and required variables to support deep sleep state switch
 /// automatically when peripherals are not required
-//#define WITH_DEEP_SLEEP
+// #define WITH_DEEP_SLEEP
 
 /**
  * \def JTAG_DISABLE_SLEEP
diff --git a/src/bsps/stm32f429zi_con_rig/interfaces-impl/bsp.cpp b/src/bsps/stm32f429zi_con_rig/interfaces-impl/bsp.cpp
index bd78945768d115bef934039b429e4e86bb5e73cc..02a27c32d8c55a8eb1d19dea758617d63305503e 100644
--- a/src/bsps/stm32f429zi_con_rig/interfaces-impl/bsp.cpp
+++ b/src/bsps/stm32f429zi_con_rig/interfaces-impl/bsp.cpp
@@ -213,12 +213,12 @@ void IRQbspInit()
     RCC_SYNC();
 
     // Initialize everything
-    interfaces::spi1::sck::mode(Mode::ALTERNATE);
     interfaces::spi1::sck::alternateFunction(5);
-    interfaces::spi1::miso::mode(Mode::ALTERNATE);
+    interfaces::spi1::sck::mode(Mode::ALTERNATE);
     interfaces::spi1::miso::alternateFunction(5);
-    interfaces::spi1::mosi::mode(Mode::ALTERNATE);
+    interfaces::spi1::miso::mode(Mode::ALTERNATE);
     interfaces::spi1::mosi::alternateFunction(5);
+    interfaces::spi1::mosi::mode(Mode::ALTERNATE);
 
     btns::n2o_filling::mode(Mode::INPUT);
     btns::n2o_release::mode(Mode::INPUT);
diff --git a/src/bsps/stm32f429zi_death_stack_v1/config/miosix_settings.h b/src/bsps/stm32f429zi_death_stack_v1/config/miosix_settings.h
index 10946aeba9077c07d1b692eb1713a26d1431a55a..6f4e025893905677b49535bd077b1b6fe925b453 100644
--- a/src/bsps/stm32f429zi_death_stack_v1/config/miosix_settings.h
+++ b/src/bsps/stm32f429zi_death_stack_v1/config/miosix_settings.h
@@ -27,8 +27,8 @@
 // The PARSING_FROM_IDE is because Netbeans gets confused by this, it is never
 // defined when compiling the code.
 #ifndef PARSING_FROM_IDE
-//#error This error is a reminder that you have not edited miosix_settings.h
-// yet.
+// #error This error is a reminder that you have not edited miosix_settings.h
+//  yet.
 #endif  // PARSING_FROM_IDE
 
 /**
@@ -70,14 +70,14 @@ namespace miosix
 // Uncomment only *one* of those
 
 #define SCHED_TYPE_PRIORITY
-//#define SCHED_TYPE_CONTROL_BASED
-//#define SCHED_TYPE_EDF
+// #define SCHED_TYPE_CONTROL_BASED
+// #define SCHED_TYPE_EDF
 
 /// \def WITH_CPU_TIME_COUNTER
 /// Allows to enable/disable CPUTimeCounter to save code size and remove its
 /// overhead from the scheduling process. By default it is not defined
 /// (CPUTimeCounter is disabled).
-//#define WITH_CPU_TIME_COUNTER
+// #define WITH_CPU_TIME_COUNTER
 
 //
 // Filesystem options
@@ -110,7 +110,7 @@ const unsigned char MAX_OPEN_FILES = 8;
 /// This enables the dynamic loader to load elf programs, the extended system
 /// call service and, if the hardware supports it, the MPU to provide memory
 /// isolation of processes
-//#define WITH_PROCESSES
+// #define WITH_PROCESSES
 
 #if defined(WITH_PROCESSES) && defined(__NO_EXCEPTIONS)
 #error Processes require C++ exception support
@@ -145,7 +145,7 @@ const unsigned char MAX_OPEN_FILES = 8;
 /// \def WITH_DEEP_SLEEP
 /// Adds interfaces and required variables to support deep sleep state switch
 /// automatically when peripherals are not required
-//#define WITH_DEEP_SLEEP
+// #define WITH_DEEP_SLEEP
 
 /**
  * \def JTAG_DISABLE_SLEEP
diff --git a/src/bsps/stm32f429zi_death_stack_v1/interfaces-impl/bsp.cpp b/src/bsps/stm32f429zi_death_stack_v1/interfaces-impl/bsp.cpp
index 646ee99b221f0f426d5eff6d306c4d909cea9969..6e54d48a8c2a09abda7eefb7acd1644b7072c1f7 100644
--- a/src/bsps/stm32f429zi_death_stack_v1/interfaces-impl/bsp.cpp
+++ b/src/bsps/stm32f429zi_death_stack_v1/interfaces-impl/bsp.cpp
@@ -327,19 +327,19 @@ void IRQbspInit()
 #endif  //__ENABLE_XRAM
 
     using namespace interfaces;
-    spi1::sck::mode(Mode::ALTERNATE);
     spi1::sck::alternateFunction(5);
-    spi1::miso::mode(Mode::ALTERNATE);
+    spi1::sck::mode(Mode::ALTERNATE);
     spi1::miso::alternateFunction(5);
-    spi1::mosi::mode(Mode::ALTERNATE);
+    spi1::miso::mode(Mode::ALTERNATE);
     spi1::mosi::alternateFunction(5);
+    spi1::mosi::mode(Mode::ALTERNATE);
 
-    spi2::sck::mode(Mode::ALTERNATE);
     spi2::sck::alternateFunction(5);
-    spi2::miso::mode(Mode::ALTERNATE);
+    spi2::sck::mode(Mode::ALTERNATE);
     spi2::miso::alternateFunction(5);
-    spi2::mosi::mode(Mode::ALTERNATE);
+    spi2::miso::mode(Mode::ALTERNATE);
     spi2::mosi::alternateFunction(5);
+    spi2::mosi::mode(Mode::ALTERNATE);
 
     // Software I2C
     i2c::scl::high();
@@ -347,21 +347,21 @@ void IRQbspInit()
     i2c::sda::high();
     i2c::sda::mode(Mode::OPEN_DRAIN);
 
-    uart4::rx::mode(Mode::ALTERNATE);
     uart4::rx::alternateFunction(8);
-    uart4::tx::mode(Mode::ALTERNATE);
+    uart4::rx::mode(Mode::ALTERNATE);
     uart4::tx::alternateFunction(8);
+    uart4::tx::mode(Mode::ALTERNATE);
 
-    can::rx::mode(Mode::ALTERNATE);
     can::rx::alternateFunction(9);
-    can::tx::mode(Mode::ALTERNATE);
+    can::rx::mode(Mode::ALTERNATE);
     can::tx::alternateFunction(9);
+    can::tx::mode(Mode::ALTERNATE);
 
     using namespace sensors;
     adis16405::cs::mode(Mode::OUTPUT);
     adis16405::cs::high();
-    adis16405::ckIn::mode(Mode::ALTERNATE);
     adis16405::ckIn::alternateFunction(2);
+    adis16405::ckIn::mode(Mode::ALTERNATE);
     adis16405::dio1::mode(Mode::INPUT);
     adis16405::rst::mode(Mode::OUTPUT);
     adis16405::rst::high();
@@ -396,11 +396,11 @@ void IRQbspInit()
     motP2::mode(Mode::OUTPUT);
     motP2::low();
 
-    rogP1::mode(Mode::ALTERNATE);
     rogP1::alternateFunction(2);
+    rogP1::mode(Mode::ALTERNATE);
 
-    rogP2::mode(Mode::ALTERNATE);
     rogP2::alternateFunction(2);
+    rogP2::mode(Mode::ALTERNATE);
 
     nc_dtch::mode(Mode::INPUT);
     motor_act::mode(Mode::INPUT);
@@ -412,8 +412,8 @@ void IRQbspInit()
     motor_gnd::low();
 
     using namespace actuators;
-    tcPwm::mode(Mode::ALTERNATE);
     tcPwm::alternateFunction(3);
+    tcPwm::mode(Mode::ALTERNATE);
 
     thCut1::ena::mode(Mode::OUTPUT);
     thCut1::ena::low();
diff --git a/src/bsps/stm32f429zi_death_stack_v2/config/miosix_settings.h b/src/bsps/stm32f429zi_death_stack_v2/config/miosix_settings.h
index aaee8b547e5996e93ae14c79aa38ea091cab45e6..5e46fc07ae64763ab77e94d351d0452b92fae3aa 100644
--- a/src/bsps/stm32f429zi_death_stack_v2/config/miosix_settings.h
+++ b/src/bsps/stm32f429zi_death_stack_v2/config/miosix_settings.h
@@ -27,8 +27,8 @@
 // The PARSING_FROM_IDE is because Netbeans gets confused by this, it is never
 // defined when compiling the code.
 #ifndef PARSING_FROM_IDE
-//#error This error is a reminder that you have not edited miosix_settings.h
-// yet.
+// #error This error is a reminder that you have not edited miosix_settings.h
+//  yet.
 #endif  // PARSING_FROM_IDE
 
 /**
@@ -70,14 +70,14 @@ namespace miosix
 // Uncomment only *one* of those
 
 #define SCHED_TYPE_PRIORITY
-//#define SCHED_TYPE_CONTROL_BASED
-//#define SCHED_TYPE_EDF
+// #define SCHED_TYPE_CONTROL_BASED
+// #define SCHED_TYPE_EDF
 
 /// \def WITH_CPU_TIME_COUNTER
 /// Allows to enable/disable CPUTimeCounter to save code size and remove its
 /// overhead from the scheduling process. By default it is not defined
 /// (CPUTimeCounter is disabled).
-//#define WITH_CPU_TIME_COUNTER
+// #define WITH_CPU_TIME_COUNTER
 
 //
 // Filesystem options
@@ -110,7 +110,7 @@ const unsigned char MAX_OPEN_FILES = 8;
 /// This enables the dynamic loader to load elf programs, the extended system
 /// call service and, if the hardware supports it, the MPU to provide memory
 /// isolation of processes
-//#define WITH_PROCESSES
+// #define WITH_PROCESSES
 
 #if defined(WITH_PROCESSES) && defined(__NO_EXCEPTIONS)
 #error Processes require C++ exception support
@@ -145,7 +145,7 @@ const unsigned char MAX_OPEN_FILES = 8;
 /// \def WITH_DEEP_SLEEP
 /// Adds interfaces and required variables to support deep sleep state switch
 /// automatically when peripherals are not required
-//#define WITH_DEEP_SLEEP
+// #define WITH_DEEP_SLEEP
 
 /**
  * \def JTAG_DISABLE_SLEEP
diff --git a/src/bsps/stm32f429zi_death_stack_v2/interfaces-impl/bsp.cpp b/src/bsps/stm32f429zi_death_stack_v2/interfaces-impl/bsp.cpp
index b7574a91aa84f527af37387db0b72f3df46665b1..8dc6f3db0635ae9438b635c522c1220b6e0b3740 100644
--- a/src/bsps/stm32f429zi_death_stack_v2/interfaces-impl/bsp.cpp
+++ b/src/bsps/stm32f429zi_death_stack_v2/interfaces-impl/bsp.cpp
@@ -337,44 +337,44 @@ void IRQbspInit()
 
     using namespace interfaces;
 
-    spi1::sck::mode(Mode::ALTERNATE);
     spi1::sck::alternateFunction(5);
-    spi1::miso::mode(Mode::ALTERNATE);
+    spi1::sck::mode(Mode::ALTERNATE);
     spi1::miso::alternateFunction(5);
-    spi1::mosi::mode(Mode::ALTERNATE);
+    spi1::miso::mode(Mode::ALTERNATE);
     spi1::mosi::alternateFunction(5);
+    spi1::mosi::mode(Mode::ALTERNATE);
 
-    spi2::sck::mode(Mode::ALTERNATE);
     spi2::sck::alternateFunction(5);
-    spi2::miso::mode(Mode::ALTERNATE);
+    spi2::sck::mode(Mode::ALTERNATE);
     spi2::miso::alternateFunction(5);
-    spi2::mosi::mode(Mode::ALTERNATE);
+    spi2::miso::mode(Mode::ALTERNATE);
     spi2::mosi::alternateFunction(5);
+    spi2::mosi::mode(Mode::ALTERNATE);
 
-    uart2::rx::mode(Mode::ALTERNATE);
     uart2::rx::alternateFunction(7);
-    uart2::tx::mode(Mode::ALTERNATE);
+    uart2::rx::mode(Mode::ALTERNATE);
     uart2::tx::alternateFunction(7);
+    uart2::tx::mode(Mode::ALTERNATE);
 
-    uart3::rx::mode(Mode::ALTERNATE);
     uart3::rx::alternateFunction(7);
-    uart3::tx::mode(Mode::ALTERNATE);
+    uart3::rx::mode(Mode::ALTERNATE);
     uart3::tx::alternateFunction(7);
+    uart3::tx::mode(Mode::ALTERNATE);
 
-    uart4::rx::mode(Mode::ALTERNATE);
     uart4::rx::alternateFunction(8);
-    uart4::tx::mode(Mode::ALTERNATE);
+    uart4::rx::mode(Mode::ALTERNATE);
     uart4::tx::alternateFunction(8);
+    uart4::tx::mode(Mode::ALTERNATE);
 
-    can::rx::mode(Mode::ALTERNATE);
     can::rx::alternateFunction(9);
-    can::tx::mode(Mode::ALTERNATE);
+    can::rx::mode(Mode::ALTERNATE);
     can::tx::alternateFunction(9);
+    can::tx::mode(Mode::ALTERNATE);
 
-    timers::tim4ch1::mode(Mode::ALTERNATE);
     timers::tim4ch1::alternateFunction(2);
-    timers::tim8ch2::mode(Mode::ALTERNATE);
+    timers::tim4ch1::mode(Mode::ALTERNATE);
     timers::tim8ch2::alternateFunction(3);
+    timers::tim8ch2::mode(Mode::ALTERNATE);
 
     camMosfet::mode(Mode::OUTPUT);
     camMosfet::low();
diff --git a/src/bsps/stm32f429zi_death_stack_v3/config/miosix_settings.h b/src/bsps/stm32f429zi_death_stack_v3/config/miosix_settings.h
index ee7e8487d9952b6c54a6a1b1be15b262e2731c86..0682125082b7d8e8e95335e98a0001c6197a460b 100644
--- a/src/bsps/stm32f429zi_death_stack_v3/config/miosix_settings.h
+++ b/src/bsps/stm32f429zi_death_stack_v3/config/miosix_settings.h
@@ -27,8 +27,8 @@
 // The PARSING_FROM_IDE is because Netbeans gets confused by this, it is never
 // defined when compiling the code.
 #ifndef PARSING_FROM_IDE
-//#error This error is a reminder that you have not edited miosix_settings.h
-// yet.
+// #error This error is a reminder that you have not edited miosix_settings.h
+//  yet.
 #endif  // PARSING_FROM_IDE
 
 /**
@@ -70,14 +70,14 @@ namespace miosix
 // Uncomment only *one* of those
 
 #define SCHED_TYPE_PRIORITY
-//#define SCHED_TYPE_CONTROL_BASED
-//#define SCHED_TYPE_EDF
+// #define SCHED_TYPE_CONTROL_BASED
+// #define SCHED_TYPE_EDF
 
 /// \def WITH_CPU_TIME_COUNTER
 /// Allows to enable/disable CPUTimeCounter to save code size and remove its
 /// overhead from the scheduling process. By default it is not defined
 /// (CPUTimeCounter is disabled).
-//#define WITH_CPU_TIME_COUNTER
+// #define WITH_CPU_TIME_COUNTER
 
 //
 // Filesystem options
@@ -110,7 +110,7 @@ const unsigned char MAX_OPEN_FILES = 8;
 /// This enables the dynamic loader to load elf programs, the extended system
 /// call service and, if the hardware supports it, the MPU to provide memory
 /// isolation of processes
-//#define WITH_PROCESSES
+// #define WITH_PROCESSES
 
 #if defined(WITH_PROCESSES) && defined(__NO_EXCEPTIONS)
 #error Processes require C++ exception support
@@ -145,7 +145,7 @@ const unsigned char MAX_OPEN_FILES = 8;
 /// \def WITH_DEEP_SLEEP
 /// Adds interfaces and required variables to support deep sleep state switch
 /// automatically when peripherals are not required
-//#define WITH_DEEP_SLEEP
+// #define WITH_DEEP_SLEEP
 
 /**
  * \def JTAG_DISABLE_SLEEP
diff --git a/src/bsps/stm32f429zi_death_stack_v3/interfaces-impl/bsp.cpp b/src/bsps/stm32f429zi_death_stack_v3/interfaces-impl/bsp.cpp
index 94f8eee9ba433c2ae5435d36e62f6875752b25f1..4b7e269feaed9eca630cb7a71f9f53c09cd36080 100644
--- a/src/bsps/stm32f429zi_death_stack_v3/interfaces-impl/bsp.cpp
+++ b/src/bsps/stm32f429zi_death_stack_v3/interfaces-impl/bsp.cpp
@@ -338,65 +338,65 @@ void IRQbspInit()
 
     RCC_SYNC();
 
-    interfaces::spi1::sck::mode(Mode::ALTERNATE);
     interfaces::spi1::sck::alternateFunction(5);
-    interfaces::spi1::miso::mode(Mode::ALTERNATE);
+    interfaces::spi1::sck::mode(Mode::ALTERNATE);
     interfaces::spi1::miso::alternateFunction(5);
-    interfaces::spi1::mosi::mode(Mode::ALTERNATE);
+    interfaces::spi1::miso::mode(Mode::ALTERNATE);
     interfaces::spi1::mosi::alternateFunction(5);
+    interfaces::spi1::mosi::mode(Mode::ALTERNATE);
 
-    interfaces::spi2::sck::mode(Mode::ALTERNATE);
     interfaces::spi2::sck::alternateFunction(5);
-    interfaces::spi2::miso::mode(Mode::ALTERNATE);
+    interfaces::spi2::sck::mode(Mode::ALTERNATE);
     interfaces::spi2::miso::alternateFunction(5);
-    interfaces::spi2::mosi::mode(Mode::ALTERNATE);
+    interfaces::spi2::miso::mode(Mode::ALTERNATE);
     interfaces::spi2::mosi::alternateFunction(5);
+    interfaces::spi2::mosi::mode(Mode::ALTERNATE);
 
-    interfaces::spi4::sck::mode(Mode::ALTERNATE);
     interfaces::spi4::sck::alternateFunction(5);
-    interfaces::spi4::miso::mode(Mode::ALTERNATE);
+    interfaces::spi4::sck::mode(Mode::ALTERNATE);
     interfaces::spi4::miso::alternateFunction(5);
-    interfaces::spi4::mosi::mode(Mode::ALTERNATE);
+    interfaces::spi4::miso::mode(Mode::ALTERNATE);
     interfaces::spi4::mosi::alternateFunction(5);
+    interfaces::spi4::mosi::mode(Mode::ALTERNATE);
 
-    interfaces::spi5::sck::mode(Mode::ALTERNATE);
     interfaces::spi5::sck::alternateFunction(5);
-    interfaces::spi5::miso::mode(Mode::ALTERNATE);
+    interfaces::spi5::sck::mode(Mode::ALTERNATE);
     interfaces::spi5::miso::alternateFunction(5);
-    interfaces::spi5::mosi::mode(Mode::ALTERNATE);
+    interfaces::spi5::miso::mode(Mode::ALTERNATE);
     interfaces::spi5::mosi::alternateFunction(5);
+    interfaces::spi5::mosi::mode(Mode::ALTERNATE);
 
-    interfaces::spi6::sck::mode(Mode::ALTERNATE);
     interfaces::spi6::sck::alternateFunction(5);
-    interfaces::spi6::miso::mode(Mode::ALTERNATE);
+    interfaces::spi6::sck::mode(Mode::ALTERNATE);
     interfaces::spi6::miso::alternateFunction(5);
-    interfaces::spi6::mosi::mode(Mode::ALTERNATE);
+    interfaces::spi6::miso::mode(Mode::ALTERNATE);
     interfaces::spi6::mosi::alternateFunction(5);
+    interfaces::spi6::mosi::mode(Mode::ALTERNATE);
 
-    interfaces::usart1::rx::mode(Mode::ALTERNATE);
     interfaces::usart1::rx::alternateFunction(7);
-    interfaces::usart1::tx::mode(Mode::ALTERNATE);
+    interfaces::usart1::rx::mode(Mode::ALTERNATE);
     interfaces::usart1::tx::alternateFunction(7);
+    interfaces::usart1::tx::mode(Mode::ALTERNATE);
 
-    interfaces::usart2::rx::mode(Mode::ALTERNATE);
     interfaces::usart2::rx::alternateFunction(7);
-    interfaces::usart2::tx::mode(Mode::ALTERNATE);
+    interfaces::usart2::rx::mode(Mode::ALTERNATE);
     interfaces::usart2::tx::alternateFunction(7);
+    interfaces::usart2::tx::mode(Mode::ALTERNATE);
 
-    interfaces::usart3::rx::mode(Mode::ALTERNATE);
     interfaces::usart3::rx::alternateFunction(7);
-    interfaces::usart3::tx::mode(Mode::ALTERNATE);
+    interfaces::usart3::rx::mode(Mode::ALTERNATE);
     interfaces::usart3::tx::alternateFunction(7);
+    interfaces::usart3::tx::mode(Mode::ALTERNATE);
 
-    interfaces::uart4::rx::mode(Mode::ALTERNATE);
     interfaces::uart4::rx::alternateFunction(8);
-    interfaces::uart4::tx::mode(Mode::ALTERNATE);
+    interfaces::uart4::rx::mode(Mode::ALTERNATE);
     interfaces::uart4::tx::alternateFunction(8);
+    interfaces::uart4::tx::mode(Mode::ALTERNATE);
 
-    interfaces::can1::rx::mode(Mode::ALTERNATE);
     interfaces::can1::rx::alternateFunction(9);
-    interfaces::can1::tx::mode(Mode::ALTERNATE);
+    interfaces::can1::rx::mode(Mode::ALTERNATE);
     interfaces::can1::tx::alternateFunction(9);
+    interfaces::can1::tx::mode(Mode::ALTERNATE);
 
     sensors::ads131m04::cs1::mode(Mode::OUTPUT);
     sensors::ads131m04::cs1::high();
@@ -430,8 +430,8 @@ void IRQbspInit()
 
     sensors::launchpad_detach::mode(Mode::INPUT);
 
-    expulsion::servo::mode(Mode::ALTERNATE);
     expulsion::servo::alternateFunction(2);
+    expulsion::servo::mode(Mode::ALTERNATE);
     expulsion::sense::mode(Mode::INPUT_PULL_UP);
     expulsion::nosecone_detach::mode(Mode::INPUT);
 
@@ -441,19 +441,19 @@ void IRQbspInit()
     cutter::enable_backup::low();
     cutter::sense::mode(Mode::INPUT_ANALOG);
 
-    airbrakes::servo::mode(Mode::ALTERNATE);
     airbrakes::servo::alternateFunction(3);
+    airbrakes::servo::mode(Mode::ALTERNATE);
     airbrakes::sensor::mode(Mode::INPUT_ANALOG);
 
     leds::red::mode(Mode::OUTPUT);
     leds::green::mode(Mode::OUTPUT);
     leds::blue::mode(Mode::OUTPUT);
 
-    buzzer::drive::mode(Mode::ALTERNATE);
     buzzer::drive::alternateFunction(3);
+    buzzer::drive::mode(Mode::ALTERNATE);
 
-    aux::servo::mode(Mode::ALTERNATE);
     aux::servo::alternateFunction(3);
+    aux::servo::mode(Mode::ALTERNATE);
     aux::sense_1::mode(Mode::INPUT);
     aux::sense_2::mode(Mode::INPUT);
 
diff --git a/src/bsps/stm32f429zi_nokia/config/miosix_settings.h b/src/bsps/stm32f429zi_nokia/config/miosix_settings.h
index 760430d5c876ece665abec6356665703fbbe03f9..0cecfe04e388e953faf3e2647078ffccc78198fc 100644
--- a/src/bsps/stm32f429zi_nokia/config/miosix_settings.h
+++ b/src/bsps/stm32f429zi_nokia/config/miosix_settings.h
@@ -27,8 +27,8 @@
 // The PARSING_FROM_IDE is because Netbeans gets confused by this, it is never
 // defined when compiling the code.
 #ifndef PARSING_FROM_IDE
-//#error This error is a reminder that you have not edited miosix_settings.h
-// yet.
+// #error This error is a reminder that you have not edited miosix_settings.h
+//  yet.
 #endif  // PARSING_FROM_IDE
 
 /**
@@ -70,14 +70,14 @@ namespace miosix
 // Uncomment only *one* of those
 
 #define SCHED_TYPE_PRIORITY
-//#define SCHED_TYPE_CONTROL_BASED
-//#define SCHED_TYPE_EDF
+// #define SCHED_TYPE_CONTROL_BASED
+// #define SCHED_TYPE_EDF
 
 /// \def WITH_CPU_TIME_COUNTER
 /// Allows to enable/disable CPUTimeCounter to save code size and remove its
 /// overhead from the scheduling process. By default it is not defined
 /// (CPUTimeCounter is disabled).
-//#define WITH_CPU_TIME_COUNTER
+// #define WITH_CPU_TIME_COUNTER
 
 //
 // Filesystem options
@@ -110,7 +110,7 @@ const unsigned char MAX_OPEN_FILES = 8;
 /// This enables the dynamic loader to load elf programs, the extended system
 /// call service and, if the hardware supports it, the MPU to provide memory
 /// isolation of processes
-//#define WITH_PROCESSES
+// #define WITH_PROCESSES
 
 #if defined(WITH_PROCESSES) && defined(__NO_EXCEPTIONS)
 #error Processes require C++ exception support
@@ -145,7 +145,7 @@ const unsigned char MAX_OPEN_FILES = 8;
 /// \def WITH_DEEP_SLEEP
 /// Adds interfaces and required variables to support deep sleep state switch
 /// automatically when peripherals are not required
-//#define WITH_DEEP_SLEEP
+// #define WITH_DEEP_SLEEP
 
 /**
  * \def JTAG_DISABLE_SLEEP
diff --git a/src/bsps/stm32f429zi_nokia/interfaces-impl/bsp.cpp b/src/bsps/stm32f429zi_nokia/interfaces-impl/bsp.cpp
index f79a64ec5a85f845752cb8b2dff3573607c05929..ab9c05cc6c7266f6dd622f8db7bf31a0bc156b6d 100644
--- a/src/bsps/stm32f429zi_nokia/interfaces-impl/bsp.cpp
+++ b/src/bsps/stm32f429zi_nokia/interfaces-impl/bsp.cpp
@@ -201,19 +201,19 @@ void IRQbspInit()
 
     RCC_SYNC();
 
-    interfaces::spi1::sck::mode(Mode::ALTERNATE);
     interfaces::spi1::sck::alternateFunction(5);
-    interfaces::spi1::miso::mode(Mode::ALTERNATE);
+    interfaces::spi1::sck::mode(Mode::ALTERNATE);
     interfaces::spi1::miso::alternateFunction(5);
-    interfaces::spi1::mosi::mode(Mode::ALTERNATE);
+    interfaces::spi1::miso::mode(Mode::ALTERNATE);
     interfaces::spi1::mosi::alternateFunction(5);
+    interfaces::spi1::mosi::mode(Mode::ALTERNATE);
 
-    interfaces::spi4::sck::mode(Mode::ALTERNATE);
     interfaces::spi4::sck::alternateFunction(5);
-    interfaces::spi4::miso::mode(Mode::ALTERNATE);
+    interfaces::spi4::sck::mode(Mode::ALTERNATE);
     interfaces::spi4::miso::alternateFunction(5);
-    interfaces::spi4::mosi::mode(Mode::ALTERNATE);
+    interfaces::spi4::miso::mode(Mode::ALTERNATE);
     interfaces::spi4::mosi::alternateFunction(5);
+    interfaces::spi4::mosi::mode(Mode::ALTERNATE);
 
     peripherals::ra01::pc13::cs::mode(Mode::OUTPUT);
     peripherals::ra01::pc13::dio0::mode(Mode::INPUT);
diff --git a/src/bsps/stm32f429zi_parafoil/config/miosix_settings.h b/src/bsps/stm32f429zi_parafoil/config/miosix_settings.h
index aaee8b547e5996e93ae14c79aa38ea091cab45e6..5e46fc07ae64763ab77e94d351d0452b92fae3aa 100644
--- a/src/bsps/stm32f429zi_parafoil/config/miosix_settings.h
+++ b/src/bsps/stm32f429zi_parafoil/config/miosix_settings.h
@@ -27,8 +27,8 @@
 // The PARSING_FROM_IDE is because Netbeans gets confused by this, it is never
 // defined when compiling the code.
 #ifndef PARSING_FROM_IDE
-//#error This error is a reminder that you have not edited miosix_settings.h
-// yet.
+// #error This error is a reminder that you have not edited miosix_settings.h
+//  yet.
 #endif  // PARSING_FROM_IDE
 
 /**
@@ -70,14 +70,14 @@ namespace miosix
 // Uncomment only *one* of those
 
 #define SCHED_TYPE_PRIORITY
-//#define SCHED_TYPE_CONTROL_BASED
-//#define SCHED_TYPE_EDF
+// #define SCHED_TYPE_CONTROL_BASED
+// #define SCHED_TYPE_EDF
 
 /// \def WITH_CPU_TIME_COUNTER
 /// Allows to enable/disable CPUTimeCounter to save code size and remove its
 /// overhead from the scheduling process. By default it is not defined
 /// (CPUTimeCounter is disabled).
-//#define WITH_CPU_TIME_COUNTER
+// #define WITH_CPU_TIME_COUNTER
 
 //
 // Filesystem options
@@ -110,7 +110,7 @@ const unsigned char MAX_OPEN_FILES = 8;
 /// This enables the dynamic loader to load elf programs, the extended system
 /// call service and, if the hardware supports it, the MPU to provide memory
 /// isolation of processes
-//#define WITH_PROCESSES
+// #define WITH_PROCESSES
 
 #if defined(WITH_PROCESSES) && defined(__NO_EXCEPTIONS)
 #error Processes require C++ exception support
@@ -145,7 +145,7 @@ const unsigned char MAX_OPEN_FILES = 8;
 /// \def WITH_DEEP_SLEEP
 /// Adds interfaces and required variables to support deep sleep state switch
 /// automatically when peripherals are not required
-//#define WITH_DEEP_SLEEP
+// #define WITH_DEEP_SLEEP
 
 /**
  * \def JTAG_DISABLE_SLEEP
diff --git a/src/bsps/stm32f429zi_parafoil/interfaces-impl/bsp.cpp b/src/bsps/stm32f429zi_parafoil/interfaces-impl/bsp.cpp
index 12077a4c421fece90f52f9465fbeaf4f35e6d841..f4304b85ac1b8d38c42e7fb941dd75b0bcdc9527 100644
--- a/src/bsps/stm32f429zi_parafoil/interfaces-impl/bsp.cpp
+++ b/src/bsps/stm32f429zi_parafoil/interfaces-impl/bsp.cpp
@@ -211,34 +211,34 @@ void IRQbspInit()
 
     using namespace interfaces;
 
-    spi1::sck::mode(Mode::ALTERNATE);
     spi1::sck::alternateFunction(5);
-    spi1::miso::mode(Mode::ALTERNATE);
+    spi1::sck::mode(Mode::ALTERNATE);
     spi1::miso::alternateFunction(5);
-    spi1::mosi::mode(Mode::ALTERNATE);
+    spi1::miso::mode(Mode::ALTERNATE);
     spi1::mosi::alternateFunction(5);
+    spi1::mosi::mode(Mode::ALTERNATE);
 
-    spi4::sck::mode(Mode::ALTERNATE);
     spi4::sck::alternateFunction(5);
-    spi4::miso::mode(Mode::ALTERNATE);
+    spi4::sck::mode(Mode::ALTERNATE);
     spi4::miso::alternateFunction(5);
-    spi4::mosi::mode(Mode::ALTERNATE);
+    spi4::miso::mode(Mode::ALTERNATE);
     spi4::mosi::alternateFunction(5);
+    spi4::mosi::mode(Mode::ALTERNATE);
 
-    uart1::rx::mode(Mode::ALTERNATE);
     uart1::rx::alternateFunction(7);
-    uart1::tx::mode(Mode::ALTERNATE);
+    uart1::rx::mode(Mode::ALTERNATE);
     uart1::tx::alternateFunction(7);
+    uart1::tx::mode(Mode::ALTERNATE);
 
-    uart2::rx::mode(Mode::ALTERNATE);
     uart2::rx::alternateFunction(7);
-    uart2::tx::mode(Mode::ALTERNATE);
+    uart2::rx::mode(Mode::ALTERNATE);
     uart2::tx::alternateFunction(7);
+    uart2::tx::mode(Mode::ALTERNATE);
 
-    timers::tim4ch2::mode(Mode::ALTERNATE);
     timers::tim4ch2::alternateFunction(2);
-    timers::tim10ch1::mode(Mode::ALTERNATE);
+    timers::tim4ch2::mode(Mode::ALTERNATE);
     timers::tim10ch1::alternateFunction(3);
+    timers::tim10ch1::mode(Mode::ALTERNATE);
 
     using namespace sensors;
 
diff --git a/src/bsps/stm32f429zi_pyxis_auxiliary/config/miosix_settings.h b/src/bsps/stm32f429zi_pyxis_auxiliary/config/miosix_settings.h
index aaee8b547e5996e93ae14c79aa38ea091cab45e6..5e46fc07ae64763ab77e94d351d0452b92fae3aa 100644
--- a/src/bsps/stm32f429zi_pyxis_auxiliary/config/miosix_settings.h
+++ b/src/bsps/stm32f429zi_pyxis_auxiliary/config/miosix_settings.h
@@ -27,8 +27,8 @@
 // The PARSING_FROM_IDE is because Netbeans gets confused by this, it is never
 // defined when compiling the code.
 #ifndef PARSING_FROM_IDE
-//#error This error is a reminder that you have not edited miosix_settings.h
-// yet.
+// #error This error is a reminder that you have not edited miosix_settings.h
+//  yet.
 #endif  // PARSING_FROM_IDE
 
 /**
@@ -70,14 +70,14 @@ namespace miosix
 // Uncomment only *one* of those
 
 #define SCHED_TYPE_PRIORITY
-//#define SCHED_TYPE_CONTROL_BASED
-//#define SCHED_TYPE_EDF
+// #define SCHED_TYPE_CONTROL_BASED
+// #define SCHED_TYPE_EDF
 
 /// \def WITH_CPU_TIME_COUNTER
 /// Allows to enable/disable CPUTimeCounter to save code size and remove its
 /// overhead from the scheduling process. By default it is not defined
 /// (CPUTimeCounter is disabled).
-//#define WITH_CPU_TIME_COUNTER
+// #define WITH_CPU_TIME_COUNTER
 
 //
 // Filesystem options
@@ -110,7 +110,7 @@ const unsigned char MAX_OPEN_FILES = 8;
 /// This enables the dynamic loader to load elf programs, the extended system
 /// call service and, if the hardware supports it, the MPU to provide memory
 /// isolation of processes
-//#define WITH_PROCESSES
+// #define WITH_PROCESSES
 
 #if defined(WITH_PROCESSES) && defined(__NO_EXCEPTIONS)
 #error Processes require C++ exception support
@@ -145,7 +145,7 @@ const unsigned char MAX_OPEN_FILES = 8;
 /// \def WITH_DEEP_SLEEP
 /// Adds interfaces and required variables to support deep sleep state switch
 /// automatically when peripherals are not required
-//#define WITH_DEEP_SLEEP
+// #define WITH_DEEP_SLEEP
 
 /**
  * \def JTAG_DISABLE_SLEEP
diff --git a/src/bsps/stm32f429zi_pyxis_auxiliary/interfaces-impl/bsp.cpp b/src/bsps/stm32f429zi_pyxis_auxiliary/interfaces-impl/bsp.cpp
index 025840ce89f9f7191dd87089599acb4556eeb325..8a9efa1a4c34a780b73569d5dc0c544077d7568b 100644
--- a/src/bsps/stm32f429zi_pyxis_auxiliary/interfaces-impl/bsp.cpp
+++ b/src/bsps/stm32f429zi_pyxis_auxiliary/interfaces-impl/bsp.cpp
@@ -62,29 +62,29 @@ void IRQbspInit()
 
     using namespace interfaces;
 
-    debug::rx::mode(Mode::ALTERNATE);
     debug::rx::alternateFunction(8);
-    debug::tx::mode(Mode::ALTERNATE);
+    debug::rx::mode(Mode::ALTERNATE);
     debug::tx::alternateFunction(8);
+    debug::tx::mode(Mode::ALTERNATE);
 
-    cam1::rx::mode(Mode::ALTERNATE);
     cam1::rx::alternateFunction(7);
-    cam1::tx::mode(Mode::ALTERNATE);
+    cam1::rx::mode(Mode::ALTERNATE);
     cam1::tx::alternateFunction(7);
+    cam1::tx::mode(Mode::ALTERNATE);
 
-    cam2::tx::mode(Mode::ALTERNATE);
     cam2::tx::alternateFunction(8);
+    cam2::tx::mode(Mode::ALTERNATE);
 
-    cam3::tx::mode(Mode::ALTERNATE);
     cam3::tx::alternateFunction(8);
+    cam3::tx::mode(Mode::ALTERNATE);
 
     camMosfet::mode(Mode::OUTPUT);
     camMosfet::low();
 
-    can1::rx::mode(Mode::ALTERNATE);
     can1::rx::alternateFunction(9);
-    can1::tx::mode(Mode::ALTERNATE);
+    can1::rx::mode(Mode::ALTERNATE);
     can1::tx::alternateFunction(9);
+    can1::tx::mode(Mode::ALTERNATE);
 
     using namespace leds;
 
diff --git a/src/bsps/stm32f429zi_rig/config/miosix_settings.h b/src/bsps/stm32f429zi_rig/config/miosix_settings.h
index 5bb339e02447493b119574e5027f4970721d88bf..fb5d771285246a5b7cfd087bd8bb4b522d06967a 100644
--- a/src/bsps/stm32f429zi_rig/config/miosix_settings.h
+++ b/src/bsps/stm32f429zi_rig/config/miosix_settings.h
@@ -27,8 +27,8 @@
 // The PARSING_FROM_IDE is because Netbeans gets confused by this, it is never
 // defined when compiling the code.
 #ifndef PARSING_FROM_IDE
-//#error This error is a reminder that you have not edited miosix_settings.h
-// yet.
+// #error This error is a reminder that you have not edited miosix_settings.h
+//  yet.
 #endif  // PARSING_FROM_IDE
 
 /**
@@ -70,14 +70,14 @@ namespace miosix
 // Uncomment only *one* of those
 
 #define SCHED_TYPE_PRIORITY
-//#define SCHED_TYPE_CONTROL_BASED
-//#define SCHED_TYPE_EDF
+// #define SCHED_TYPE_CONTROL_BASED
+// #define SCHED_TYPE_EDF
 
 /// \def WITH_CPU_TIME_COUNTER
 /// Allows to enable/disable CPUTimeCounter to save code size and remove its
 /// overhead from the scheduling process. By default it is not defined
 /// (CPUTimeCounter is disabled).
-//#define WITH_CPU_TIME_COUNTER
+// #define WITH_CPU_TIME_COUNTER
 
 //
 // Filesystem options
@@ -110,7 +110,7 @@ const unsigned char MAX_OPEN_FILES = 8;
 /// This enables the dynamic loader to load elf programs, the extended system
 /// call service and, if the hardware supports it, the MPU to provide memory
 /// isolation of processes
-//#define WITH_PROCESSES
+// #define WITH_PROCESSES
 
 #if defined(WITH_PROCESSES) && defined(__NO_EXCEPTIONS)
 #error Processes require C++ exception support
@@ -145,7 +145,7 @@ const unsigned char MAX_OPEN_FILES = 8;
 /// \def WITH_DEEP_SLEEP
 /// Adds interfaces and required variables to support deep sleep state switch
 /// automatically when peripherals are not required
-//#define WITH_DEEP_SLEEP
+// #define WITH_DEEP_SLEEP
 
 /**
  * \def JTAG_DISABLE_SLEEP
diff --git a/src/bsps/stm32f429zi_rig/interfaces-impl/bsp.cpp b/src/bsps/stm32f429zi_rig/interfaces-impl/bsp.cpp
index 2caef6f014c57c8eb40402bd6abb7340fae5d23b..42bd1607aa18eead9f5876fbda7a0283c0c2a2ad 100644
--- a/src/bsps/stm32f429zi_rig/interfaces-impl/bsp.cpp
+++ b/src/bsps/stm32f429zi_rig/interfaces-impl/bsp.cpp
@@ -214,56 +214,50 @@ void IRQbspInit()
 
     using namespace interfaces;
 
-    spi1::sck::mode(Mode::ALTERNATE);
     spi1::sck::alternateFunction(5);
-    spi1::miso::mode(Mode::ALTERNATE);
+    spi1::sck::mode(Mode::ALTERNATE);
     spi1::miso::alternateFunction(5);
-    spi1::mosi::mode(Mode::ALTERNATE);
+    spi1::miso::mode(Mode::ALTERNATE);
     spi1::mosi::alternateFunction(5);
+    spi1::mosi::mode(Mode::ALTERNATE);
 
-    spi2::sck::mode(Mode::ALTERNATE);
     spi2::sck::alternateFunction(5);
-    spi2::miso::mode(Mode::ALTERNATE);
+    spi2::sck::mode(Mode::ALTERNATE);
     spi2::miso::alternateFunction(5);
-    spi2::mosi::mode(Mode::ALTERNATE);
+    spi2::miso::mode(Mode::ALTERNATE);
     spi2::mosi::alternateFunction(5);
+    spi2::mosi::mode(Mode::ALTERNATE);
 
-    spi4::sck::mode(Mode::ALTERNATE);
     spi4::sck::alternateFunction(5);
-    spi4::miso::mode(Mode::ALTERNATE);
+    spi4::sck::mode(Mode::ALTERNATE);
     spi4::miso::alternateFunction(5);
-    spi4::mosi::mode(Mode::ALTERNATE);
+    spi4::miso::mode(Mode::ALTERNATE);
     spi4::mosi::alternateFunction(5);
+    spi4::mosi::mode(Mode::ALTERNATE);
 
-    spi5::sck::mode(Mode::ALTERNATE);
     spi5::sck::alternateFunction(5);
-    spi5::miso::mode(Mode::ALTERNATE);
+    spi5::sck::mode(Mode::ALTERNATE);
     spi5::miso::alternateFunction(5);
-    spi5::mosi::mode(Mode::ALTERNATE);
+    spi5::miso::mode(Mode::ALTERNATE);
     spi5::mosi::alternateFunction(5);
+    spi5::mosi::mode(Mode::ALTERNATE);
 
-    spi6::sck::mode(Mode::ALTERNATE);
     spi6::sck::alternateFunction(5);
-    spi6::miso::mode(Mode::ALTERNATE);
+    spi6::sck::mode(Mode::ALTERNATE);
     spi6::miso::alternateFunction(5);
-    spi6::mosi::mode(Mode::ALTERNATE);
+    spi6::miso::mode(Mode::ALTERNATE);
     spi6::mosi::alternateFunction(5);
+    spi6::mosi::mode(Mode::ALTERNATE);
 
-    uart1::rx::mode(Mode::ALTERNATE);
     uart1::rx::alternateFunction(7);
-    uart1::tx::mode(Mode::ALTERNATE);
+    uart1::rx::mode(Mode::ALTERNATE);
     uart1::tx::alternateFunction(7);
+    uart1::tx::mode(Mode::ALTERNATE);
 
-    can1::rx::mode(Mode::ALTERNATE);
     can1::rx::alternateFunction(9);
-    can1::tx::mode(Mode::ALTERNATE);
+    can1::rx::mode(Mode::ALTERNATE);
     can1::tx::alternateFunction(9);
-
-    timers::tim4ch2::mode(Mode::ALTERNATE);
-    timers::tim11ch1::mode(Mode::ALTERNATE);
-    timers::tim3ch1::mode(Mode::ALTERNATE);
-    timers::tim10ch1::mode(Mode::ALTERNATE);
-    timers::tim8ch1::mode(Mode::ALTERNATE);
+    can1::tx::mode(Mode::ALTERNATE);
 
     timers::tim4ch2::alternateFunction(2);
     timers::tim11ch1::alternateFunction(3);
@@ -271,6 +265,12 @@ void IRQbspInit()
     timers::tim10ch1::alternateFunction(3);
     timers::tim8ch1::alternateFunction(3);
 
+    timers::tim4ch2::mode(Mode::ALTERNATE);
+    timers::tim11ch1::mode(Mode::ALTERNATE);
+    timers::tim3ch1::mode(Mode::ALTERNATE);
+    timers::tim10ch1::mode(Mode::ALTERNATE);
+    timers::tim8ch1::mode(Mode::ALTERNATE);
+
     using namespace sensors;
     ADS131_1::cs::mode(Mode::OUTPUT);
     ADS131_1::cs::high();
diff --git a/src/bsps/stm32f756zg_nucleo/config/miosix_settings.h b/src/bsps/stm32f756zg_nucleo/config/miosix_settings.h
index 924bbc52a40b6a327ce1f3fd61337a017ce87d71..7d337090043e2aa3e40e0fff7fb8b1aaa845b5dd 100644
--- a/src/bsps/stm32f756zg_nucleo/config/miosix_settings.h
+++ b/src/bsps/stm32f756zg_nucleo/config/miosix_settings.h
@@ -27,8 +27,8 @@
 // The PARSING_FROM_IDE is because Netbeans gets confused by this, it is never
 // defined when compiling the code.
 #ifndef PARSING_FROM_IDE
-//#error This error is a reminder that you have not edited miosix_settings.h
-// yet.
+// #error This error is a reminder that you have not edited miosix_settings.h
+//  yet.
 #endif  // PARSING_FROM_IDE
 
 /**
@@ -70,14 +70,14 @@ namespace miosix
 // Uncomment only *one* of those
 
 #define SCHED_TYPE_PRIORITY
-//#define SCHED_TYPE_CONTROL_BASED
-//#define SCHED_TYPE_EDF
+// #define SCHED_TYPE_CONTROL_BASED
+// #define SCHED_TYPE_EDF
 
 /// \def WITH_CPU_TIME_COUNTER
 /// Allows to enable/disable CPUTimeCounter to save code size and remove its
 /// overhead from the scheduling process. By default it is not defined
 /// (CPUTimeCounter is disabled).
-//#define WITH_CPU_TIME_COUNTER
+// #define WITH_CPU_TIME_COUNTER
 
 //
 // Filesystem options
@@ -110,7 +110,7 @@ const unsigned char MAX_OPEN_FILES = 8;
 /// This enables the dynamic loader to load elf programs, the extended system
 /// call service and, if the hardware supports it, the MPU to provide memory
 /// isolation of processes
-//#define WITH_PROCESSES
+// #define WITH_PROCESSES
 
 #if defined(WITH_PROCESSES) && defined(__NO_EXCEPTIONS)
 #error Processes require C++ exception support
@@ -145,7 +145,7 @@ const unsigned char MAX_OPEN_FILES = 8;
 /// \def WITH_DEEP_SLEEP
 /// Adds interfaces and required variables to support deep sleep state switch
 /// automatically when peripherals are not required
-//#define WITH_DEEP_SLEEP
+// #define WITH_DEEP_SLEEP
 
 /**
  * \def JTAG_DISABLE_SLEEP
diff --git a/src/bsps/stm32f756zg_nucleo/interfaces-impl/bsp.cpp b/src/bsps/stm32f756zg_nucleo/interfaces-impl/bsp.cpp
index 2cc3d8230ed05540f7b075e2d178a9e6293534ab..b6a87331246d8d1139b0540002aec2209bd5f849 100644
--- a/src/bsps/stm32f756zg_nucleo/interfaces-impl/bsp.cpp
+++ b/src/bsps/stm32f756zg_nucleo/interfaces-impl/bsp.cpp
@@ -77,10 +77,15 @@ void IRQbspInit()
     ledOn();
     delayMs(100);
     ledOff();
+
     auto tx = Gpio<GPIOD_BASE, 8>::getPin();
     tx.alternateFunction(7);
     auto rx = Gpio<GPIOD_BASE, 9>::getPin();
     rx.alternateFunction(7);
+
+    // rx and tx alternate function is set here, mode will be set by the
+    // STM32Serial class later on
+
     DefaultConsole::instance().IRQset(intrusive_ref_ptr<Device>(
         new STM32Serial(3, defaultSerialSpeed, tx, rx)));
 }
diff --git a/src/bsps/stm32f767zi_automated_antennas/config/miosix_settings.h b/src/bsps/stm32f767zi_automated_antennas/config/miosix_settings.h
index 4df5735cec0075381011304085875d00a309d003..eaeb50131823dd9bb2b3b8d66a6c93b5b170acae 100644
--- a/src/bsps/stm32f767zi_automated_antennas/config/miosix_settings.h
+++ b/src/bsps/stm32f767zi_automated_antennas/config/miosix_settings.h
@@ -27,8 +27,8 @@
 // The PARSING_FROM_IDE is because Netbeans gets confused by this, it is never
 // defined when compiling the code.
 #ifndef PARSING_FROM_IDE
-//#error This error is a reminder that you have not edited miosix_settings.h
-// yet.
+// #error This error is a reminder that you have not edited miosix_settings.h
+//  yet.
 #endif  // PARSING_FROM_IDE
 
 /**
@@ -70,14 +70,14 @@ namespace miosix
 // Uncomment only *one* of those
 
 #define SCHED_TYPE_PRIORITY
-//#define SCHED_TYPE_CONTROL_BASED
-//#define SCHED_TYPE_EDF
+// #define SCHED_TYPE_CONTROL_BASED
+// #define SCHED_TYPE_EDF
 
 /// \def WITH_CPU_TIME_COUNTER
 /// Allows to enable/disable CPUTimeCounter to save code size and remove its
 /// overhead from the scheduling process. By default it is not defined
 /// (CPUTimeCounter is disabled).
-//#define WITH_CPU_TIME_COUNTER
+// #define WITH_CPU_TIME_COUNTER
 
 //
 // Filesystem options
@@ -110,7 +110,7 @@ const unsigned char MAX_OPEN_FILES = 8;
 /// This enables the dynamic loader to load elf programs, the extended system
 /// call service and, if the hardware supports it, the MPU to provide memory
 /// isolation of processes
-//#define WITH_PROCESSES
+// #define WITH_PROCESSES
 
 #if defined(WITH_PROCESSES) && defined(__NO_EXCEPTIONS)
 #error Processes require C++ exception support
@@ -145,7 +145,7 @@ const unsigned char MAX_OPEN_FILES = 8;
 /// \def WITH_DEEP_SLEEP
 /// Adds interfaces and required variables to support deep sleep state switch
 /// automatically when peripherals are not required
-//#define WITH_DEEP_SLEEP
+// #define WITH_DEEP_SLEEP
 
 /**
  * \def JTAG_DISABLE_SLEEP
diff --git a/src/bsps/stm32f767zi_automated_antennas/interfaces-impl/bsp.cpp b/src/bsps/stm32f767zi_automated_antennas/interfaces-impl/bsp.cpp
index 0853b1f8b51a361f67f78683477d2e28fb622b28..c9fb4d970a732f717b830a0aaa617226c35a6584 100644
--- a/src/bsps/stm32f767zi_automated_antennas/interfaces-impl/bsp.cpp
+++ b/src/bsps/stm32f767zi_automated_antennas/interfaces-impl/bsp.cpp
@@ -232,41 +232,41 @@ void IRQbspInit()
     userSwitch::mode(Mode::INPUT);
 
     using namespace interfaces;
-    spi1::sck::mode(Mode::ALTERNATE);
     spi1::sck::alternateFunction(5);
-    spi1::miso::mode(Mode::ALTERNATE);
+    spi1::sck::mode(Mode::ALTERNATE);
     spi1::miso::alternateFunction(5);
-    spi1::mosi::mode(Mode::ALTERNATE);
+    spi1::miso::mode(Mode::ALTERNATE);
     spi1::mosi::alternateFunction(5);
+    spi1::mosi::mode(Mode::ALTERNATE);
 
-    spi3::sck::mode(Mode::ALTERNATE);
     spi3::sck::alternateFunction(6);
-    spi3::miso::mode(Mode::ALTERNATE);
+    spi3::sck::mode(Mode::ALTERNATE);
     spi3::miso::alternateFunction(6);
-    spi3::mosi::mode(Mode::ALTERNATE);
+    spi3::miso::mode(Mode::ALTERNATE);
     spi3::mosi::alternateFunction(5);
+    spi3::mosi::mode(Mode::ALTERNATE);
 
-    spi4::sck::mode(Mode::ALTERNATE);
     spi4::sck::alternateFunction(5);
-    spi4::miso::mode(Mode::ALTERNATE);
+    spi4::sck::mode(Mode::ALTERNATE);
     spi4::miso::alternateFunction(5);
-    spi4::mosi::mode(Mode::ALTERNATE);
+    spi4::miso::mode(Mode::ALTERNATE);
     spi4::mosi::alternateFunction(5);
+    spi4::mosi::mode(Mode::ALTERNATE);
 
-    can2::rx::mode(Mode::ALTERNATE);
     can2::rx::alternateFunction(9);
-    can2::tx::mode(Mode::ALTERNATE);
+    can2::rx::mode(Mode::ALTERNATE);
     can2::tx::alternateFunction(9);
+    can2::tx::mode(Mode::ALTERNATE);
 
-    usart1::tx::mode(Mode::ALTERNATE);
     usart1::tx::alternateFunction(7);
-    usart1::rx::mode(Mode::ALTERNATE);
+    usart1::tx::mode(Mode::ALTERNATE);
     usart1::rx::alternateFunction(7);
+    usart1::rx::mode(Mode::ALTERNATE);
 
-    usart2::tx::mode(Mode::ALTERNATE);
     usart2::tx::alternateFunction(7);
-    usart2::rx::mode(Mode::ALTERNATE);
+    usart2::tx::mode(Mode::ALTERNATE);
     usart2::rx::alternateFunction(7);
+    usart2::rx::mode(Mode::ALTERNATE);
 
     using namespace radio;
     cs::mode(Mode::OUTPUT);
@@ -278,10 +278,10 @@ void IRQbspInit()
     rx_enable::mode(Mode::OUTPUT);
 
     using namespace timers;
-    tim3ch2::mode(Mode::ALTERNATE);
     tim3ch2::alternateFunction(2);
-    tim4ch1::mode(Mode::ALTERNATE);
+    tim3ch2::mode(Mode::ALTERNATE);
     tim4ch1::alternateFunction(2);
+    tim4ch1::mode(Mode::ALTERNATE);
 
     stepper1::enable::mode(Mode::OUTPUT);
     stepper1::direction::mode(Mode::OUTPUT);
diff --git a/src/bsps/stm32f767zi_compute_unit/config/miosix_settings.h b/src/bsps/stm32f767zi_compute_unit/config/miosix_settings.h
index 64b0670cab5f4cdfc3d8e06db7cc06e913deae15..1d02b120519dfa4a8fec6705418221cf4ee433c2 100644
--- a/src/bsps/stm32f767zi_compute_unit/config/miosix_settings.h
+++ b/src/bsps/stm32f767zi_compute_unit/config/miosix_settings.h
@@ -27,8 +27,8 @@
 // The PARSING_FROM_IDE is because Netbeans gets confused by this, it is never
 // defined when compiling the code.
 #ifndef PARSING_FROM_IDE
-//#error This error is a reminder that you have not edited miosix_settings.h
-// yet.
+// #error This error is a reminder that you have not edited miosix_settings.h
+//  yet.
 #endif  // PARSING_FROM_IDE
 
 /**
@@ -70,14 +70,14 @@ namespace miosix
 // Uncomment only *one* of those
 
 #define SCHED_TYPE_PRIORITY
-//#define SCHED_TYPE_CONTROL_BASED
-//#define SCHED_TYPE_EDF
+// #define SCHED_TYPE_CONTROL_BASED
+// #define SCHED_TYPE_EDF
 
 /// \def WITH_CPU_TIME_COUNTER
 /// Allows to enable/disable CPUTimeCounter to save code size and remove its
 /// overhead from the scheduling process. By default it is not defined
 /// (CPUTimeCounter is disabled).
-//#define WITH_CPU_TIME_COUNTER
+// #define WITH_CPU_TIME_COUNTER
 
 //
 // Filesystem options
@@ -110,7 +110,7 @@ const unsigned char MAX_OPEN_FILES = 8;
 /// This enables the dynamic loader to load elf programs, the extended system
 /// call service and, if the hardware supports it, the MPU to provide memory
 /// isolation of processes
-//#define WITH_PROCESSES
+// #define WITH_PROCESSES
 
 #if defined(WITH_PROCESSES) && defined(__NO_EXCEPTIONS)
 #error Processes require C++ exception support
@@ -145,7 +145,7 @@ const unsigned char MAX_OPEN_FILES = 8;
 /// \def WITH_DEEP_SLEEP
 /// Adds interfaces and required variables to support deep sleep state switch
 /// automatically when peripherals are not required
-//#define WITH_DEEP_SLEEP
+// #define WITH_DEEP_SLEEP
 
 /**
  * \def JTAG_DISABLE_SLEEP
diff --git a/src/bsps/stm32f767zi_compute_unit_v2/config/miosix_settings.h b/src/bsps/stm32f767zi_compute_unit_v2/config/miosix_settings.h
index 64b0670cab5f4cdfc3d8e06db7cc06e913deae15..1d02b120519dfa4a8fec6705418221cf4ee433c2 100644
--- a/src/bsps/stm32f767zi_compute_unit_v2/config/miosix_settings.h
+++ b/src/bsps/stm32f767zi_compute_unit_v2/config/miosix_settings.h
@@ -27,8 +27,8 @@
 // The PARSING_FROM_IDE is because Netbeans gets confused by this, it is never
 // defined when compiling the code.
 #ifndef PARSING_FROM_IDE
-//#error This error is a reminder that you have not edited miosix_settings.h
-// yet.
+// #error This error is a reminder that you have not edited miosix_settings.h
+//  yet.
 #endif  // PARSING_FROM_IDE
 
 /**
@@ -70,14 +70,14 @@ namespace miosix
 // Uncomment only *one* of those
 
 #define SCHED_TYPE_PRIORITY
-//#define SCHED_TYPE_CONTROL_BASED
-//#define SCHED_TYPE_EDF
+// #define SCHED_TYPE_CONTROL_BASED
+// #define SCHED_TYPE_EDF
 
 /// \def WITH_CPU_TIME_COUNTER
 /// Allows to enable/disable CPUTimeCounter to save code size and remove its
 /// overhead from the scheduling process. By default it is not defined
 /// (CPUTimeCounter is disabled).
-//#define WITH_CPU_TIME_COUNTER
+// #define WITH_CPU_TIME_COUNTER
 
 //
 // Filesystem options
@@ -110,7 +110,7 @@ const unsigned char MAX_OPEN_FILES = 8;
 /// This enables the dynamic loader to load elf programs, the extended system
 /// call service and, if the hardware supports it, the MPU to provide memory
 /// isolation of processes
-//#define WITH_PROCESSES
+// #define WITH_PROCESSES
 
 #if defined(WITH_PROCESSES) && defined(__NO_EXCEPTIONS)
 #error Processes require C++ exception support
@@ -145,7 +145,7 @@ const unsigned char MAX_OPEN_FILES = 8;
 /// \def WITH_DEEP_SLEEP
 /// Adds interfaces and required variables to support deep sleep state switch
 /// automatically when peripherals are not required
-//#define WITH_DEEP_SLEEP
+// #define WITH_DEEP_SLEEP
 
 /**
  * \def JTAG_DISABLE_SLEEP
diff --git a/src/bsps/stm32f767zi_death_stack_v4/config/miosix_settings.h b/src/bsps/stm32f767zi_death_stack_v4/config/miosix_settings.h
index 5bb339e02447493b119574e5027f4970721d88bf..fb5d771285246a5b7cfd087bd8bb4b522d06967a 100644
--- a/src/bsps/stm32f767zi_death_stack_v4/config/miosix_settings.h
+++ b/src/bsps/stm32f767zi_death_stack_v4/config/miosix_settings.h
@@ -27,8 +27,8 @@
 // The PARSING_FROM_IDE is because Netbeans gets confused by this, it is never
 // defined when compiling the code.
 #ifndef PARSING_FROM_IDE
-//#error This error is a reminder that you have not edited miosix_settings.h
-// yet.
+// #error This error is a reminder that you have not edited miosix_settings.h
+//  yet.
 #endif  // PARSING_FROM_IDE
 
 /**
@@ -70,14 +70,14 @@ namespace miosix
 // Uncomment only *one* of those
 
 #define SCHED_TYPE_PRIORITY
-//#define SCHED_TYPE_CONTROL_BASED
-//#define SCHED_TYPE_EDF
+// #define SCHED_TYPE_CONTROL_BASED
+// #define SCHED_TYPE_EDF
 
 /// \def WITH_CPU_TIME_COUNTER
 /// Allows to enable/disable CPUTimeCounter to save code size and remove its
 /// overhead from the scheduling process. By default it is not defined
 /// (CPUTimeCounter is disabled).
-//#define WITH_CPU_TIME_COUNTER
+// #define WITH_CPU_TIME_COUNTER
 
 //
 // Filesystem options
@@ -110,7 +110,7 @@ const unsigned char MAX_OPEN_FILES = 8;
 /// This enables the dynamic loader to load elf programs, the extended system
 /// call service and, if the hardware supports it, the MPU to provide memory
 /// isolation of processes
-//#define WITH_PROCESSES
+// #define WITH_PROCESSES
 
 #if defined(WITH_PROCESSES) && defined(__NO_EXCEPTIONS)
 #error Processes require C++ exception support
@@ -145,7 +145,7 @@ const unsigned char MAX_OPEN_FILES = 8;
 /// \def WITH_DEEP_SLEEP
 /// Adds interfaces and required variables to support deep sleep state switch
 /// automatically when peripherals are not required
-//#define WITH_DEEP_SLEEP
+// #define WITH_DEEP_SLEEP
 
 /**
  * \def JTAG_DISABLE_SLEEP
diff --git a/src/bsps/stm32f767zi_death_stack_v4/interfaces-impl/bsp.cpp b/src/bsps/stm32f767zi_death_stack_v4/interfaces-impl/bsp.cpp
index 557775f4156e8a38caba214bb1acb568e8f2b154..f839dacd5d40bc16b27ad09052176e3e34c94e3e 100644
--- a/src/bsps/stm32f767zi_death_stack_v4/interfaces-impl/bsp.cpp
+++ b/src/bsps/stm32f767zi_death_stack_v4/interfaces-impl/bsp.cpp
@@ -232,73 +232,73 @@ void IRQbspInit()
     userSwitch::mode(Mode::INPUT);
 
     using namespace interfaces;
-    spi1::sck::mode(Mode::ALTERNATE);
     spi1::sck::alternateFunction(5);
-    spi1::miso::mode(Mode::ALTERNATE);
+    spi1::sck::mode(Mode::ALTERNATE);
     spi1::miso::alternateFunction(5);
-    spi1::mosi::mode(Mode::ALTERNATE);
+    spi1::miso::mode(Mode::ALTERNATE);
     spi1::mosi::alternateFunction(5);
+    spi1::mosi::mode(Mode::ALTERNATE);
 
-    spi3::sck::mode(Mode::ALTERNATE);
     spi3::sck::alternateFunction(6);
-    spi3::miso::mode(Mode::ALTERNATE);
+    spi3::sck::mode(Mode::ALTERNATE);
     spi3::miso::alternateFunction(6);
-    spi3::mosi::mode(Mode::ALTERNATE);
+    spi3::miso::mode(Mode::ALTERNATE);
     spi3::mosi::alternateFunction(5);
+    spi3::mosi::mode(Mode::ALTERNATE);
 
-    spi4::sck::mode(Mode::ALTERNATE);
     spi4::sck::alternateFunction(5);
-    spi4::miso::mode(Mode::ALTERNATE);
+    spi4::sck::mode(Mode::ALTERNATE);
     spi4::miso::alternateFunction(5);
-    spi4::mosi::mode(Mode::ALTERNATE);
+    spi4::miso::mode(Mode::ALTERNATE);
     spi4::mosi::alternateFunction(5);
+    spi4::mosi::mode(Mode::ALTERNATE);
 
-    spi6::sck::mode(Mode::ALTERNATE);
     spi6::sck::alternateFunction(5);
-    spi6::miso::mode(Mode::ALTERNATE);
+    spi6::sck::mode(Mode::ALTERNATE);
     spi6::miso::alternateFunction(5);
-    spi6::mosi::mode(Mode::ALTERNATE);
+    spi6::miso::mode(Mode::ALTERNATE);
     spi6::mosi::alternateFunction(5);
+    spi6::mosi::mode(Mode::ALTERNATE);
 
-    i2c1::sda::mode(Mode::ALTERNATE);
     i2c1::sda::alternateFunction(4);
-    i2c1::scl::mode(Mode::ALTERNATE);
+    i2c1::sda::mode(Mode::ALTERNATE);
     i2c1::scl::alternateFunction(4);
+    i2c1::scl::mode(Mode::ALTERNATE);
 
-    can1::rx::mode(Mode::ALTERNATE);
     can1::rx::alternateFunction(9);
-    can1::tx::mode(Mode::ALTERNATE);
+    can1::rx::mode(Mode::ALTERNATE);
     can1::tx::alternateFunction(9);
+    can1::tx::mode(Mode::ALTERNATE);
 
-    can2::rx::mode(Mode::ALTERNATE);
     can2::rx::alternateFunction(9);
-    can2::tx::mode(Mode::ALTERNATE);
+    can2::rx::mode(Mode::ALTERNATE);
     can2::tx::alternateFunction(9);
+    can2::tx::mode(Mode::ALTERNATE);
 
-    usart1::tx::mode(Mode::ALTERNATE);
     usart1::tx::alternateFunction(7);
-    usart1::rx::mode(Mode::ALTERNATE);
+    usart1::tx::mode(Mode::ALTERNATE);
     usart1::rx::alternateFunction(7);
+    usart1::rx::mode(Mode::ALTERNATE);
 
-    usart2::tx::mode(Mode::ALTERNATE);
     usart2::tx::alternateFunction(7);
-    usart2::rx::mode(Mode::ALTERNATE);
+    usart2::tx::mode(Mode::ALTERNATE);
     usart2::rx::alternateFunction(7);
+    usart2::rx::mode(Mode::ALTERNATE);
 
-    uart4::tx::mode(Mode::ALTERNATE);
     uart4::tx::alternateFunction(8);
-    uart4::rx::mode(Mode::ALTERNATE);
+    uart4::tx::mode(Mode::ALTERNATE);
     uart4::rx::alternateFunction(8);
+    uart4::rx::mode(Mode::ALTERNATE);
 
     using namespace timers;
-    tim3ch1::mode(Mode::ALTERNATE);
     tim3ch1::alternateFunction(2);
-    tim3ch2::mode(Mode::ALTERNATE);
+    tim3ch1::mode(Mode::ALTERNATE);
     tim3ch2::alternateFunction(2);
-    tim1ch1::mode(Mode::ALTERNATE);
+    tim3ch2::mode(Mode::ALTERNATE);
     tim1ch1::alternateFunction(1);
-    tim12ch2::mode(Mode::ALTERNATE);
+    tim1ch1::mode(Mode::ALTERNATE);
     tim12ch2::alternateFunction(9);
+    tim12ch2::mode(Mode::ALTERNATE);
 
     using namespace sensors;
     LSM6DSRX::cs::mode(Mode::OUTPUT);
diff --git a/src/bsps/stm32f767zi_gemini_gs/config/miosix_settings.h b/src/bsps/stm32f767zi_gemini_gs/config/miosix_settings.h
index a83f2a517a69131baa3e820b0754ae58a4eb0b0e..cc85def80c2c9796b87bb8ae0cfe037bdcb5f092 100644
--- a/src/bsps/stm32f767zi_gemini_gs/config/miosix_settings.h
+++ b/src/bsps/stm32f767zi_gemini_gs/config/miosix_settings.h
@@ -27,8 +27,8 @@
 // The PARSING_FROM_IDE is because Netbeans gets confused by this, it is never
 // defined when compiling the code.
 #ifndef PARSING_FROM_IDE
-//#error This error is a reminder that you have not edited miosix_settings.h
-// yet.
+// #error This error is a reminder that you have not edited miosix_settings.h
+//  yet.
 #endif  // PARSING_FROM_IDE
 
 /**
@@ -70,14 +70,14 @@ namespace miosix
 // Uncomment only *one* of those
 
 #define SCHED_TYPE_PRIORITY
-//#define SCHED_TYPE_CONTROL_BASED
-//#define SCHED_TYPE_EDF
+// #define SCHED_TYPE_CONTROL_BASED
+// #define SCHED_TYPE_EDF
 
 /// \def WITH_CPU_TIME_COUNTER
 /// Allows to enable/disable CPUTimeCounter to save code size and remove its
 /// overhead from the scheduling process. By default it is not defined
 /// (CPUTimeCounter is disabled).
-//#define WITH_CPU_TIME_COUNTER
+// #define WITH_CPU_TIME_COUNTER
 
 //
 // Filesystem options
@@ -110,7 +110,7 @@ const unsigned char MAX_OPEN_FILES = 8;
 /// This enables the dynamic loader to load elf programs, the extended system
 /// call service and, if the hardware supports it, the MPU to provide memory
 /// isolation of processes
-//#define WITH_PROCESSES
+// #define WITH_PROCESSES
 
 #if defined(WITH_PROCESSES) && defined(__NO_EXCEPTIONS)
 #error Processes require C++ exception support
@@ -145,7 +145,7 @@ const unsigned char MAX_OPEN_FILES = 8;
 /// \def WITH_DEEP_SLEEP
 /// Adds interfaces and required variables to support deep sleep state switch
 /// automatically when peripherals are not required
-//#define WITH_DEEP_SLEEP
+// #define WITH_DEEP_SLEEP
 
 /**
  * \def JTAG_DISABLE_SLEEP
diff --git a/src/bsps/stm32f767zi_gemini_gs/interfaces-impl/bsp.cpp b/src/bsps/stm32f767zi_gemini_gs/interfaces-impl/bsp.cpp
index f1b9d7daf7e1ef66a426246697b8eccabdb47589..6737470e3aec6358a71542665212528174328e02 100644
--- a/src/bsps/stm32f767zi_gemini_gs/interfaces-impl/bsp.cpp
+++ b/src/bsps/stm32f767zi_gemini_gs/interfaces-impl/bsp.cpp
@@ -231,26 +231,26 @@ void IRQbspInit()
     userLed4::mode(Mode::OUTPUT);
     userSwitch::mode(Mode::INPUT);
 
-    interfaces::spi1::miso::mode(Mode::ALTERNATE);
     interfaces::spi1::miso::alternateFunction(5);
-    interfaces::spi1::mosi::mode(Mode::ALTERNATE);
+    interfaces::spi1::miso::mode(Mode::ALTERNATE);
     interfaces::spi1::mosi::alternateFunction(5);
-    interfaces::spi1::sck::mode(Mode::ALTERNATE);
+    interfaces::spi1::mosi::mode(Mode::ALTERNATE);
     interfaces::spi1::sck::alternateFunction(5);
+    interfaces::spi1::sck::mode(Mode::ALTERNATE);
 
-    interfaces::spi3::miso::mode(Mode::ALTERNATE);
     interfaces::spi3::miso::alternateFunction(6);
-    interfaces::spi3::mosi::mode(Mode::ALTERNATE);
+    interfaces::spi3::miso::mode(Mode::ALTERNATE);
     interfaces::spi3::mosi::alternateFunction(5);
-    interfaces::spi3::sck::mode(Mode::ALTERNATE);
+    interfaces::spi3::mosi::mode(Mode::ALTERNATE);
     interfaces::spi3::sck::alternateFunction(6);
+    interfaces::spi3::sck::mode(Mode::ALTERNATE);
 
-    interfaces::spi4::miso::mode(Mode::ALTERNATE);
     interfaces::spi4::miso::alternateFunction(5);
-    interfaces::spi4::mosi::mode(Mode::ALTERNATE);
+    interfaces::spi4::miso::mode(Mode::ALTERNATE);
     interfaces::spi4::mosi::alternateFunction(5);
-    interfaces::spi4::sck::mode(Mode::ALTERNATE);
+    interfaces::spi4::mosi::mode(Mode::ALTERNATE);
     interfaces::spi4::sck::alternateFunction(5);
+    interfaces::spi4::sck::mode(Mode::ALTERNATE);
 
     radio1::cs::mode(Mode::OUTPUT);
     radio1::cs::high();
diff --git a/src/bsps/stm32f767zi_gemini_motor/config/miosix_settings.h b/src/bsps/stm32f767zi_gemini_motor/config/miosix_settings.h
index 64b0670cab5f4cdfc3d8e06db7cc06e913deae15..1d02b120519dfa4a8fec6705418221cf4ee433c2 100644
--- a/src/bsps/stm32f767zi_gemini_motor/config/miosix_settings.h
+++ b/src/bsps/stm32f767zi_gemini_motor/config/miosix_settings.h
@@ -27,8 +27,8 @@
 // The PARSING_FROM_IDE is because Netbeans gets confused by this, it is never
 // defined when compiling the code.
 #ifndef PARSING_FROM_IDE
-//#error This error is a reminder that you have not edited miosix_settings.h
-// yet.
+// #error This error is a reminder that you have not edited miosix_settings.h
+//  yet.
 #endif  // PARSING_FROM_IDE
 
 /**
@@ -70,14 +70,14 @@ namespace miosix
 // Uncomment only *one* of those
 
 #define SCHED_TYPE_PRIORITY
-//#define SCHED_TYPE_CONTROL_BASED
-//#define SCHED_TYPE_EDF
+// #define SCHED_TYPE_CONTROL_BASED
+// #define SCHED_TYPE_EDF
 
 /// \def WITH_CPU_TIME_COUNTER
 /// Allows to enable/disable CPUTimeCounter to save code size and remove its
 /// overhead from the scheduling process. By default it is not defined
 /// (CPUTimeCounter is disabled).
-//#define WITH_CPU_TIME_COUNTER
+// #define WITH_CPU_TIME_COUNTER
 
 //
 // Filesystem options
@@ -110,7 +110,7 @@ const unsigned char MAX_OPEN_FILES = 8;
 /// This enables the dynamic loader to load elf programs, the extended system
 /// call service and, if the hardware supports it, the MPU to provide memory
 /// isolation of processes
-//#define WITH_PROCESSES
+// #define WITH_PROCESSES
 
 #if defined(WITH_PROCESSES) && defined(__NO_EXCEPTIONS)
 #error Processes require C++ exception support
@@ -145,7 +145,7 @@ const unsigned char MAX_OPEN_FILES = 8;
 /// \def WITH_DEEP_SLEEP
 /// Adds interfaces and required variables to support deep sleep state switch
 /// automatically when peripherals are not required
-//#define WITH_DEEP_SLEEP
+// #define WITH_DEEP_SLEEP
 
 /**
  * \def JTAG_DISABLE_SLEEP
diff --git a/src/bsps/stm32f767zi_gemini_motor/interfaces-impl/bsp.cpp b/src/bsps/stm32f767zi_gemini_motor/interfaces-impl/bsp.cpp
index 12303cae3b797c729cba634123b21caabee0afb1..aba9222316e1f728577aa45dafe0d85d9b8b0489 100644
--- a/src/bsps/stm32f767zi_gemini_motor/interfaces-impl/bsp.cpp
+++ b/src/bsps/stm32f767zi_gemini_motor/interfaces-impl/bsp.cpp
@@ -224,38 +224,38 @@ void IRQbspInit()
     // Enable USART1 pins port
     RCC->AHB1ENR |= RCC_AHB1ENR_GPIOAEN;
 
-    interfaces::spi1::sck::mode(Mode::ALTERNATE);
     interfaces::spi1::sck::alternateFunction(5);
-    interfaces::spi1::miso::mode(Mode::ALTERNATE);
+    interfaces::spi1::sck::mode(Mode::ALTERNATE);
     interfaces::spi1::miso::alternateFunction(5);
-    interfaces::spi1::mosi::mode(Mode::ALTERNATE);
+    interfaces::spi1::miso::mode(Mode::ALTERNATE);
     interfaces::spi1::mosi::alternateFunction(5);
+    interfaces::spi1::mosi::mode(Mode::ALTERNATE);
 
-    interfaces::spi3::sck::mode(Mode::ALTERNATE);
     interfaces::spi3::sck::alternateFunction(6);
-    interfaces::spi3::miso::mode(Mode::ALTERNATE);
+    interfaces::spi3::sck::mode(Mode::ALTERNATE);
     interfaces::spi3::miso::alternateFunction(6);
-    interfaces::spi3::mosi::mode(Mode::ALTERNATE);
+    interfaces::spi3::miso::mode(Mode::ALTERNATE);
     interfaces::spi3::mosi::alternateFunction(5);
+    interfaces::spi3::mosi::mode(Mode::ALTERNATE);
 
-    interfaces::spi4::sck::mode(Mode::ALTERNATE);
     interfaces::spi4::sck::alternateFunction(5);
-    interfaces::spi4::miso::mode(Mode::ALTERNATE);
+    interfaces::spi4::sck::mode(Mode::ALTERNATE);
     interfaces::spi4::miso::alternateFunction(5);
-    interfaces::spi4::mosi::mode(Mode::ALTERNATE);
+    interfaces::spi4::miso::mode(Mode::ALTERNATE);
     interfaces::spi4::mosi::alternateFunction(5);
+    interfaces::spi4::mosi::mode(Mode::ALTERNATE);
 
     // USART1 configured by the miosix serial driver
 
-    interfaces::usart2::tx::mode(Mode::ALTERNATE);
     interfaces::usart2::tx::alternateFunction(7);
-    interfaces::usart2::rx::mode(Mode::ALTERNATE);
+    interfaces::usart2::tx::mode(Mode::ALTERNATE);
     interfaces::usart2::rx::alternateFunction(7);
+    interfaces::usart2::rx::mode(Mode::ALTERNATE);
 
-    interfaces::can2::tx::mode(Mode::ALTERNATE);
     interfaces::can2::tx::alternateFunction(9);
-    interfaces::can2::rx::mode(Mode::ALTERNATE);
+    interfaces::can2::tx::mode(Mode::ALTERNATE);
     interfaces::can2::rx::alternateFunction(9);
+    interfaces::can2::rx::mode(Mode::ALTERNATE);
 
     peripherals::leds::userLed1::mode(Mode::OUTPUT);
     peripherals::leds::userLed2::mode(Mode::OUTPUT);
@@ -287,10 +287,10 @@ void IRQbspInit()
     peripherals::max31856::cs::mode(Mode::OUTPUT);
     peripherals::max31856::cs::high();
 
-    peripherals::servos::servo1::mode(Mode::ALTERNATE);
     peripherals::servos::servo1::alternateFunction(3);
-    peripherals::servos::servo2::mode(Mode::ALTERNATE);
+    peripherals::servos::servo1::mode(Mode::ALTERNATE);
     peripherals::servos::servo2::alternateFunction(3);
+    peripherals::servos::servo2::mode(Mode::ALTERNATE);
 
     peripherals::tank_level::lvl1::mode(Mode::INPUT);
     peripherals::tank_level::lvl2::mode(Mode::INPUT);
diff --git a/src/bsps/stm32f767zi_lyra_biscotto/config/miosix_settings.h b/src/bsps/stm32f767zi_lyra_biscotto/config/miosix_settings.h
index 64b0670cab5f4cdfc3d8e06db7cc06e913deae15..1d02b120519dfa4a8fec6705418221cf4ee433c2 100644
--- a/src/bsps/stm32f767zi_lyra_biscotto/config/miosix_settings.h
+++ b/src/bsps/stm32f767zi_lyra_biscotto/config/miosix_settings.h
@@ -27,8 +27,8 @@
 // The PARSING_FROM_IDE is because Netbeans gets confused by this, it is never
 // defined when compiling the code.
 #ifndef PARSING_FROM_IDE
-//#error This error is a reminder that you have not edited miosix_settings.h
-// yet.
+// #error This error is a reminder that you have not edited miosix_settings.h
+//  yet.
 #endif  // PARSING_FROM_IDE
 
 /**
@@ -70,14 +70,14 @@ namespace miosix
 // Uncomment only *one* of those
 
 #define SCHED_TYPE_PRIORITY
-//#define SCHED_TYPE_CONTROL_BASED
-//#define SCHED_TYPE_EDF
+// #define SCHED_TYPE_CONTROL_BASED
+// #define SCHED_TYPE_EDF
 
 /// \def WITH_CPU_TIME_COUNTER
 /// Allows to enable/disable CPUTimeCounter to save code size and remove its
 /// overhead from the scheduling process. By default it is not defined
 /// (CPUTimeCounter is disabled).
-//#define WITH_CPU_TIME_COUNTER
+// #define WITH_CPU_TIME_COUNTER
 
 //
 // Filesystem options
@@ -110,7 +110,7 @@ const unsigned char MAX_OPEN_FILES = 8;
 /// This enables the dynamic loader to load elf programs, the extended system
 /// call service and, if the hardware supports it, the MPU to provide memory
 /// isolation of processes
-//#define WITH_PROCESSES
+// #define WITH_PROCESSES
 
 #if defined(WITH_PROCESSES) && defined(__NO_EXCEPTIONS)
 #error Processes require C++ exception support
@@ -145,7 +145,7 @@ const unsigned char MAX_OPEN_FILES = 8;
 /// \def WITH_DEEP_SLEEP
 /// Adds interfaces and required variables to support deep sleep state switch
 /// automatically when peripherals are not required
-//#define WITH_DEEP_SLEEP
+// #define WITH_DEEP_SLEEP
 
 /**
  * \def JTAG_DISABLE_SLEEP
diff --git a/src/bsps/stm32f767zi_lyra_biscotto/interfaces-impl/bsp.cpp b/src/bsps/stm32f767zi_lyra_biscotto/interfaces-impl/bsp.cpp
index 133580cc10b6a8f6e9f92f9d20082a3fe40930ce..2ffa98323ed6fab50c59e9dc46f54c2bceaf4b05 100644
--- a/src/bsps/stm32f767zi_lyra_biscotto/interfaces-impl/bsp.cpp
+++ b/src/bsps/stm32f767zi_lyra_biscotto/interfaces-impl/bsp.cpp
@@ -255,59 +255,59 @@ void IRQbspInit()
     userLed3::mode(Mode::OUTPUT);
     userLed4::mode(Mode::OUTPUT);
 
-    interfaces::spi1::sck::mode(Mode::ALTERNATE);
     interfaces::spi1::sck::alternateFunction(5);
-    interfaces::spi1::miso::mode(Mode::ALTERNATE);
+    interfaces::spi1::sck::mode(Mode::ALTERNATE);
     interfaces::spi1::miso::alternateFunction(5);
-    interfaces::spi1::mosi::mode(Mode::ALTERNATE);
+    interfaces::spi1::miso::mode(Mode::ALTERNATE);
     interfaces::spi1::mosi::alternateFunction(5);
+    interfaces::spi1::mosi::mode(Mode::ALTERNATE);
 
-    interfaces::spi3::sck::mode(Mode::ALTERNATE);
     interfaces::spi3::sck::alternateFunction(6);
-    interfaces::spi3::miso::mode(Mode::ALTERNATE);
+    interfaces::spi3::sck::mode(Mode::ALTERNATE);
     interfaces::spi3::miso::alternateFunction(6);
-    interfaces::spi3::mosi::mode(Mode::ALTERNATE);
+    interfaces::spi3::miso::mode(Mode::ALTERNATE);
     interfaces::spi3::mosi::alternateFunction(5);
+    interfaces::spi3::mosi::mode(Mode::ALTERNATE);
 
-    interfaces::spi4::sck::mode(Mode::ALTERNATE);
     interfaces::spi4::sck::alternateFunction(5);
-    interfaces::spi4::miso::mode(Mode::ALTERNATE);
+    interfaces::spi4::sck::mode(Mode::ALTERNATE);
     interfaces::spi4::miso::alternateFunction(5);
-    interfaces::spi4::mosi::mode(Mode::ALTERNATE);
+    interfaces::spi4::miso::mode(Mode::ALTERNATE);
     interfaces::spi4::mosi::alternateFunction(5);
+    interfaces::spi4::mosi::mode(Mode::ALTERNATE);
 
-    interfaces::spi6::sck::mode(Mode::ALTERNATE);
     interfaces::spi6::sck::alternateFunction(5);
-    interfaces::spi6::miso::mode(Mode::ALTERNATE);
+    interfaces::spi6::sck::mode(Mode::ALTERNATE);
     interfaces::spi6::miso::alternateFunction(5);
-    interfaces::spi6::mosi::mode(Mode::ALTERNATE);
+    interfaces::spi6::miso::mode(Mode::ALTERNATE);
     interfaces::spi6::mosi::alternateFunction(5);
+    interfaces::spi6::mosi::mode(Mode::ALTERNATE);
 
     // We do not need to setup the miosix usart
 
-    interfaces::uart4::tx::mode(Mode::ALTERNATE);
     interfaces::uart4::tx::alternateFunction(8);
-    interfaces::uart4::rx::mode(Mode::ALTERNATE);
+    interfaces::uart4::tx::mode(Mode::ALTERNATE);
     interfaces::uart4::rx::alternateFunction(8);
+    interfaces::uart4::rx::mode(Mode::ALTERNATE);
 
-    interfaces::i2c1::sda::mode(Mode::ALTERNATE);
     interfaces::i2c1::sda::alternateFunction(4);
-    interfaces::i2c1::scl::mode(Mode::ALTERNATE);
+    interfaces::i2c1::sda::mode(Mode::ALTERNATE);
     interfaces::i2c1::scl::alternateFunction(4);
+    interfaces::i2c1::scl::mode(Mode::ALTERNATE);
 
-    interfaces::can1::tx::mode(Mode::ALTERNATE);
     interfaces::can1::tx::alternateFunction(9);
-    interfaces::can1::rx::mode(Mode::ALTERNATE);
+    interfaces::can1::tx::mode(Mode::ALTERNATE);
     interfaces::can1::rx::alternateFunction(9);
+    interfaces::can1::rx::mode(Mode::ALTERNATE);
 
-    interfaces::timers::tim1ch1::mode(Mode::ALTERNATE);
     interfaces::timers::tim1ch1::alternateFunction(1);
-    interfaces::timers::tim3ch1::mode(Mode::ALTERNATE);
+    interfaces::timers::tim1ch1::mode(Mode::ALTERNATE);
     interfaces::timers::tim3ch1::alternateFunction(2);
-    interfaces::timers::tim4ch2::mode(Mode::ALTERNATE);
+    interfaces::timers::tim3ch1::mode(Mode::ALTERNATE);
     interfaces::timers::tim4ch2::alternateFunction(2);
-    interfaces::timers::tim9ch1::mode(Mode::ALTERNATE);
+    interfaces::timers::tim4ch2::mode(Mode::ALTERNATE);
     interfaces::timers::tim9ch1::alternateFunction(3);
+    interfaces::timers::tim9ch1::mode(Mode::ALTERNATE);
 
     interfaces::adcs::adc12in8::mode(Mode::INPUT_ANALOG);
     interfaces::adcs::adc12in9::mode(Mode::INPUT_ANALOG);
diff --git a/src/bsps/stm32f767zi_lyra_gs/config/miosix_settings.h b/src/bsps/stm32f767zi_lyra_gs/config/miosix_settings.h
index 64b0670cab5f4cdfc3d8e06db7cc06e913deae15..1d02b120519dfa4a8fec6705418221cf4ee433c2 100644
--- a/src/bsps/stm32f767zi_lyra_gs/config/miosix_settings.h
+++ b/src/bsps/stm32f767zi_lyra_gs/config/miosix_settings.h
@@ -27,8 +27,8 @@
 // The PARSING_FROM_IDE is because Netbeans gets confused by this, it is never
 // defined when compiling the code.
 #ifndef PARSING_FROM_IDE
-//#error This error is a reminder that you have not edited miosix_settings.h
-// yet.
+// #error This error is a reminder that you have not edited miosix_settings.h
+//  yet.
 #endif  // PARSING_FROM_IDE
 
 /**
@@ -70,14 +70,14 @@ namespace miosix
 // Uncomment only *one* of those
 
 #define SCHED_TYPE_PRIORITY
-//#define SCHED_TYPE_CONTROL_BASED
-//#define SCHED_TYPE_EDF
+// #define SCHED_TYPE_CONTROL_BASED
+// #define SCHED_TYPE_EDF
 
 /// \def WITH_CPU_TIME_COUNTER
 /// Allows to enable/disable CPUTimeCounter to save code size and remove its
 /// overhead from the scheduling process. By default it is not defined
 /// (CPUTimeCounter is disabled).
-//#define WITH_CPU_TIME_COUNTER
+// #define WITH_CPU_TIME_COUNTER
 
 //
 // Filesystem options
@@ -110,7 +110,7 @@ const unsigned char MAX_OPEN_FILES = 8;
 /// This enables the dynamic loader to load elf programs, the extended system
 /// call service and, if the hardware supports it, the MPU to provide memory
 /// isolation of processes
-//#define WITH_PROCESSES
+// #define WITH_PROCESSES
 
 #if defined(WITH_PROCESSES) && defined(__NO_EXCEPTIONS)
 #error Processes require C++ exception support
@@ -145,7 +145,7 @@ const unsigned char MAX_OPEN_FILES = 8;
 /// \def WITH_DEEP_SLEEP
 /// Adds interfaces and required variables to support deep sleep state switch
 /// automatically when peripherals are not required
-//#define WITH_DEEP_SLEEP
+// #define WITH_DEEP_SLEEP
 
 /**
  * \def JTAG_DISABLE_SLEEP
diff --git a/src/bsps/stm32f767zi_lyra_gs/interfaces-impl/bsp.cpp b/src/bsps/stm32f767zi_lyra_gs/interfaces-impl/bsp.cpp
index 85215a2362d81af757bcc88bbf37a4077f071316..753e2dbeb668643f09ad73a8d4a167b348de60bd 100644
--- a/src/bsps/stm32f767zi_lyra_gs/interfaces-impl/bsp.cpp
+++ b/src/bsps/stm32f767zi_lyra_gs/interfaces-impl/bsp.cpp
@@ -243,53 +243,53 @@ void IRQbspInit()
 
     // Setting AF, mode for interfaces
 
-    interfaces::spi1::sck::mode(Mode::ALTERNATE);
     interfaces::spi1::sck::alternateFunction(5);
-    interfaces::spi1::miso::mode(Mode::ALTERNATE);
+    interfaces::spi1::sck::mode(Mode::ALTERNATE);
     interfaces::spi1::miso::alternateFunction(5);
-    interfaces::spi1::mosi::mode(Mode::ALTERNATE);
+    interfaces::spi1::miso::mode(Mode::ALTERNATE);
     interfaces::spi1::mosi::alternateFunction(5);
+    interfaces::spi1::mosi::mode(Mode::ALTERNATE);
 
-    interfaces::spi2::sck::mode(Mode::ALTERNATE);
     interfaces::spi2::sck::alternateFunction(5);
-    interfaces::spi2::miso::mode(Mode::ALTERNATE);
+    interfaces::spi2::sck::mode(Mode::ALTERNATE);
     interfaces::spi2::miso::alternateFunction(5);
-    interfaces::spi2::mosi::mode(Mode::ALTERNATE);
+    interfaces::spi2::miso::mode(Mode::ALTERNATE);
     interfaces::spi2::mosi::alternateFunction(5);
+    interfaces::spi2::mosi::mode(Mode::ALTERNATE);
 
-    interfaces::spi4::sck::mode(Mode::ALTERNATE);
     interfaces::spi4::sck::alternateFunction(5);
-    interfaces::spi4::miso::mode(Mode::ALTERNATE);
+    interfaces::spi4::sck::mode(Mode::ALTERNATE);
     interfaces::spi4::miso::alternateFunction(5);
-    interfaces::spi4::mosi::mode(Mode::ALTERNATE);
+    interfaces::spi4::miso::mode(Mode::ALTERNATE);
     interfaces::spi4::mosi::alternateFunction(5);
+    interfaces::spi4::mosi::mode(Mode::ALTERNATE);
 
     // We do not need to setup the miosix usart
 
-    interfaces::usart2::tx::mode(Mode::ALTERNATE_PULL_UP);
     interfaces::usart2::tx::alternateFunction(7);
-    interfaces::usart2::rx::mode(Mode::ALTERNATE_OD_PULL_UP);
+    interfaces::usart2::tx::mode(Mode::ALTERNATE_PULL_UP);
     interfaces::usart2::rx::alternateFunction(7);
+    interfaces::usart2::rx::mode(Mode::ALTERNATE_OD_PULL_UP);
 
-    interfaces::uart4::tx::mode(Mode::ALTERNATE);
     interfaces::uart4::tx::alternateFunction(8);
-    interfaces::uart4::rx::mode(Mode::ALTERNATE);
+    interfaces::uart4::tx::mode(Mode::ALTERNATE);
     interfaces::uart4::rx::alternateFunction(8);
+    interfaces::uart4::rx::mode(Mode::ALTERNATE);
 
-    interfaces::timers::tim1ch1::mode(Mode::ALTERNATE);
     interfaces::timers::tim1ch1::alternateFunction(1);
-    // interfaces::timers::tim2ch1::mode(Mode::ALTERNATE);
+    interfaces::timers::tim1ch1::mode(Mode::ALTERNATE);
     // interfaces::timers::tim2ch1::alternateFunction(1);
-    // interfaces::timers::tim2ch4::mode(Mode::ALTERNATE);
+    // interfaces::timers::tim2ch1::mode(Mode::ALTERNATE);
     // interfaces::timers::tim2ch4::alternateFunction(1);
-    interfaces::timers::tim3ch2::mode(Mode::ALTERNATE);
+    // interfaces::timers::tim2ch4::mode(Mode::ALTERNATE);
     interfaces::timers::tim3ch2::alternateFunction(2);
-    interfaces::timers::tim4ch1::mode(Mode::ALTERNATE);
+    interfaces::timers::tim3ch2::mode(Mode::ALTERNATE);
     interfaces::timers::tim4ch1::alternateFunction(2);
-    interfaces::timers::tim8ch1::mode(Mode::ALTERNATE);
+    interfaces::timers::tim4ch1::mode(Mode::ALTERNATE);
     interfaces::timers::tim8ch1::alternateFunction(3);
-    // interfaces::timers::tim10ch1::mode(Mode::ALTERNATE);
+    interfaces::timers::tim8ch1::mode(Mode::ALTERNATE);
     // interfaces::timers::tim10ch1::alternateFunction(3);
+    // interfaces::timers::tim10ch1::mode(Mode::ALTERNATE);
 
     commBox::ledTimY1::mode(Mode::OUTPUT);
     commBox::ledTimY1::low();
diff --git a/src/bsps/stm32f767zi_lyra_motor/config/miosix_settings.h b/src/bsps/stm32f767zi_lyra_motor/config/miosix_settings.h
index 64b0670cab5f4cdfc3d8e06db7cc06e913deae15..1d02b120519dfa4a8fec6705418221cf4ee433c2 100644
--- a/src/bsps/stm32f767zi_lyra_motor/config/miosix_settings.h
+++ b/src/bsps/stm32f767zi_lyra_motor/config/miosix_settings.h
@@ -27,8 +27,8 @@
 // The PARSING_FROM_IDE is because Netbeans gets confused by this, it is never
 // defined when compiling the code.
 #ifndef PARSING_FROM_IDE
-//#error This error is a reminder that you have not edited miosix_settings.h
-// yet.
+// #error This error is a reminder that you have not edited miosix_settings.h
+//  yet.
 #endif  // PARSING_FROM_IDE
 
 /**
@@ -70,14 +70,14 @@ namespace miosix
 // Uncomment only *one* of those
 
 #define SCHED_TYPE_PRIORITY
-//#define SCHED_TYPE_CONTROL_BASED
-//#define SCHED_TYPE_EDF
+// #define SCHED_TYPE_CONTROL_BASED
+// #define SCHED_TYPE_EDF
 
 /// \def WITH_CPU_TIME_COUNTER
 /// Allows to enable/disable CPUTimeCounter to save code size and remove its
 /// overhead from the scheduling process. By default it is not defined
 /// (CPUTimeCounter is disabled).
-//#define WITH_CPU_TIME_COUNTER
+// #define WITH_CPU_TIME_COUNTER
 
 //
 // Filesystem options
@@ -110,7 +110,7 @@ const unsigned char MAX_OPEN_FILES = 8;
 /// This enables the dynamic loader to load elf programs, the extended system
 /// call service and, if the hardware supports it, the MPU to provide memory
 /// isolation of processes
-//#define WITH_PROCESSES
+// #define WITH_PROCESSES
 
 #if defined(WITH_PROCESSES) && defined(__NO_EXCEPTIONS)
 #error Processes require C++ exception support
@@ -145,7 +145,7 @@ const unsigned char MAX_OPEN_FILES = 8;
 /// \def WITH_DEEP_SLEEP
 /// Adds interfaces and required variables to support deep sleep state switch
 /// automatically when peripherals are not required
-//#define WITH_DEEP_SLEEP
+// #define WITH_DEEP_SLEEP
 
 /**
  * \def JTAG_DISABLE_SLEEP
diff --git a/src/bsps/stm32f767zi_lyra_motor/interfaces-impl/bsp.cpp b/src/bsps/stm32f767zi_lyra_motor/interfaces-impl/bsp.cpp
index ab59a46672f48e29b9a2a75b387eaf8fcf49c0a4..d7daea5cd5f99805d7152ef799e9c1dbb88f137b 100644
--- a/src/bsps/stm32f767zi_lyra_motor/interfaces-impl/bsp.cpp
+++ b/src/bsps/stm32f767zi_lyra_motor/interfaces-impl/bsp.cpp
@@ -255,43 +255,43 @@ void IRQbspInit()
     userLed3::mode(Mode::OUTPUT);
     userLed4::mode(Mode::OUTPUT);
 
-    interfaces::spi1::sck::mode(Mode::ALTERNATE);
     interfaces::spi1::sck::alternateFunction(5);
-    interfaces::spi1::miso::mode(Mode::ALTERNATE);
+    interfaces::spi1::sck::mode(Mode::ALTERNATE);
     interfaces::spi1::miso::alternateFunction(5);
-    interfaces::spi1::mosi::mode(Mode::ALTERNATE);
+    interfaces::spi1::miso::mode(Mode::ALTERNATE);
     interfaces::spi1::mosi::alternateFunction(5);
+    interfaces::spi1::mosi::mode(Mode::ALTERNATE);
 
-    interfaces::spi3::sck::mode(Mode::ALTERNATE);
     interfaces::spi3::sck::alternateFunction(6);
-    interfaces::spi3::miso::mode(Mode::ALTERNATE);
+    interfaces::spi3::sck::mode(Mode::ALTERNATE);
     interfaces::spi3::miso::alternateFunction(6);
-    interfaces::spi3::mosi::mode(Mode::ALTERNATE);
+    interfaces::spi3::miso::mode(Mode::ALTERNATE);
     interfaces::spi3::mosi::alternateFunction(5);
+    interfaces::spi3::mosi::mode(Mode::ALTERNATE);
 
-    interfaces::spi4::sck::mode(Mode::ALTERNATE);
     interfaces::spi4::sck::alternateFunction(5);
-    interfaces::spi4::miso::mode(Mode::ALTERNATE);
+    interfaces::spi4::sck::mode(Mode::ALTERNATE);
     interfaces::spi4::miso::alternateFunction(5);
-    interfaces::spi4::mosi::mode(Mode::ALTERNATE);
+    interfaces::spi4::miso::mode(Mode::ALTERNATE);
     interfaces::spi4::mosi::alternateFunction(5);
+    interfaces::spi4::mosi::mode(Mode::ALTERNATE);
 
     // We do not need to setup the miosix usart
 
-    interfaces::uart4::tx::mode(Mode::ALTERNATE);
     interfaces::uart4::tx::alternateFunction(8);
-    interfaces::uart4::rx::mode(Mode::ALTERNATE);
+    interfaces::uart4::tx::mode(Mode::ALTERNATE);
     interfaces::uart4::rx::alternateFunction(8);
+    interfaces::uart4::rx::mode(Mode::ALTERNATE);
 
-    interfaces::can1::tx::mode(Mode::ALTERNATE);
     interfaces::can1::tx::alternateFunction(9);
-    interfaces::can1::rx::mode(Mode::ALTERNATE);
+    interfaces::can1::tx::mode(Mode::ALTERNATE);
     interfaces::can1::rx::alternateFunction(9);
+    interfaces::can1::rx::mode(Mode::ALTERNATE);
 
-    interfaces::timers::tim1ch1::mode(Mode::ALTERNATE);
     interfaces::timers::tim1ch1::alternateFunction(1);
-    interfaces::timers::tim3ch1::mode(Mode::ALTERNATE);
+    interfaces::timers::tim1ch1::mode(Mode::ALTERNATE);
     interfaces::timers::tim3ch1::alternateFunction(2);
+    interfaces::timers::tim3ch1::mode(Mode::ALTERNATE);
 
     interfaces::adcs::adc12in9::mode(Mode::INPUT_ANALOG);
     interfaces::adcs::adc12in14::mode(Mode::INPUT_ANALOG);
diff --git a/src/bsps/stm32f767zi_rig_v2/config/miosix_settings.h b/src/bsps/stm32f767zi_rig_v2/config/miosix_settings.h
index 64b0670cab5f4cdfc3d8e06db7cc06e913deae15..1d02b120519dfa4a8fec6705418221cf4ee433c2 100644
--- a/src/bsps/stm32f767zi_rig_v2/config/miosix_settings.h
+++ b/src/bsps/stm32f767zi_rig_v2/config/miosix_settings.h
@@ -27,8 +27,8 @@
 // The PARSING_FROM_IDE is because Netbeans gets confused by this, it is never
 // defined when compiling the code.
 #ifndef PARSING_FROM_IDE
-//#error This error is a reminder that you have not edited miosix_settings.h
-// yet.
+// #error This error is a reminder that you have not edited miosix_settings.h
+//  yet.
 #endif  // PARSING_FROM_IDE
 
 /**
@@ -70,14 +70,14 @@ namespace miosix
 // Uncomment only *one* of those
 
 #define SCHED_TYPE_PRIORITY
-//#define SCHED_TYPE_CONTROL_BASED
-//#define SCHED_TYPE_EDF
+// #define SCHED_TYPE_CONTROL_BASED
+// #define SCHED_TYPE_EDF
 
 /// \def WITH_CPU_TIME_COUNTER
 /// Allows to enable/disable CPUTimeCounter to save code size and remove its
 /// overhead from the scheduling process. By default it is not defined
 /// (CPUTimeCounter is disabled).
-//#define WITH_CPU_TIME_COUNTER
+// #define WITH_CPU_TIME_COUNTER
 
 //
 // Filesystem options
@@ -110,7 +110,7 @@ const unsigned char MAX_OPEN_FILES = 8;
 /// This enables the dynamic loader to load elf programs, the extended system
 /// call service and, if the hardware supports it, the MPU to provide memory
 /// isolation of processes
-//#define WITH_PROCESSES
+// #define WITH_PROCESSES
 
 #if defined(WITH_PROCESSES) && defined(__NO_EXCEPTIONS)
 #error Processes require C++ exception support
@@ -145,7 +145,7 @@ const unsigned char MAX_OPEN_FILES = 8;
 /// \def WITH_DEEP_SLEEP
 /// Adds interfaces and required variables to support deep sleep state switch
 /// automatically when peripherals are not required
-//#define WITH_DEEP_SLEEP
+// #define WITH_DEEP_SLEEP
 
 /**
  * \def JTAG_DISABLE_SLEEP
diff --git a/src/bsps/stm32f767zi_rig_v2/interfaces-impl/bsp.cpp b/src/bsps/stm32f767zi_rig_v2/interfaces-impl/bsp.cpp
index 0d0c1bcc3323d459c3785a95611c6e82074cc927..f6ddb1f55dfeb2fcf0e2eee501cac3ec49ccedbf 100644
--- a/src/bsps/stm32f767zi_rig_v2/interfaces-impl/bsp.cpp
+++ b/src/bsps/stm32f767zi_rig_v2/interfaces-impl/bsp.cpp
@@ -257,80 +257,80 @@ void IRQbspInit()
     userLed4::mode(Mode::OUTPUT);
 
     // RIG stuff
-    interfaces::spi1::sck::mode(Mode::ALTERNATE);
     interfaces::spi1::sck::alternateFunction(5);
-    interfaces::spi1::miso::mode(Mode::ALTERNATE);
+    interfaces::spi1::sck::mode(Mode::ALTERNATE);
     interfaces::spi1::miso::alternateFunction(5);
-    interfaces::spi1::mosi::mode(Mode::ALTERNATE);
+    interfaces::spi1::miso::mode(Mode::ALTERNATE);
     interfaces::spi1::mosi::alternateFunction(5);
+    interfaces::spi1::mosi::mode(Mode::ALTERNATE);
 
-    interfaces::spi2::sck::mode(Mode::ALTERNATE);
     interfaces::spi2::sck::alternateFunction(5);
-    interfaces::spi2::miso::mode(Mode::ALTERNATE);
+    interfaces::spi2::sck::mode(Mode::ALTERNATE);
     interfaces::spi2::miso::alternateFunction(5);
-    interfaces::spi2::mosi::mode(Mode::ALTERNATE);
+    interfaces::spi2::miso::mode(Mode::ALTERNATE);
     interfaces::spi2::mosi::alternateFunction(5);
+    interfaces::spi2::mosi::mode(Mode::ALTERNATE);
 
-    interfaces::spi3::sck::mode(Mode::ALTERNATE);
     interfaces::spi3::sck::alternateFunction(6);
-    interfaces::spi3::miso::mode(Mode::ALTERNATE);
+    interfaces::spi3::sck::mode(Mode::ALTERNATE);
     interfaces::spi3::miso::alternateFunction(6);
-    interfaces::spi3::mosi::mode(Mode::ALTERNATE);
+    interfaces::spi3::miso::mode(Mode::ALTERNATE);
     interfaces::spi3::mosi::alternateFunction(5);
+    interfaces::spi3::mosi::mode(Mode::ALTERNATE);
 
     /* Do not enable Flavio's bullshit
-    interfaces::spi4::sck::mode(Mode::ALTERNATE);
     interfaces::spi4::sck::alternateFunction(5);
-    interfaces::spi4::miso::mode(Mode::ALTERNATE);
+    interfaces::spi4::sck::mode(Mode::ALTERNATE);
     interfaces::spi4::miso::alternateFunction(5);
-    interfaces::spi4::mosi::mode(Mode::ALTERNATE);
+    interfaces::spi4::miso::mode(Mode::ALTERNATE);
     interfaces::spi4::mosi::alternateFunction(5);
+    interfaces::spi4::mosi::mode(Mode::ALTERNATE);
     */
 
-    interfaces::spi6::sck::mode(Mode::ALTERNATE);
     interfaces::spi6::sck::alternateFunction(5);
-    interfaces::spi6::miso::mode(Mode::ALTERNATE);
+    interfaces::spi6::sck::mode(Mode::ALTERNATE);
     interfaces::spi6::miso::alternateFunction(5);
-    interfaces::spi6::mosi::mode(Mode::ALTERNATE);
+    interfaces::spi6::miso::mode(Mode::ALTERNATE);
     interfaces::spi6::mosi::alternateFunction(5);
+    interfaces::spi6::mosi::mode(Mode::ALTERNATE);
 
     // We do not need to setup the miosix usart
 
-    interfaces::uart4::tx::mode(Mode::ALTERNATE);
     interfaces::uart4::tx::alternateFunction(8);
-    interfaces::uart4::rx::mode(Mode::ALTERNATE);
+    interfaces::uart4::tx::mode(Mode::ALTERNATE);
     interfaces::uart4::rx::alternateFunction(8);
+    interfaces::uart4::rx::mode(Mode::ALTERNATE);
 
-    interfaces::can1::tx::mode(Mode::ALTERNATE);
     interfaces::can1::tx::alternateFunction(9);
-    interfaces::can1::rx::mode(Mode::ALTERNATE);
+    interfaces::can1::tx::mode(Mode::ALTERNATE);
     interfaces::can1::rx::alternateFunction(9);
+    interfaces::can1::rx::mode(Mode::ALTERNATE);
 
-    interfaces::can2::tx::mode(Mode::ALTERNATE);
     interfaces::can2::tx::alternateFunction(9);
-    interfaces::can2::rx::mode(Mode::ALTERNATE);
+    interfaces::can2::tx::mode(Mode::ALTERNATE);
     interfaces::can2::rx::alternateFunction(9);
+    interfaces::can2::rx::mode(Mode::ALTERNATE);
 
-    interfaces::timers::tim1ch1::mode(Mode::ALTERNATE);
     interfaces::timers::tim1ch1::alternateFunction(1);
-    interfaces::timers::tim3ch3::mode(Mode::ALTERNATE);
+    interfaces::timers::tim1ch1::mode(Mode::ALTERNATE);
     interfaces::timers::tim3ch3::alternateFunction(2);
-    interfaces::timers::tim4ch1::mode(Mode::ALTERNATE);
+    interfaces::timers::tim3ch3::mode(Mode::ALTERNATE);
     interfaces::timers::tim4ch1::alternateFunction(2);
-    interfaces::timers::tim5ch3::mode(Mode::ALTERNATE);
+    interfaces::timers::tim4ch1::mode(Mode::ALTERNATE);
     interfaces::timers::tim5ch3::alternateFunction(2);
-    interfaces::timers::tim8ch1::mode(Mode::ALTERNATE);
+    interfaces::timers::tim5ch3::mode(Mode::ALTERNATE);
     interfaces::timers::tim8ch1::alternateFunction(3);
-    interfaces::timers::tim8ch2::mode(Mode::ALTERNATE);
+    interfaces::timers::tim8ch1::mode(Mode::ALTERNATE);
     interfaces::timers::tim8ch2::alternateFunction(3);
-    interfaces::timers::tim9ch2::mode(Mode::ALTERNATE);
+    interfaces::timers::tim8ch2::mode(Mode::ALTERNATE);
     interfaces::timers::tim9ch2::alternateFunction(3);
-    interfaces::timers::tim10ch1::mode(Mode::ALTERNATE);
+    interfaces::timers::tim9ch2::mode(Mode::ALTERNATE);
     interfaces::timers::tim10ch1::alternateFunction(3);
-    interfaces::timers::tim11ch1::mode(Mode::ALTERNATE);
+    interfaces::timers::tim10ch1::mode(Mode::ALTERNATE);
     interfaces::timers::tim11ch1::alternateFunction(3);
-    interfaces::timers::tim12ch2::mode(Mode::ALTERNATE);
+    interfaces::timers::tim11ch1::mode(Mode::ALTERNATE);
     interfaces::timers::tim12ch2::alternateFunction(9);
+    interfaces::timers::tim12ch2::mode(Mode::ALTERNATE);
 
     interfaces::adcs::adc12in9::mode(Mode::INPUT_ANALOG);
     interfaces::adcs::adc123in11::mode(Mode::INPUT_ANALOG);
diff --git a/src/entrypoints/runcam-settings.cpp b/src/entrypoints/runcam-settings.cpp
index d87ac005682aa80bf319a4cec48f8bb96240efca..17ca888b3e437dde47a97fc4dcc7011b244271a0 100644
--- a/src/entrypoints/runcam-settings.cpp
+++ b/src/entrypoints/runcam-settings.cpp
@@ -47,12 +47,12 @@ int main()
     GpioPin tx(GPIOB_BASE, 6);
     GpioPin rx(GPIOB_BASE, 7);
 
-    tx.mode(Mode::ALTERNATE);
-    rx.mode(Mode::ALTERNATE);
-
     tx.alternateFunction(7);
     rx.alternateFunction(7);
 
+    tx.mode(Mode::ALTERNATE);
+    rx.mode(Mode::ALTERNATE);
+
     USART usart1(USART1, 115200);
 
     Runcam test(usart1);
diff --git a/src/tests/drivers/canbus/CanDriver/test-can-2way.cpp b/src/tests/drivers/canbus/CanDriver/test-can-2way.cpp
index 27a5f6190cee47a888abebe4659eb9e7df7fe608..446127e97c32de573c59dc0a2c73d58c6dc8e214 100644
--- a/src/tests/drivers/canbus/CanDriver/test-can-2way.cpp
+++ b/src/tests/drivers/canbus/CanDriver/test-can-2way.cpp
@@ -209,11 +209,12 @@ int main()
         CanRX::mode(Mode::ALTERNATE);
         CanTX::mode(Mode::ALTERNATE);
 #else
+        CanRX::alternateFunction(9);
+        CanTX::alternateFunction(9);
+
         CanRX::mode(Mode::ALTERNATE);
         CanTX::mode(Mode::ALTERNATE);
 
-        CanRX::alternateFunction(9);
-        CanTX::alternateFunction(9);
 #endif
     }
 
diff --git a/src/tests/drivers/canbus/CanDriver/test-can-filters.cpp b/src/tests/drivers/canbus/CanDriver/test-can-filters.cpp
index 3be71dbab2e7be6d5ee44ee0d1297e45c5169356..57f8aed738619a7d59d170731fb7af351d9a2204 100644
--- a/src/tests/drivers/canbus/CanDriver/test-can-filters.cpp
+++ b/src/tests/drivers/canbus/CanDriver/test-can-filters.cpp
@@ -63,11 +63,11 @@ int main()
     {
         miosix::FastInterruptDisableLock dLock;
 
-        CanRX::mode(Mode::ALTERNATE);
-        CanTX::mode(Mode::ALTERNATE);
-
         CanRX::alternateFunction(9);
         CanTX::alternateFunction(9);
+
+        CanRX::mode(Mode::ALTERNATE);
+        CanTX::mode(Mode::ALTERNATE);
     }
 
     CanbusDriver::CanbusConfig cfg;
diff --git a/src/tests/drivers/canbus/CanDriver/test-can-loopback.cpp b/src/tests/drivers/canbus/CanDriver/test-can-loopback.cpp
index f8ae585aa82387c48bc7f7fd2843eb3df54813be..0002deca04b27373cf21ff601e9ff2b450a8921b 100644
--- a/src/tests/drivers/canbus/CanDriver/test-can-loopback.cpp
+++ b/src/tests/drivers/canbus/CanDriver/test-can-loopback.cpp
@@ -91,11 +91,11 @@ int main()
     {
         miosix::FastInterruptDisableLock dLock;
 
-        CanRX::mode(Mode::ALTERNATE);
-        CanTX::mode(Mode::ALTERNATE);
-
         CanRX::alternateFunction(9);
         CanTX::alternateFunction(9);
+
+        CanRX::mode(Mode::ALTERNATE);
+        CanTX::mode(Mode::ALTERNATE);
     }
 
     load.start();
diff --git a/src/tests/drivers/test-dsgamma.cpp b/src/tests/drivers/test-dsgamma.cpp
index e454bb5b028c35e4458450b23c4d0a790017aa51..1637402e6bcbd3e939790dae56476ddf03a0553e 100644
--- a/src/tests/drivers/test-dsgamma.cpp
+++ b/src/tests/drivers/test-dsgamma.cpp
@@ -34,7 +34,7 @@ using miosix::Gpio;
 using miosix::Thread;
 
 // Protocol config
-//#define DATA_LEN 16384
+// #define DATA_LEN 16384
 
 /* DISCOVERY F429I*/
 typedef Gpio<GPIOA_BASE, 0> button;
diff --git a/src/tests/drivers/test-wiz5500.cpp b/src/tests/drivers/test-wiz5500.cpp
index 0fb14ebddece5e0f6abefca82e1ed2420bdf4ffd..e1805e4addc35c8819dfed42e28ad2772574de3d 100644
--- a/src/tests/drivers/test-wiz5500.cpp
+++ b/src/tests/drivers/test-wiz5500.cpp
@@ -45,12 +45,13 @@ SPIBus bus(SPI4);
 
 void setupBoard()
 {
-    sck::mode(Mode::ALTERNATE);
     sck::alternateFunction(5);
-    miso::mode(Mode::ALTERNATE);
+    sck::mode(Mode::ALTERNATE);
     miso::alternateFunction(5);
-    mosi::mode(Mode::ALTERNATE);
+    miso::mode(Mode::ALTERNATE);
     mosi::alternateFunction(5);
+    mosi::mode(Mode::ALTERNATE);
+
     cs::mode(Mode::OUTPUT);
     cs::high();
     intn::mode(Mode::INPUT);
diff --git a/src/tests/drivers/timer/test-counted-pwm.cpp b/src/tests/drivers/timer/test-counted-pwm.cpp
index 1338389edad03bcdff5b168b3da0a1195f7af406..0e95c2cc78a2afdbffa7c48f42388622590e1aaa 100644
--- a/src/tests/drivers/timer/test-counted-pwm.cpp
+++ b/src/tests/drivers/timer/test-counted-pwm.cpp
@@ -39,11 +39,11 @@ typedef Gpio<GPIOD_BASE, 12> tim4ch1;  // AF2
 
 int main()
 {
-    tim3ch1::mode(Mode::ALTERNATE);
     tim3ch1::alternateFunction(2);
+    tim3ch1::mode(Mode::ALTERNATE);
 
-    tim4ch1::mode(Mode::ALTERNATE);
     tim4ch1::alternateFunction(2);
+    tim4ch1::mode(Mode::ALTERNATE);
 
     CountedPWM pwm(
         TIM3, TimerUtils::Channel::CHANNEL_1, TimerUtils::TriggerSource::ITR3,
diff --git a/src/tests/drivers/timer/test-pwm.cpp b/src/tests/drivers/timer/test-pwm.cpp
index b6b3b014d584392b05e470dcbcc1450e58c365b6..ba8d05a27019e39a0585f0fb01c8b51ea7e6b49f 100644
--- a/src/tests/drivers/timer/test-pwm.cpp
+++ b/src/tests/drivers/timer/test-pwm.cpp
@@ -33,14 +33,14 @@ typedef Gpio<GPIOB_BASE, 8> ch4;
 
 int main()
 {
-    ch1::mode(Mode::ALTERNATE);
     ch1::alternateFunction(2);
-    ch2::mode(Mode::ALTERNATE);
+    ch1::mode(Mode::ALTERNATE);
     ch2::alternateFunction(2);
-    ch3::mode(Mode::ALTERNATE);
+    ch2::mode(Mode::ALTERNATE);
     ch3::alternateFunction(2);
-    ch4::mode(Mode::ALTERNATE);
+    ch3::mode(Mode::ALTERNATE);
     ch4::alternateFunction(3);
+    ch4::mode(Mode::ALTERNATE);
 
     PWM pwm(TIM3);
     PWM pwm2(TIM10);
diff --git a/src/tests/drivers/xbee/test-xbee-bidir.cpp b/src/tests/drivers/xbee/test-xbee-bidir.cpp
index 2066c9bd9782600f41d414dcc0808c0812e5689e..0aa00c84ac0035db2411e6328221824be7c89c1a 100644
--- a/src/tests/drivers/xbee/test-xbee-bidir.cpp
+++ b/src/tests/drivers/xbee/test-xbee-bidir.cpp
@@ -103,14 +103,15 @@ void configure()
         FastInterruptDisableLock dLock;
 
         // Set SPI pins to correct alternate mode
-        GpioSck::mode(Mode::ALTERNATE);
-        GpioMiso::mode(Mode::ALTERNATE);
-        GpioMosi::mode(Mode::ALTERNATE);
 
         GpioSck::alternateFunction(5);
         GpioMiso::alternateFunction(5);
         GpioMosi::alternateFunction(5);
 
+        GpioSck::mode(Mode::ALTERNATE);
+        GpioMiso::mode(Mode::ALTERNATE);
+        GpioMosi::mode(Mode::ALTERNATE);
+
         GpioATTN::mode(Mode::INPUT);
 
         GpioLedLog::mode(Mode::OUTPUT);
diff --git a/src/tests/drivers/xbee/test-xbee-gui.cpp b/src/tests/drivers/xbee/test-xbee-gui.cpp
index 7a7309ae904cc7beef2a6ba3fa5239a766641ec8..6b3099ff52659cc4907a063bf263d656c8db2ef3 100644
--- a/src/tests/drivers/xbee/test-xbee-gui.cpp
+++ b/src/tests/drivers/xbee/test-xbee-gui.cpp
@@ -324,14 +324,15 @@ void setupXbee(XbeeConfig config)
 void configure()
 {
     // Set SPI pins to correct alternate mode
-    GpioSck::mode(Mode::ALTERNATE);
-    GpioMiso::mode(Mode::ALTERNATE);
-    GpioMosi::mode(Mode::ALTERNATE);
 
     GpioSck::alternateFunction(5);
     GpioMiso::alternateFunction(5);
     GpioMosi::alternateFunction(5);
 
+    GpioSck::mode(Mode::ALTERNATE);
+    GpioMiso::mode(Mode::ALTERNATE);
+    GpioMosi::mode(Mode::ALTERNATE);
+
     GpioATTN::mode(Mode::INPUT_PULL_UP);
 
     GpioLedLog::mode(Mode::OUTPUT);
diff --git a/src/tests/radio/test-mavlinkdriver.cpp b/src/tests/radio/test-mavlinkdriver.cpp
index 812c1566470528c2554e3d6f5e6552c45f4272c1..86bc11da2a326f03ae799f7e5f8ab8bd3d24a2fb 100644
--- a/src/tests/radio/test-mavlinkdriver.cpp
+++ b/src/tests/radio/test-mavlinkdriver.cpp
@@ -47,10 +47,10 @@ void payloadGenerator();
 
 int main()
 {
-    u2rx::mode(Mode::ALTERNATE);
     u2rx::alternateFunction(7);
-    u2tx::mode(Mode::ALTERNATE);
+    u2rx::mode(Mode::ALTERNATE);
     u2tx::alternateFunction(7);
+    u2tx::mode(Mode::ALTERNATE);
 
     TaskScheduler scheduler;
     scheduler.addTask(payloadGenerator, 2000);
diff --git a/src/tests/sensors/test-l3gd20-fifo.cpp b/src/tests/sensors/test-l3gd20-fifo.cpp
index 2800a87e71fcf97cb8e677028d3544a64cd2f8a0..03d6677eb7a3542c2b6e998a8b93a593504ba733 100644
--- a/src/tests/sensors/test-l3gd20-fifo.cpp
+++ b/src/tests/sensors/test-l3gd20-fifo.cpp
@@ -127,14 +127,14 @@ void __attribute__((used)) EXTI2_IRQHandlerImpl()
 
 void configure()
 {
-    GpioSck::mode(Mode::ALTERNATE);
-    GpioMiso::mode(Mode::ALTERNATE);
-    GpioMosi::mode(Mode::ALTERNATE);
-
     GpioSck::alternateFunction(5);
     GpioMiso::alternateFunction(5);
     GpioMosi::alternateFunction(5);
 
+    GpioSck::mode(Mode::ALTERNATE);
+    GpioMiso::mode(Mode::ALTERNATE);
+    GpioMosi::mode(Mode::ALTERNATE);
+
     // Interrupt
     GpioINT2::mode(Mode::INPUT_PULL_DOWN);
 
diff --git a/src/tests/sensors/test-l3gd20.cpp b/src/tests/sensors/test-l3gd20.cpp
index 8e9dad81fd0f8566194db0f320f3607fe8e9fefa..e9deb8b5cc76fd4595d662543d547d769549c68a 100644
--- a/src/tests/sensors/test-l3gd20.cpp
+++ b/src/tests/sensors/test-l3gd20.cpp
@@ -99,14 +99,14 @@ void __attribute__((used)) EXTI2_IRQHandlerImpl()
 void configure()
 {
     // Set SPI pins to correct alternate mode
-    GpioSck::mode(Mode::ALTERNATE);
-    GpioMiso::mode(Mode::ALTERNATE);
-    GpioMosi::mode(Mode::ALTERNATE);
-
     GpioSck::alternateFunction(5);
     GpioMiso::alternateFunction(5);
     GpioMosi::alternateFunction(5);
 
+    GpioSck::mode(Mode::ALTERNATE);
+    GpioMiso::mode(Mode::ALTERNATE);
+    GpioMosi::mode(Mode::ALTERNATE);
+
     // Setup interrupt pin (sensors pulls INT2 up, so we set it to PULL_DOWN
     // to avoid spurious interrupts)
     GpioINT2::mode(Mode::INPUT_PULL_DOWN);