From c1bfcc275156c61af12f8bd0d29e8037283dec0f Mon Sep 17 00:00:00 2001
From: Davide <davide.mor@skywarder.eu>
Date: Wed, 2 Oct 2024 15:17:04 +0200
Subject: [PATCH] [gs] Added nokia subtarget

---
 .vscode/c_cpp_properties.json                 | 23 +++++++++++++++++++
 CMakeLists.txt                                |  9 +++++++-
 src/boards/Groundstation/Nokia/Hub.cpp        |  3 +--
 .../Groundstation/Nokia/Radio/Radio.cpp       |  2 +-
 .../base-groundstation-entry.cpp              |  6 ++---
 .../nokia-groundstation-entry.cpp             |  3 +--
 6 files changed, 37 insertions(+), 9 deletions(-)

diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json
index 6b8c74e51..dbb48611d 100755
--- a/.vscode/c_cpp_properties.json
+++ b/.vscode/c_cpp_properties.json
@@ -410,6 +410,29 @@
             "cStandard": "c17",
             "intelliSenseMode": "linux-gcc-x64",
             "cppStandard": "c++20"
+        },
+        {
+            "name": "stm32f429zi_skyward_groundstation_v2",
+            "cStandard": "c11",
+            "cppStandard": "c++14",
+            "compilerPath": "/opt/arm-miosix-eabi/bin/arm-miosix-eabi-g++",
+            "defines": [
+                "{defaultDefines}",
+                "_MIOSIX_BOARDNAME=stm32f429zi_skyward_groundstation_v2",
+                "_BOARD_STM32F429ZI_SKYWARD_GS_V2",
+                "_ARCH_CORTEXM4_STM32F4",
+                "STM32F429xx",
+                "HSE_VALUE=8000000",
+                "SYSCLK_FREQ_168MHz=168000000",
+                "__ENABLE_XRAM",
+                "V_DDA_VOLTAGE=3.0f"
+            ],
+            "includePath": [
+                "${defaultIncludePaths}",
+                "${workspaceFolder}/skyward-boardcore/libs/miosix-kernel/miosix/arch/cortexM4_stm32f4/common",
+                "${workspaceFolder}/skyward-boardcore/libs/miosix-kernel/miosix/arch/cortexM4_stm32f4/stm32f429zi_skyward_groundstation_v2",
+                "${workspaceFolder}/skyward-boardcore/libs/miosix-kernel/miosix/config/arch/cortexM4_stm32f4/stm32f429zi_skyward_groundstation_v2"
+            ]
         }
     ],
     "version": 4
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 15113e630..993c16b6b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -96,4 +96,11 @@ add_executable(base-groundstation-entry
     ${GROUNDSTATION_COMMON} ${GROUNDSTATION_BASE}
 )
 target_include_directories(base-groundstation-entry PRIVATE ${OBSW_INCLUDE_DIRS})
-sbs_target(base-groundstation-entry stm32f767zi_gemini_gs)
\ No newline at end of file
+sbs_target(base-groundstation-entry stm32f767zi_gemini_gs)
+
+add_executable(nokia-groundstation-entry 
+    src/entrypoints/Groundstation/nokia-groundstation-entry.cpp 
+    ${GROUNDSTATION_COMMON} ${GROUNDSTATION_NOKIA}
+)
+target_include_directories(nokia-groundstation-entry PRIVATE ${OBSW_INCLUDE_DIRS})
+sbs_target(nokia-groundstation-entry stm32f429zi_skyward_groundstation_v2)
\ No newline at end of file
diff --git a/src/boards/Groundstation/Nokia/Hub.cpp b/src/boards/Groundstation/Nokia/Hub.cpp
index ab06368e1..0a89a8bba 100644
--- a/src/boards/Groundstation/Nokia/Hub.cpp
+++ b/src/boards/Groundstation/Nokia/Hub.cpp
@@ -34,8 +34,7 @@ void Hub::dispatchOutgoingMsg(const mavlink_message_t& msg)
 {
     Radio* radio = ModuleManager::getInstance().get<Radio>();
 
-    if (!radio->sendMsg(msg))
-    {
+    if(!radio->sendMsg(msg)) {
         sendNack(msg);
     }
 }
diff --git a/src/boards/Groundstation/Nokia/Radio/Radio.cpp b/src/boards/Groundstation/Nokia/Radio/Radio.cpp
index 2e27dfac3..8a3911b82 100644
--- a/src/boards/Groundstation/Nokia/Radio/Radio.cpp
+++ b/src/boards/Groundstation/Nokia/Radio/Radio.cpp
@@ -58,7 +58,7 @@ bool Radio::start()
 #error "Backup RF not supported on nokia"
 #else
     std::unique_ptr<SX1278::ISX1278Frontend> frontend =
-        std::make_unique<RA01Frontend>();
+        std::make_unique<Skyward433Frontend>();
 #endif
 
     std::unique_ptr<Boardcore::SX1278Fsk> sx1278 =
diff --git a/src/entrypoints/Groundstation/base-groundstation-entry.cpp b/src/entrypoints/Groundstation/base-groundstation-entry.cpp
index 8afa9771f..dc56725a9 100644
--- a/src/entrypoints/Groundstation/base-groundstation-entry.cpp
+++ b/src/entrypoints/Groundstation/base-groundstation-entry.cpp
@@ -32,11 +32,11 @@ using namespace Groundstation;
 using namespace Boardcore;
 using namespace miosix;
 
-void spinLoop()
+void idleLoop()
 {
     while (1)
     {
-        Thread::sleep(1000);
+        Thread::wait();
     }
 }
 
@@ -130,6 +130,6 @@ int main()
     }
 
     led1On();
-    spinLoop();
+    idleLoop();
     return 0;
 }
\ No newline at end of file
diff --git a/src/entrypoints/Groundstation/nokia-groundstation-entry.cpp b/src/entrypoints/Groundstation/nokia-groundstation-entry.cpp
index da685704b..c33676910 100644
--- a/src/entrypoints/Groundstation/nokia-groundstation-entry.cpp
+++ b/src/entrypoints/Groundstation/nokia-groundstation-entry.cpp
@@ -78,8 +78,7 @@ int main()
         printf("[error] Failed to start radio!\n");
     }
 
-    if (ok)
-    {
+    if(ok) {
         printf("Init complete!\n");
     }
 
-- 
GitLab