diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index 1ada274691a4637589ee76449b7d4aed76b64196..176a6fd8cb0ac332487e7479a425a849f6d2f07d 100755 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -16,7 +16,6 @@ "${workspaceFolder}/skyward-boardcore/libs/tscpp", "${workspaceFolder}/skyward-boardcore/src/shared", "${workspaceFolder}/skyward-boardcore/src/tests", - "${workspaceFolder}/src/boards", "${workspaceFolder}/src" ] }, @@ -87,6 +86,30 @@ "${workspaceFolder}/skyward-boardcore/src/bsps/stm32f767zi_compute_unit" ] }, + { + "name": "stm32f429zi_skyward_death_stack_v2", + "cStandard": "c11", + "cppStandard": "c++14", + "compilerPath": "/opt/arm-miosix-eabi/bin/arm-miosix-eabi-g++", + "defines": [ + "{defaultDefines}", + "_MIOSIX_BOARDNAME=stm32f429zi_skyward_death_stack_x", + "_BOARD_STM32F429ZI_SKYWARD_DEATHST_X", + "_BOARD_STM32F429ZI_DEATH_STACK_V2", + "_ARCH_CORTEXM4_STM32F4", + "STM32F429xx", + "HSE_VALUE=8000000", + "SYSCLK_FREQ_168MHz=168000000", + "__ENABLE_XRAM", + "V_DDA_VOLTAGE=3.3f" + ], + "includePath": [ + "${defaultIncludePaths}", + "${workspaceFolder}/skyward-boardcore/libs/miosix-kernel/miosix/arch/cortexM4_stm32f4/common", + "${workspaceFolder}/skyward-boardcore/src/bsps/stm32f429zi_death_stack_v2/config", + "${workspaceFolder}/skyward-boardcore/src/bsps/stm32f429zi_death_stack_v2" + ] + }, { "name": "stm32f767zi_death_stack_v4", "cStandard": "c11", diff --git a/.vscode/settings.json b/.vscode/settings.json index ad3a4cc6e27d76d6fbb77d88dcc67532033ebcfe..8ce097eb1f114745fbb65ea162008ba55ae3a1cb 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -140,6 +140,7 @@ "datasheet", "Davide", "DELS", + "depman", "DGNSS", "digi", "DOUT", diff --git a/CMakeLists.txt b/CMakeLists.txt index 2e28274d6c43e8bb72a37d6435f9592bb23fd2f3..6693d7b26b1d5bea7b405d0a9ac2bb0239d18e54 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -64,6 +64,10 @@ target_include_directories(payload-entry-euroc PRIVATE ${OBSW_INCLUDE_DIRS}) target_compile_definitions(payload-entry-euroc PRIVATE EUROC) sbs_target(payload-entry-euroc stm32f767zi_lyra_biscotto) +add_executable(parafoil-entry src/Parafoil/parafoil-entry.cpp ${PARAFOIL_COMPUTER}) +target_include_directories(parafoil-entry PRIVATE ${OBSW_INCLUDE_DIRS}) +sbs_target(parafoil-entry stm32f429zi_death_stack_v2) + add_executable(motor-entry src/Motor/motor-entry.cpp ${MOTOR_SOURCES}) target_include_directories(motor-entry PRIVATE ${OBSW_INCLUDE_DIRS}) sbs_target(motor-entry stm32f767zi_lyra_motor) diff --git a/cmake/dependencies.cmake b/cmake/dependencies.cmake index 27364e888ef6b87ce7fafb589120f6ef41ea96e8..f2dfc6220d9d5db5a19140f2843e00066b0a506a 100644 --- a/cmake/dependencies.cmake +++ b/cmake/dependencies.cmake @@ -118,3 +118,7 @@ set (LYRA_GS src/Groundstation/Automated/PinHandler/PinHandler.cpp src/Groundstation/LyraGS/Ports/SerialLyraGS.cpp ) + +set(PARAFOIL_COMPUTER + +) \ No newline at end of file diff --git a/src/Parafoil/BoardScheduler.h b/src/Parafoil/BoardScheduler.h new file mode 100644 index 0000000000000000000000000000000000000000..408d758100578da03dfa690f6f2bfd248cd0328a --- /dev/null +++ b/src/Parafoil/BoardScheduler.h @@ -0,0 +1,105 @@ +/* Copyright (c) 2024 Skyward Experimental Rocketry + * Author: Davide Basso + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +#pragma once + +#include <diagnostic/PrintLogger.h> +#include <scheduler/TaskScheduler.h> +#include <utils/DependencyManager/DependencyManager.h> + +namespace Payload +{ + +/** + * @brief The class that manages the task schedulers of the board. + * It takes care of handing out task schedulers to modules. + */ +class BoardScheduler : public Boardcore::Injectable +{ +public: + /** + * @brief Enclosing struct to avoid polluting the BoardScheduler namespace. + */ + struct Priority + { + /** + * @brief Priority levels for the board schedulers. + */ + enum PriorityLevel + { + LOW = miosix::PRIORITY_MAX - 4, + MEDIUM = miosix::PRIORITY_MAX - 3, + HIGH = miosix::PRIORITY_MAX - 2, + CRITICAL = miosix::PRIORITY_MAX - 1, + }; + }; + + /** + * @brief Starts all the schedulers + */ + [[nodiscard]] bool start() + { + if (!critical.start()) + { + LOG_ERR(logger, "Critical priority scheduler failed to start"); + return false; + } + + if (!high.start()) + { + LOG_ERR(logger, "High priority scheduler failed to start"); + return false; + } + + if (!medium.start()) + { + LOG_ERR(logger, "Medium priority scheduler failed to start"); + return false; + } + + if (!low.start()) + { + LOG_ERR(logger, "Low priority scheduler failed to start"); + return false; + } + + started = true; + return true; + } + + /** + * @brief Returns if all the schedulers are up and running + */ + bool isStarted() { return started; } + +private: + Boardcore::TaskScheduler critical{Priority::CRITICAL}; + Boardcore::TaskScheduler high{Priority::HIGH}; + Boardcore::TaskScheduler medium{Priority::MEDIUM}; + Boardcore::TaskScheduler low{Priority::LOW}; + + std::atomic<bool> started{false}; + + Boardcore::PrintLogger logger = + Boardcore::Logging::getLogger("BoardScheduler"); +}; + +} // namespace Payload diff --git a/src/Parafoil/Buses.h b/src/Parafoil/Buses.h new file mode 100644 index 0000000000000000000000000000000000000000..5f264dd239fa39e32059e7c4df856ea2a7ac06ae --- /dev/null +++ b/src/Parafoil/Buses.h @@ -0,0 +1,53 @@ +/* Copyright (c) 2024 Skyward Experimental Rocketry + * Author: Davide Basso + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#pragma once + +#include <drivers/spi/SPIBus.h> +#include <drivers/usart/USART.h> +#include <utils/DependencyManager/DependencyManager.h> + +namespace Parafoil +{ + +/** + * @brief Manages all the buses of the parafoil board. + * It provides access to the buses used by the sensors and other peripherals. + */ +class Buses : public Boardcore::Injectable +{ +public: + Boardcore::USART usart1; + Boardcore::USART usart2; + Boardcore::USART usart3; + Boardcore::USART uart4; + + Boardcore::SPIBus spi1; + Boardcore::SPIBus spi2; + + Buses() + : usart1(USART1, 115200), usart2(USART2, 115200), + usart3(USART3, 115200), uart4(UART4, 115200), spi1(SPI1), spi2(SPI2) + { + } +}; +} // namespace Parafoil diff --git a/src/Parafoil/parafoil-entry.cpp b/src/Parafoil/parafoil-entry.cpp new file mode 100644 index 0000000000000000000000000000000000000000..911a9c80b3658f7d0b458e6b662210fe3590f668 --- /dev/null +++ b/src/Parafoil/parafoil-entry.cpp @@ -0,0 +1,56 @@ +/* Copyright (c) 2024 Skyward Experimental Rocketry + * Author: Davide Basso + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include <Parafoil/Buses.h> +#include <diagnostic/PrintLogger.h> +#include <utils/DependencyManager/DependencyManager.h> + +#include <iostream> + +// Build type string for printing during startup +#if defined(DEBUG) +#define BUILD_TYPE "Debug" +#else +#define BUILD_TYPE "Release" +#endif + +using namespace Boardcore; +using namespace Parafoil; + +int main() +{ + std::cout << "Parafoil Entrypoint " + << "(" << BUILD_TYPE << ")" + << " by Skyward Experimental Rocketry" << std::endl; + + auto logger = Logging::getLogger("Mockup"); + DependencyManager depman{}; + + std::cout << "Instantiating modules" << std::endl; + bool initResult = true; + + // Core components + auto buses = new Buses(); + initResult &= depman.insert(buses); + + return 0; +} \ No newline at end of file