From 3beb083d31c4803789f1154c32613ba079f9a5b0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Nicol=C3=B2=20Caruso?= <niccolo.caruso@skywarder.eu>
Date: Wed, 2 Oct 2024 15:17:11 +0200
Subject: [PATCH] [GS] Actuators config and test updated for Lyra

Updated the defines for the Lyra actuators configuration. Also updated the test-actuators include and reintroduced the entry to Cmake.
---
 CMakeLists.txt                                 |  7 +++++++
 .../Automated/Actuators/ActuatorsConfig.h      | 12 ++++++------
 .../Groundstation/Automated/test-actuators.cpp | 18 +++++-------------
 3 files changed, 18 insertions(+), 19 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index e3908bd85..11fdaf4b5 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -86,6 +86,13 @@ add_executable(nokia-groundstation-entry
 target_include_directories(nokia-groundstation-entry PRIVATE ${OBSW_INCLUDE_DIRS})
 sbs_target(nokia-groundstation-entry stm32f429zi_nokia)
 
+add_executable(test-actuators
+    src/entrypoints/Groundstation/Automated/test-actuators.cpp
+    ${LYRA_GS} ${GROUNDSTATION_COMMON}
+)
+target_include_directories(test-actuators PRIVATE ${OBSW_INCLUDE_DIRS})
+sbs_target(test-actuators stm32f767zi_lyra_gs)
+
 add_executable(lyra-gs-entry
     src/entrypoints/Groundstation/lyra-gs-entry.cpp
     ${LYRA_GS} ${GROUNDSTATION_COMMON}
diff --git a/src/boards/Groundstation/Automated/Actuators/ActuatorsConfig.h b/src/boards/Groundstation/Automated/Actuators/ActuatorsConfig.h
index 53438444a..0748ada07 100644
--- a/src/boards/Groundstation/Automated/Actuators/ActuatorsConfig.h
+++ b/src/boards/Groundstation/Automated/Actuators/ActuatorsConfig.h
@@ -56,24 +56,24 @@ namespace StepperSettings
 // TIM4_CH1 PD12 AF2
 //      |
 // TIM8_CH4 PC9  AF3
-static TIM_TypeDef* const SERVO1_PULSE_TIM = TIM3;
-static TIM_TypeDef* const SERVO1_COUNT_TIM = TIM1;
+static TIM_TypeDef* const SERVO1_PULSE_TIM = TIM1;
+static TIM_TypeDef* const SERVO1_COUNT_TIM = TIM3;
 static TIM_TypeDef* const SERVO2_PULSE_TIM = TIM4;
 static TIM_TypeDef* const SERVO2_COUNT_TIM = TIM8;
 
 constexpr Boardcore::TimerUtils::Channel SERVO1_PULSE_CH =
-    Boardcore::TimerUtils::Channel::CHANNEL_2;
+    Boardcore::TimerUtils::Channel::CHANNEL_1;
 constexpr Boardcore::TimerUtils::Channel SERVO1_COUNT_CH =
-    Boardcore::TimerUtils::Channel::CHANNEL_4;
+    Boardcore::TimerUtils::Channel::CHANNEL_2;
 constexpr Boardcore::TimerUtils::Channel SERVO2_PULSE_CH =
     Boardcore::TimerUtils::Channel::CHANNEL_1;
 constexpr Boardcore::TimerUtils::Channel SERVO2_COUNT_CH =
     Boardcore::TimerUtils::Channel::CHANNEL_4;
 
 constexpr Boardcore::TimerUtils::TriggerSource SERVO1_PULSE_ITR =
-    Boardcore::TimerUtils::TriggerSource::ITR0;
-constexpr Boardcore::TimerUtils::TriggerSource SERVO1_COUNT_ITR =
     Boardcore::TimerUtils::TriggerSource::ITR2;
+constexpr Boardcore::TimerUtils::TriggerSource SERVO1_COUNT_ITR =
+    Boardcore::TimerUtils::TriggerSource::ITR0;
 constexpr Boardcore::TimerUtils::TriggerSource SERVO2_PULSE_ITR =
     Boardcore::TimerUtils::TriggerSource::ITR3;
 constexpr Boardcore::TimerUtils::TriggerSource SERVO2_COUNT_ITR =
diff --git a/src/entrypoints/Groundstation/Automated/test-actuators.cpp b/src/entrypoints/Groundstation/Automated/test-actuators.cpp
index 27ee9302b..b013b9410 100644
--- a/src/entrypoints/Groundstation/Automated/test-actuators.cpp
+++ b/src/entrypoints/Groundstation/Automated/test-actuators.cpp
@@ -21,11 +21,10 @@
  */
 
 #include <Groundstation/Automated/Actuators/Actuators.h>
-#include <Groundstation/Automated/Buses.h>
 #include <Groundstation/Automated/Hub.h>
-#include <Groundstation/Automated/Radio/Radio.h>
 #include <Groundstation/Automated/Sensors/Sensors.h>
 #include <Groundstation/Common/Ports/Serial.h>
+#include <Groundstation/LyraGS/Buses.h>
 #include <diagnostic/PrintLogger.h>
 #include <drivers/interrupt/external_interrupts.h>
 #include <miosix.h>
@@ -34,6 +33,7 @@
 
 #define STEPPER_SPEED 0.25
 #define TEST_WAIT 5000
+#define NO_SD_LOGGING
 
 #define START_MODULE(name, lambda)                                  \
     do                                                              \
@@ -55,13 +55,6 @@ using namespace Antennas;
 using namespace Boardcore;
 using namespace miosix;
 
-GpioPin button = GpioPin(GPIOG_BASE, 10);  ///< Emergency stop button
-
-void __attribute__((used)) EXTI10_IRQHandlerImpl()
-{
-    ModuleManager::getInstance().get<Actuators>()->IRQemergencyStop();
-}
-
 void ledWaitLoop(int ms)
 {
     int waited = 0;
@@ -199,12 +192,9 @@ void test6(Actuators *actuators)
 int main()
 {
     ledOff();
-    button.mode(Mode::INPUT);
-    enableExternalInterrupt(button.getPort(), button.getNumber(),
-                            InterruptTrigger::RISING_EDGE);
 
     Hub *hub             = new Hub();
-    Buses *buses         = new Buses();
+    LyraGS::Buses *buses = new LyraGS::Buses();
     Serial *serial       = new Serial();
     Actuators *actuators = new Actuators();
     Sensors *sensors     = new Sensors();
@@ -253,6 +243,8 @@ int main()
 
     LOG_INFO(logger, "Starting tests\n");
 
+    actuators->arm();
+
     test1(actuators);
     test2(actuators);
     test3(actuators);
-- 
GitLab