From cc590f3f9eebec85397253b823551c9895aef862 Mon Sep 17 00:00:00 2001 From: giatats <74799007+giatats@users.noreply.github.com> Date: Thu, 2 Nov 2023 15:12:53 +0200 Subject: [PATCH] Revert "remove crossplatform (#1)" This reverts commit b727e69f9e58c5e6a8fd607bc00a5974eefba337. --- .gitmodules | 4 +- CMakeLists.txt | 8 +- conanfile.py | 8 +- inc/FreeRTOSTasks/AmbientTemperatureTask.hpp | 53 - inc/FreeRTOSTasks/CANGatekeeperTask.hpp | 158 --- inc/FreeRTOSTasks/CANTestTask.hpp | 27 - inc/FreeRTOSTasks/MCUTemperatureTask.hpp | 28 - inc/FreeRTOSTasks/Task.hpp | 54 - inc/FreeRTOSTasks/TimeKeepingTask.hpp | 47 - inc/FreeRTOSTasks/UARTGatekeeperTask.hpp | 51 - inc/FreeRTOSTasks/WatchdogTask.hpp | 32 - inc/Helpers/COBS.hpp | 40 - inc/Helpers/FreeRTOSHandlers.hpp | 8 - inc/Platform/CAN/ApplicationLayer.hpp | 214 ---- inc/Platform/CAN/Driver.hpp | 218 ---- inc/Platform/CAN/Frame.hpp | 51 - inc/Platform/CAN/TPMessage.hpp | 52 - inc/Platform/CAN/TPProtocol.hpp | 61 - .../Parameters/AcubeSATParameters.hpp | 1051 ----------------- inc/Platform/Parameters/BootCounter.hpp | 48 - inc/Platform/Parameters/Definitions.hpp | 80 -- inc/Platform/TaskInitialization.hpp | 13 - lib/cobs-c | 1 - src/FreeRTOSTasks/AmbientTemperatureTask.cpp | 35 - src/FreeRTOSTasks/CANGatekeeperTask.cpp | 40 - src/FreeRTOSTasks/CANTestTask.cpp | 15 - src/FreeRTOSTasks/MCUTemperatureTask.cpp | 16 - src/FreeRTOSTasks/TimeKeepingTask.cpp | 46 - src/FreeRTOSTasks/UARTGatekeeperTask.cpp | 23 - src/FreeRTOSTasks/WatchdogTask.cpp | 9 - src/Platform/CAN/ApplicationLayer.cpp | 262 ---- src/Platform/CAN/Driver.cpp | 212 ---- src/Platform/CAN/TPProtocol.cpp | 156 --- src/Platform/Logger.cpp | 78 -- src/Platform/Parameters/BootCounter.cpp | 25 - src/Platform/TaskInitialization.cpp | 15 - src/Platform/TimeGetter.cpp | 10 - src/main.cpp | 4 +- 38 files changed, 12 insertions(+), 3241 deletions(-) delete mode 100644 inc/FreeRTOSTasks/AmbientTemperatureTask.hpp delete mode 100644 inc/FreeRTOSTasks/CANGatekeeperTask.hpp delete mode 100644 inc/FreeRTOSTasks/CANTestTask.hpp delete mode 100644 inc/FreeRTOSTasks/MCUTemperatureTask.hpp delete mode 100644 inc/FreeRTOSTasks/Task.hpp delete mode 100644 inc/FreeRTOSTasks/TimeKeepingTask.hpp delete mode 100644 inc/FreeRTOSTasks/UARTGatekeeperTask.hpp delete mode 100644 inc/FreeRTOSTasks/WatchdogTask.hpp delete mode 100644 inc/Helpers/COBS.hpp delete mode 100644 inc/Helpers/FreeRTOSHandlers.hpp delete mode 100644 inc/Platform/CAN/ApplicationLayer.hpp delete mode 100644 inc/Platform/CAN/Driver.hpp delete mode 100644 inc/Platform/CAN/Frame.hpp delete mode 100644 inc/Platform/CAN/TPMessage.hpp delete mode 100644 inc/Platform/CAN/TPProtocol.hpp delete mode 100644 inc/Platform/Parameters/AcubeSATParameters.hpp delete mode 100644 inc/Platform/Parameters/BootCounter.hpp delete mode 100644 inc/Platform/Parameters/Definitions.hpp delete mode 100644 inc/Platform/TaskInitialization.hpp delete mode 160000 lib/cobs-c delete mode 100644 src/FreeRTOSTasks/AmbientTemperatureTask.cpp delete mode 100644 src/FreeRTOSTasks/CANGatekeeperTask.cpp delete mode 100644 src/FreeRTOSTasks/CANTestTask.cpp delete mode 100644 src/FreeRTOSTasks/MCUTemperatureTask.cpp delete mode 100644 src/FreeRTOSTasks/TimeKeepingTask.cpp delete mode 100644 src/FreeRTOSTasks/UARTGatekeeperTask.cpp delete mode 100644 src/FreeRTOSTasks/WatchdogTask.cpp delete mode 100644 src/Platform/CAN/ApplicationLayer.cpp delete mode 100644 src/Platform/CAN/Driver.cpp delete mode 100644 src/Platform/CAN/TPProtocol.cpp delete mode 100644 src/Platform/Logger.cpp delete mode 100644 src/Platform/Parameters/BootCounter.cpp delete mode 100644 src/Platform/TaskInitialization.cpp delete mode 100644 src/Platform/TimeGetter.cpp diff --git a/.gitmodules b/.gitmodules index b2ace02..7bbed01 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,4 +1,4 @@ [submodule "lib/cobs-c"] - path = lib/cobs-c - url = git@github.com:cmcqueen/cobs-c.git + path = lib/cobs-c + url = git@github.com:cmcqueen/cobs-c.git diff --git a/CMakeLists.txt b/CMakeLists.txt index c4a199f..19e81c0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,7 +17,6 @@ include_directories(inc/Platform) include_directories(inc/FreeRTOSTasks) include_directories(inc/Platform/Parameters) include_directories(inc/Helpers) -include_directories(inc/Platform/CAN) include_directories(src) include_directories(src/config) include_directories(src/config/default) @@ -66,7 +65,8 @@ include_directories(lib/atsam-component-drivers/SMC/inc) include_directories(lib/atsam-component-drivers/MRAM/inc) include_directories(lib/atsam-component-drivers/LCL/inc) include_directories(lib/atsam-component-drivers/NANDFlash/inc) -include_directories(lib/cobs-c/) +include_directories(lib/cross-platform-software) +add_subdirectory(lib/cross-platform-software) file(GLOB_RECURSE DRIVER_SOURCES "lib/atsam-component-drivers/MCP9808/*.cpp" "lib/atsam-component-drivers/LCL/*.cpp" "lib/atsam-component-drivers/NANDFlash/*.cpp") @@ -74,9 +74,9 @@ file(GLOB_RECURSE SOURCES "src/*.c" "src/*.cpp" "lib/SEGGER/RTT/*.c" "AutoGenera file(GLOB_RECURSE FREERTOS_SOURCES "lib/FreeRTOS/*.c") file(GLOB_RECURSE EXTRA_SOURCES "lib/cobs-c/cobs.c" "lib/cobs-c/cobsr.c") -add_executable(${PROJECT_NAME}.elf ${SOURCES} ${LINKER_SCRIPT} ${FREERTOS_SOURCES} ${DRIVER_SOURCES} ${EXTRA_SOURCES}) +add_executable(${PROJECT_NAME}.elf ${SOURCES} ${LINKER_SCRIPT} ${FREERTOS_SOURCES} ${DRIVER_SOURCES}) -target_link_libraries(${PROJECT_NAME}.elf PRIVATE common etl log_common) +target_link_libraries(${PROJECT_NAME}.elf PRIVATE common common_cross etl log_common) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS_INIT} -Wl,-Map=${PROJECT_BINARY_DIR}/${PROJECT_NAME}.map") diff --git a/conanfile.py b/conanfile.py index a2d0d66..b2f0532 100644 --- a/conanfile.py +++ b/conanfile.py @@ -33,10 +33,10 @@ def config_options(self): del self.options.fPIC def source(self): - # git = Git(self) - # git.clone(url="git@gitlab.com:acubesat/obc/cross-platform-software.git", target=join(str(self.source_folder), "lib/cross-platform-software")) - # self.run("cd lib/cross-platform-software && git submodule update --init --recursive") - # self.run("cd lib/cross-platform-software && git checkout campaign-obc") + git = Git(self) + git.clone(url="git@gitlab.com:acubesat/obc/cross-platform-software.git", target=join(str(self.source_folder), "lib/cross-platform-software")) + self.run("cd lib/cross-platform-software && git submodule update --init --recursive") + self.run("cd lib/cross-platform-software && git checkout campaign-obc") git = Git(self) git.clone(url="git@gitlab.com:acubesat/obc/atsam-component-drivers.git", target=join(str(self.source_folder), "lib/atsam-component-drivers")) self.run("cd lib/atsam-component-drivers && git checkout NAND-implementation") diff --git a/inc/FreeRTOSTasks/AmbientTemperatureTask.hpp b/inc/FreeRTOSTasks/AmbientTemperatureTask.hpp deleted file mode 100644 index 3e57237..0000000 --- a/inc/FreeRTOSTasks/AmbientTemperatureTask.hpp +++ /dev/null @@ -1,53 +0,0 @@ -#pragma once - -#include "Task.hpp" -#include "MCP9808.hpp" - -/** - * FreeRTOS task for periodically printing the value of the MCP9808 external temperature sensor. - */ -class AmbientTemperatureTask : public Task { -private: - const uint16_t DelayMs = 1000; - - /** - * Number of sensors on the PCB - */ - static inline constexpr uint8_t NumberOfTemperatureSensors = 2; - - /** - * The I2C addresses of the sensors based on the pin configuration of the physical devices - */ - inline static constexpr etl::array - SensorI2CAddress = {0, 1}; - - /** - * The driver for the MCP9808 temperature sensor - */ - etl::array sensors = {MCP9808(SensorI2CAddress[0]), - MCP9808(SensorI2CAddress[1])}; - - /** - * The value of the temperature, measured in Celsius - */ - etl::array ambientTemperature = {0, 0}; - - const static inline uint16_t TaskStackDepth = 2000; - - StackType_t taskStack[TaskStackDepth]; - -public: - void execute(); - - AmbientTemperatureTask() : Task("ExternalTemperatureSensors") {} - - void createTask() { - taskHandle = xTaskCreateStatic(vClassTask < AmbientTemperatureTask > , this->TaskName, - AmbientTemperatureTask::TaskStackDepth, this, - tskIDLE_PRIORITY + 2, this->taskStack, - &(this->taskBuffer)); - } - -}; - -inline std::optional ambientTemperatureTask; diff --git a/inc/FreeRTOSTasks/CANGatekeeperTask.hpp b/inc/FreeRTOSTasks/CANGatekeeperTask.hpp deleted file mode 100644 index ad1fbe6..0000000 --- a/inc/FreeRTOSTasks/CANGatekeeperTask.hpp +++ /dev/null @@ -1,158 +0,0 @@ -#pragma once - -#include "CAN/ApplicationLayer.hpp" -#include "CAN/Frame.hpp" -#include "Task.hpp" -#include "queue.h" -#include "Peripheral_Definitions.hpp" -#ifdef OBC_EQM_LCL -#include "LCLDefinitions.hpp" -#endif - -/** - * Contains functionality of a Gatekeeper Task for the CAN Bus. It has the sole access to CAN, to avoid any - * deadlocks that might be caused by simultaneous requests of access to the same resource. It works by having anyone - * needing to access CAN, send the data in a queue. Then this task receives queue elements and sends them via CAN. - * - * @example @code - * uint32_t id = 0x4; // Specify the sending Node ID. - * etl::vector data = {0,1,2,3,4,5,6,7}; // Specify an array of data, up to 64 bytes. - * CAN::Frame message = {id, data}; // Create a CAN::Frame object. - * canGatekeeperTask->addToQueue(message); // Add the message to the outgoing queue. - * @endcode - */ -class CANGatekeeperTask : public Task { -private: - /** - * A freeRTOS queue to handle outgoing messages, to keep order in case tasks interrupt each other. - */ - QueueHandle_t outgoingQueue; - - /** - * The variable used to hold the queue's data structure. - */ - static inline StaticQueue_t outgoingQueueBuffer; - - /** - * Storage area given to freeRTOS to manage the queue items. - */ - static inline uint8_t outgoingQueueStorageArea[CAN::FrameQueueSize * sizeof(CAN::Frame)]; - - /** - * A freeRTOS queue to handle incoming frames part of a CAN-TP message, since they need to be parsed as a whole. - */ - QueueHandle_t incomingQueue; - - /** - * The variable used to hold the queue's data structure. - */ - static inline StaticQueue_t incomingQueueBuffer; - - /** - * Storage area given to freeRTOS to manage the queue items. - */ - static inline uint8_t incomingQueueStorageArea[CAN::FrameQueueSize * sizeof(CAN::Frame)]; - - const static inline uint16_t TaskStackDepth = 1300; - - StackType_t taskStack[TaskStackDepth]; - -public: - TickType_t lastTransmissionTime = 0; - - void execute(); - - /** - * The constructor calls the initialize() function of the CAN::Driver. It also initializes the FreeRTOS queues for - * incoming/outgoing messages. - */ - CANGatekeeperTask(); - - /** - * Adds an CAN::Frame to the CAN Gatekeeper's queue. - * - * This function was added as an extra abstraction layer to house the `xQueueSendToBack` function. - * It can be used from anywhere in the code to get access to the CAN queue/CAN Gatekeeper task, without having to - * know the low level details of the queue. - * - * If the queue is full, the message is not added to the queue and an error is logged. - * - * @param message the CAN::Frame to be added in the queue of the CAN Gatekeeper task. - * @param isISR indicating if the message is a response to another CAN Message, thus composed through an ISR - */ - inline void send(const CAN::Frame &message, bool isISR = false) { - BaseType_t status; - - if (isISR) { - BaseType_t taskShouldYield = pdFALSE; - - status = xQueueSendToBackFromISR(outgoingQueue, &message, &taskShouldYield); - - if (taskShouldYield) { - taskYIELD(); - } - } else { - status = xQueueSendToBack(outgoingQueue, &message, 0); - } - - if (status == errQUEUE_FULL) { - LOG_ERROR << "Tried sending CAN Message while outgoing queue is full!"; - } - } - - /** - * Adds a CAN::Frame to the incomingQueue. - * If the queue is full the message is lost. - * - * @note This function is designed to be used from within the ISR of a CAN Message Receipt. Thus, it uses - * freeRTOS's ISR-Specific functions. - * - * @param message The incoming CAN::Frame. - */ - inline void addToIncoming(const CAN::Frame &message) { - BaseType_t taskShouldYield = pdFALSE; - - xQueueSendToBackFromISR(incomingQueue, &message, &taskShouldYield); - - if (taskShouldYield) { - taskYIELD(); - } - } - - /** - * An abstraction layer over the freeRTOS queue API to get the number of messages in the incoming queue. - * @return The number of messages in the queue. - */ - inline uint8_t getIncomingMessagesCount() { - return uxQueueMessagesWaiting(incomingQueue); - } - - /** - * Receives a CAN::Frame from the CAN Gatekeeper's incoming queue. - * - * This function was added as an extra abstraction layer to house the `xQueueReceive` function. - * It can be used from anywhere in the code to get access to the CAN queue/CAN Gatekeeper task, without having to - * know the low level details of the queue. - * - * If the queue is empty, the returned message is empty. - */ - inline CAN::Frame getFromQueue() { - CAN::Frame message; - xQueueReceive(incomingQueue, &message, 0); - return message; - } - - /** - * Deletes all items present in the incoming queue. - */ - void emptyIncomingQueue() { - xQueueReset(incomingQueue); - } - - void createTask() { - xTaskCreateStatic(vClassTask < CANGatekeeperTask > , this->TaskName, CANGatekeeperTask::TaskStackDepth, this, - tskIDLE_PRIORITY + 2, this->taskStack, &(this->taskBuffer)); - } -}; - -inline std::optional canGatekeeperTask; diff --git a/inc/FreeRTOSTasks/CANTestTask.hpp b/inc/FreeRTOSTasks/CANTestTask.hpp deleted file mode 100644 index 39d3f0d..0000000 --- a/inc/FreeRTOSTasks/CANTestTask.hpp +++ /dev/null @@ -1,27 +0,0 @@ -#pragma once - -#include "CAN/Driver.hpp" -#include "Task.hpp" - -class CANTestTask : public Task { -private: - -public: - const static inline uint16_t TaskStackDepth = 2300; - - StackType_t taskStack[TaskStackDepth]; - - void execute(); - - CANTestTask() : Task("CAN Test") {} - - /** - * Create freeRTOS Task - */ - void createTask() { - xTaskCreateStatic(vClassTask < CANTestTask > , this->TaskName, CANTestTask::TaskStackDepth, this, - configMAX_PRIORITIES - 1, this->taskStack, &(this->taskBuffer)); - } -}; - -inline std::optional canTestTask; diff --git a/inc/FreeRTOSTasks/MCUTemperatureTask.hpp b/inc/FreeRTOSTasks/MCUTemperatureTask.hpp deleted file mode 100644 index 5b1dcab..0000000 --- a/inc/FreeRTOSTasks/MCUTemperatureTask.hpp +++ /dev/null @@ -1,28 +0,0 @@ -#pragma once - -#include "Task.hpp" - -/** - * FreeRTOS task for periodically printing the value of the internal temperature sensor. - */ -class MCUTemperatureTask : public Task { -private: - const uint16_t delayMs = 10000; - - const static inline uint16_t TaskStackDepth = 1000; - - StackType_t taskStack[TaskStackDepth]; - -public: - void execute(); - - MCUTemperatureTask() : Task("MCUTemperatureSensor") {} - - void createTask() { - xTaskCreateStatic(vClassTask, this->TaskName, MCUTemperatureTask::TaskStackDepth, this, - tskIDLE_PRIORITY + 2, this->taskStack, &(this->taskBuffer)); - } - -}; - -inline std::optional mcuTemperatureTask; diff --git a/inc/FreeRTOSTasks/Task.hpp b/inc/FreeRTOSTasks/Task.hpp deleted file mode 100644 index 5c5a267..0000000 --- a/inc/FreeRTOSTasks/Task.hpp +++ /dev/null @@ -1,54 +0,0 @@ -#pragma once - -#include "FreeRTOS.h" -#include "task.h" -#include "ServicePool.hpp" -#include "BootCounter.hpp" -#include "definitions.h" -#include "Logger.hpp" -#include "AcubeSATParameters.hpp" -#include "CommonParameters.hpp" -#include "Definitions.hpp" - -/** - * Base class, whose method 'execute' is meant to be inherited by each and every individual FreeRTOS task. - */ -class Task { -public: - /** - * taskBuffer parameter of each FreeRTOS task that holds the new task's data structures - */ - StaticTask_t taskBuffer; - - /** - * A native FreeRTOS task that calls the `->execute()` function of a C++ Task. - * - * Useful for converting between native C-style tasks, and tasks defined as C++ classes. - * - * @tparam T A class with an `execute()` function that represent the state of a FreeRTOS task - * @param pvParameters This argument is passed by FreeRTOS and should contain a pointer to the Task object - */ - template - static void vClassTask(void *pvParameters) { - (static_cast(pvParameters))->execute(); - } - -public: - /** - * Name of each task. - */ - const char *TaskName; - - /** - * Handle of each FreeRTOS task. - */ - TaskHandle_t taskHandle; - - /** - * The stack depth of each FreeRTOS task, defined as the number of words the stack can hold. For example, in an - * architecture with 4 byte stack, assigning 100 to the usStackDepth argument, will allocate 4x100=400 bytes. - */ - const uint16_t TaskStackDepth = 1000; - - Task(const char *TaskName) : TaskName(TaskName) {} -}; diff --git a/inc/FreeRTOSTasks/TimeKeepingTask.hpp b/inc/FreeRTOSTasks/TimeKeepingTask.hpp deleted file mode 100644 index 95d642c..0000000 --- a/inc/FreeRTOSTasks/TimeKeepingTask.hpp +++ /dev/null @@ -1,47 +0,0 @@ -#pragma once - -#include "Task.hpp" - -class TimeKeepingTask : public Task { -private: - const uint16_t DelayMs = 1100; - - const static inline uint16_t TaskStackDepth = 2000; - - StackType_t taskStack[TaskStackDepth]; - -public: - void execute(); - - /** - * Sets the year base, used to acquire the current time from a tm structure. - */ - uint16_t yearBase = 1900; - - /** - * This function sets the epoch time. - * @param dateTime is a tm struct witch keeps the time from MCU. - */ - void setEpoch(tm &dateTime); - - /** - * This function sets the AcubeSAT's time parameters using a tm struct. - * @param dateTime is a tm struct witch keeps the time from MCU. - */ - void setTimePlatformParameters(tm &dateTime); - - /** - * This function prints the on-board time. - */ - void printOnBoardTime(); - - TimeKeepingTask() : Task("Timekeeping") {} - - void createTask() { - xTaskCreateStatic(vClassTask, this->TaskName, TimeKeepingTask::TaskStackDepth, this, - tskIDLE_PRIORITY + 1, this->taskStack, &(this->taskBuffer)); - } - -}; - -inline std::optional timeKeepingTask; diff --git a/inc/FreeRTOSTasks/UARTGatekeeperTask.hpp b/inc/FreeRTOSTasks/UARTGatekeeperTask.hpp deleted file mode 100644 index 1ce6cf7..0000000 --- a/inc/FreeRTOSTasks/UARTGatekeeperTask.hpp +++ /dev/null @@ -1,51 +0,0 @@ -#pragma once - -#include "COBS.hpp" -#include "Task.hpp" -#include "queue.h" -#include "Peripheral_Definitions.hpp" - -/** - * Contains functionality of a Gatekeeper Task for the UART resource. It has the sole access to UART, to avoid any - * deadlocks that might be caused by simultaneous requests of access to the same resource. It works by having anyone - * needing to access UART, send the data in a queue. Then, this task receives queue elements and sends them to UART. - */ -class UARTGatekeeperTask : public Task { -private: - QueueHandle_t xUartQueue; - - StaticQueue_t xStaticQueue; - - uint8_t ucQueueStorageArea[UARTQueueSize * sizeof(etl::string)]; - - const static inline uint16_t TaskStackDepth = 2000; - - StackType_t taskStack[TaskStackDepth]; - -public: - void execute(); - - UARTGatekeeperTask(); - - /** - * Adds an etl::string to the UART Gatekeeper's queue. - * - * This function was added as an extra abstraction layer to house the `xQueueSendToBack` function. - * It can be used from anywhere in the code to get access to the UART queue/UART Gatekeeper task, without having to - * know the low level details of the queue. - * - * If the queue is full, the string is not added to the queue and is lost. - * @param message the etl::string to be added in the queue of the UART Gatekeeper task. - */ - void addToQueue(const etl::string &message) { - xQueueSendToBack(xUartQueue, &message, 0); - } - - void createTask() { - xTaskCreateStatic(vClassTask < UARTGatekeeperTask > , this->TaskName, UARTGatekeeperTask::TaskStackDepth, this, - tskIDLE_PRIORITY + 2, this->taskStack, &(this->taskBuffer)); - } - -}; - -inline std::optional uartGatekeeperTask; diff --git a/inc/FreeRTOSTasks/WatchdogTask.hpp b/inc/FreeRTOSTasks/WatchdogTask.hpp deleted file mode 100644 index 41afe75..0000000 --- a/inc/FreeRTOSTasks/WatchdogTask.hpp +++ /dev/null @@ -1,32 +0,0 @@ -#pragma once - -#include "Task.hpp" - -class WatchdogTask : public Task { -private: - /** - * The delay in milliseconds between each watchdog reset. It is set to 14000ms, since the - * maximum timeout is 16000ms, so the timer needs to clear before the next reset. - * @see config/default/peripheral/wdt.c for the specific configuration. - * Do not change this value, without also modifying the value in Harmony configurator. - */ - const uint16_t WatchdogWindow = 14000; - - const static inline uint16_t TaskStackDepth = 1000; - - StackType_t taskStack[TaskStackDepth]; - -public: - void execute(); - - WatchdogTask() : Task("Watchdog") {} - - void createTask() { - xTaskCreateStatic(vClassTask, this->TaskName, WatchdogTask::TaskStackDepth, this, - tskIDLE_PRIORITY, this->taskStack, &(this->taskBuffer)); - } - -}; - -inline std::optional watchdogTask; - diff --git a/inc/Helpers/COBS.hpp b/inc/Helpers/COBS.hpp deleted file mode 100644 index 1493623..0000000 --- a/inc/Helpers/COBS.hpp +++ /dev/null @@ -1,40 +0,0 @@ -#pragma once - -#include -#include "cobs.h" - -template -etl::string COBSencode(const uint8_t* input, uint16_t length) { - char output[MaxLength]; - - auto cobsOutput = cobs_encode(output, MaxLength, input, length); - - return { output, cobsOutput.out_len }; -} - -template -etl::string COBSencode(const etl::string& input) { - char output[MaxLength]; - - auto cobsOutput = cobs_encode(output, MaxLength, input.data(), input.length()); - - return { output, cobsOutput.out_len }; -} - -template -etl::string COBSdecode(const uint8_t* input, uint16_t length) { - char output[MaxLength]; - - auto cobsOutput = cobs_decode(output, MaxLength, input, length); - - return { output, cobsOutput.out_len }; -} - -template -etl::string COBSdecode(const etl::string& input) { - char output[MaxLength]; - - auto cobsOutput = cobs_decode(output, MaxLength, input.data(), input.length()); - - return { output, cobsOutput.out_len }; -} diff --git a/inc/Helpers/FreeRTOSHandlers.hpp b/inc/Helpers/FreeRTOSHandlers.hpp deleted file mode 100644 index 107e978..0000000 --- a/inc/Helpers/FreeRTOSHandlers.hpp +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once - -#include "FreeRTOS.h" -#include "Logger.hpp" - -extern "C" void vApplicationStackOverflowHook(TaskHandle_t xTask, char *pcTaskName) { - LOG_DEBUG << "Stack overflow on task " << pcTaskName; -} diff --git a/inc/Platform/CAN/ApplicationLayer.hpp b/inc/Platform/CAN/ApplicationLayer.hpp deleted file mode 100644 index 0b33552..0000000 --- a/inc/Platform/CAN/ApplicationLayer.hpp +++ /dev/null @@ -1,214 +0,0 @@ -#pragma once - -#include "Driver.hpp" -#include "etl/map.h" -#include "etl/array.h" -#include "etl/String.hpp" -#include "Frame.hpp" -#include "Logger_Definitions.hpp" -#include "Message.hpp" -#include "Peripheral_Definitions.hpp" -#include "AcubeSATParameters.hpp" -#include "TPMessage.hpp" -#include "Definitions.hpp" - -namespace CAN::Application { - /** - * Entity that maps subsystem names to strings for use in logging functions. - */ - inline etl::map, LogSource::NumberOfLogSources> nodeIdToString = { - {OBC, "OBC"}, - {COMMS, "COMMS"}, - {ADCS, "ADCS"}, - {SU, "SU"}, - {ExternalMCU, "External"} - }; - - /** - * CAN-TP message IDs, as specified in DDJF_OBDH. - */ - enum MessageIDs : uint16_t { - SendParameters = 0x01, - RequestParameters = 0x02, - PerformFunction = 0x03, - EventReport = 0x10, - TMPacket = 0x20, - TCPacket = 0x21, - CCSDSPacket = 0x022, - Ping = 0x30, - Pong = 0x31, - LogMessage = 0x40, - UTCTime = 0x200, - BusSwitchover = 0x400, - Heartbeat = 0x700 - }; - - /** - * Toggles the active CAN Bus. - * @param bus A default argument that uses the currentBus member variable if a value is not provided. - * @return The ID of the bus to be switched to. - */ - CAN::Driver::ActiveBus switchBus(CAN::Driver::ActiveBus newBus); - - /** - * The available Event Report Types, for an Event Report CAN-TP Message. - */ - enum EventReportType : uint8_t { - Informative = 0x0, LowSeverity = 0x1, MediumSeverity = 0x2, HighSeverity = 0x3 - }; - - /** - * The size in bytes for the function ID required in Perform Function Messages. - */ - static constexpr uint8_t FunctionIdSize = 6; - - /** - * Milliseconds per day. - */ - inline constexpr uint64_t millisecondsPerDay = 24 * 60 * 60 * 1000; - - - /** - * Removes the ID of the sender in an incoming CAN Message. - * @param id The ID to be filtered. - * @return The filtered ID. - */ - inline uint32_t filterMessageID(uint32_t id) { - return id & 0x700; - } - - /** - * Adds a Ping message to the outgoing queue, according to DDJF_OBDH. - */ - void sendPingMessage(NodeIDs destinationAddress, bool isMulticast); - - /** - * Adds a Pong message to the outgoing queue, to be sent in response to a Ping message, according to DDJF_OBDH. - */ - void sendPongMessage(); - - /** - * Adds a Heartbeat message to the outgoing queue, to be called periodically, according to DDJF_OBDH. - */ - void sendHeartbeatMessage(); - - /** - * Creates a CAN Bus switchover message to be sent whenever the FDIR responsible determines the bus quality - * is not satisfactory, according to DDJF_OBDH. - */ - void sendBusSwitchoverMessage(); - - /** - * Creates a CAN Bus switchover message to be sent whenever the FDIR responsible determines the bus quality - * is not satisfactory, according to DDJF_OBDH. - * @param newBus The Bus to switch to. - */ - void sendBusSwitchoverMessage(Driver::ActiveBus newBus); - - /** - * Adds a message to the outgoing queue with the current UTC Time, according to DDJF_OBDH. - */ - void sendUTCTimeMessage(); - - /** - * Sends a Send Parameters CAN-TP Message as described in DDJF_OBDH. - * @param destinationAddress The ID of the destination node. - * @param isMulticast Whether the message is to be sent to a multicast group. - * @param parameterIDs The IDs of the parameters to be sent. - */ - void createSendParametersMessage(NodeIDs destinationAddress, bool isMulticast, - const etl::array ¶meterIDs, - bool isISR); - - /** - * Sends a Request Parameters CAN-TP Message as described in DDJF_OBDH. - * @param destinationAddress The ID of the destination node. - * @param isMulticast Whether the message is to be sent to a multicast group. - * @param parameterIDs The IDs of the parameters to be requested. - */ - void createRequestParametersMessage(NodeIDs destinationAddress, bool isMulticast, - const etl::array ¶meterIDs, - bool isISR); - - /** - * Sends a Request Parameters CAN-TP Message as described in DDJF_OBDH. - * @param destinationAddress The ID of the destination node. - * @param isMulticast Whether the message is to be sent to a multicast group. - * @param functionId The ID of the function to be called. - * @param arguments The map containing the arguments of the function to be called. - * @TODO This map should be changed to accommodate arguments of differing types, not just uint64_t - * */ - void createPerformFunctionMessage(NodeIDs destinationAddress, bool isMulticast, - const etl::string &functionId, - const etl::map &arguments, - bool isISR); - - /** - * Sends a Event Report CAN-TP Message as described in DDJF_OBDH. - * @param destinationAddress The ID of the destination node. - * @param isMulticast Whether the message is to be sent to a multicast group. - * @param type The event report type. - * @param eventID The ID of the event. - * @param payload An array of the event data. - */ - void createEventReportMessage(NodeIDs destinationAddress, bool isMulticast, EventReportType type, uint16_t eventID, - const Message &eventData, bool isISR); - - /** - * Creates an ECSS-E-ST-70-41C Services TM/TC packet to be sent. After creation the packet is split into CAN-TP - * Protocol frames to be transmitted. - * @param destinationAddress The ID of the destination node. - * @param isMulticast Whether the message is to be sent to a multicast group. - * @param message An ECSS Message. - */ - void createPacketMessage(NodeIDs destinationAddress, bool isMulticast, const etl::string<128> &incomingMessage, Message::PacketType packetType, bool isISR); - - /** - * Creates a CCSDS packet to be sent. After creation the packet is split into CAN-TP - * Protocol frames to be transmitted. - * @param destinationAddress The ID of the destination node. - * @param isMulticast Whether the message is to be sent to a multicast group. - * @param message An ECSS Message. - */ - void - createCCSDSPacketMessage(NodeIDs destinationAddress, bool isMulticast, const Message &message, bool isISR); - - /** - * Sends a Log CAN-TP Message as described in DDJF_OBDH. - * @param destinationAddress The ID of the destination node. - * @param isMulticast Whether the message is to be sent to a multicast group. - * @param log A LogEntry to be sent. - */ - void createLogMessage(NodeIDs destinationAddress, bool isMulticast, const String &log, - bool isISR); - - /** - * Parses an incoming non-TP frame for the appropriate response. - * @param message The incoming CAN::Frame. - */ - void parseMessage(const CAN::Frame &message); - - /** - * Parses an incoming Send Parameters Message and updates the according parameters - * @param message An incoming TPMessage - */ - void parseSendParametersMessage(TPMessage &message); - - /** - * Parses an incoming Request Parameters Message and sends the according parameters back, if they exist. - * @param message An incoming TPMessage - */ - void parseRequestParametersMessage(TPMessage &message); - - /** - * Parses an incoming TM Packet and logs it. - * @param message An incoming TMPacket - */ - void parseTMMessage(TPMessage &message); - - /** - * Parses an incoming TC Packet and executes it. - * @param message An incoming TCPacket - */ - void parseTCMessage(TPMessage &message); -} diff --git a/inc/Platform/CAN/Driver.hpp b/inc/Platform/CAN/Driver.hpp deleted file mode 100644 index e92763c..0000000 --- a/inc/Platform/CAN/Driver.hpp +++ /dev/null @@ -1,218 +0,0 @@ -#ifndef OBC_SOFTWARE_CANDRIVER_H -#define OBC_SOFTWARE_CANDRIVER_H - -#include -#include "ECSS_Definitions.hpp" -#include "Frame.hpp" -#include "peripheral/mcan/plib_mcan1.h" -#include "peripheral/mcan/plib_mcan0.h" - -namespace CAN { - /** - * A basic driver for the CAN Peripherals of the SAMV71 family of processors. This driver includes encoding/decoding - * functions for the Data Length Code as well as the ID when used in normal addressing mode. There are two interrupt - * callback functions, one for registering a transmission plus logging an error if needed, and one for passing the - * incoming CAN::Frames to the higher level services in the application. This driver handles both peripherals, - * while keeping only one active through a parameter for transmission, and disabling interrupts for receipt. - * - * @note CAN Normal Addressing requires the NodeID to be at most 11 bits long. - * - * @note There are two peripherals for the CAN Bus. The main bus is considered as MCAN1, since that is the one - * available on the development board. - * - * @example @code - * uint32_t id = 0x4; // Specify the sending Node ID. - * etl::vector data = {0,1,2,3,4,5,6,7}; // Specify an array of data, up to 64 bytes. - * CAN::Frame message = {id, data}; // Create a CAN::Frame object. - * CAN::Driver::send(message, Application::Main); // Use the included send function to send a message on the Main bus. - * @endcode - */ - class Driver { - private: - /** - * Buffer that stores a message that is ready to be sent - */ - static inline MCAN_TX_BUFFER txFifo; - - /** - * Buffer that stores a received message that is to be processed. - * In this setup, rxFifo0 is used to store TP Messages that usually span across multiple CAN::Frames - */ - static inline MCAN_RX_BUFFER rxFifo0; - - /** - * Buffer that stores a received message that is to be processed. - * In this setup, rxFifo1 is used to store normal messages that are contained in a single CAN::Frame - */ - static inline MCAN_RX_BUFFER rxFifo1; - - public: - /** - * An area of memory the HAL uses to house incoming/outgoing buffers for the peripheral. - */ - static inline uint8_t mcan0MessageRAM[MCAN0_MESSAGE_RAM_CONFIG_SIZE] __attribute__((aligned (32))) __attribute__((section (".ram_nocache"))); - - /** - * An area of memory the HAL uses to house incoming/outgoing buffers for the peripheral. - */ - static inline uint8_t mcan1MessageRAM[MCAN1_MESSAGE_RAM_CONFIG_SIZE] __attribute__((aligned (32))) __attribute__((section (".ram_nocache"))); - - /** - * Possible states for the peripheral, to be used as arguments in the callback functions. - */ - enum AppStates : uint8_t { - Receive, Transmit, - }; - - /** - * The available buses to use. - */ - enum ActiveBus : uint8_t { - Redundant = 0x0, Main = 0x1 - }; - - /** - * Sets the appropriate interrupt handlers, configures the storage area for incoming/outgoing buffers and - * keeps only a single peripheral's interrupts active. - */ - static void initialize(); - - /** - * Logs a successful CAN Bus transmission. - * It is registered as a callback to be automatically called by Microchip's HAL whenever - * there is a message transmission on TX FIFO. - * - * @param context The state of the peripheral when the function is called. - * The above parameter is a uintptr_t type for compatibility with the HAL, and is casted to APPStates. - */ - static void mcan0TxFifoCallback(uintptr_t context); - - /** - * Initiates a message receipt from the peripheral to the processor. - * It is registered as a callback to be automatically called by Microchip's HAL whenever - * there is a message receipt on RX FIFO 0. - * - * In this setup, messages using the TP Protocol will be moved to RX FIFO 0, requiring further parsing - * using the gatekeeper task. - * - * @param numberOfMessages The number of messages to be received from the peripheral - * @param context The state of the peripheral when the function is called. - * The above parameter is a uintptr_t type for compatibility with the HAL, and is casted to APPStates. - */ - static void mcan0RxFifo0Callback(uint8_t numberOfMessages, uintptr_t context); - - /** - * Initiates a message receipt from the peripheral to the processor. - * It is registered as a callback to be automatically called by Microchip's HAL whenever - * there is a message receipt on RX FIFO 1. - * - * In this setup, all received messages are contained in a single frame and will immediately be processed - * in this callback. - * - * @param numberOfMessages The number of messages to be received from the peripheral - * @param context The state of the peripheral when the function is called. - * The above parameter is a uintptr_t type for compatibility with the HAL, and is casted to APPStates. - */ - static void mcan0RxFifo1Callback(uint8_t numberOfMessages, uintptr_t context); - - /** - * Logs a successful CAN Bus transmission. - * It is registered as a callback to be automatically called by Microchip's HAL whenever - * there is a message transmission on TX FIFO. - * - * @param context The state of the peripheral when the function is called. - * The above parameter is a uintptr_t type for compatibility with the HAL, and is casted to APPStates. - */ - static void mcan1TxFifoCallback(uintptr_t context); - - /** - * Initiates a message receipt from the peripheral to the processor. - * It is registered as a callback to be automatically called by Microchip's HAL whenever - * there is a message receipt on RX FIFO 0. - * - * In this setup, messages using the TP Protocol will be moved to RX FIFO 0, requiring further parsing - * using the gatekeeper task. - * - * @param numberOfMessages The number of messages to be received from the peripheral - * @param context The state of the peripheral when the function is called. - * The above parameter is a uintptr_t type for compatibility with the HAL, and is casted to APPStates. - */ - static void mcan1RxFifo0Callback(uint8_t numberOfMessages, uintptr_t context); - - /** - * Initiates a message receipt from the peripheral to the processor. - * It is registered as a callback to be automatically called by Microchip's HAL whenever - * there is a message receipt on RX FIFO 1. - * - * In this setup, all received messages are contained in a single frame and will immediately be processed - * in this callback. - * - * @param numberOfMessages The number of messages to be received from the peripheral - * @param context The state of the peripheral when the function is called. - * The above parameter is a uintptr_t type for compatibility with the HAL, and is casted to APPStates. - */ - static void mcan1RxFifo1Callback(uint8_t numberOfMessages, uintptr_t context); - - /** - * Logs messages that are in the Rx buffer - * @param rxBuf The RX Buffer that the messages are stored - */ - static void logMessage(const MCAN_RX_BUFFER &rxBuf, ActiveBus incomingBus); - - /** - * Decodes the data length code to get the largest expected size of the message. - * - * @param dlc The data length code - * @return The length of the message in bytes - */ - static uint8_t convertDlcToLength(uint8_t dlc); - - /** - * Encodes the length of the message body to the smallest data length code that it fits in. - * - * @param length The length of the message in bytes - * @return The data length code - */ - static uint8_t convertLengthToDLC(uint8_t length); - - /** - * Transforms a frame ID to conform to the CAN Standard. - * The implementation shifts non-extended IDs by 18 bits to ease debugging with example projects. - * @param id The ID as specified in the standard. - * @return The ID that's sent over the network. - * - * @note All IDs should be at most 11 bits long as the non-extended ID scheme is used. The function gets/returns - * a 32-bit ID to accomodate the shift. - */ - static inline uint32_t writeId(uint32_t id) { - return id << 18; - } - - /** - * Transforms the ID from the CAN Standard to match a frame ID. - * @param id The ID that was received from the network. - * @return The ID as specified in the standard. - * - * @note All IDs should be at most 11 bits long as the non-extended ID scheme is used. The function gets/returns - * a 32-bit ID to accomodate the shift. - */ - static inline uint32_t readId(uint32_t id) { - return id >> 18; - } - - /** - * Immediately ends a CAN Message - * @param message The message to be sent. - */ - static void send(const CAN::Frame &message); - - /** - * Converts an MCAN_RX_BUFFER object into a CAN::Frame. - * @param rxBuffer The incoming buffer. - * @return A CAN::Frame. - */ - static CAN::Frame getFrame(const MCAN_RX_BUFFER &rxBuffer); - }; -} - -#endif //OBC_SOFTWARE_CANDRIVER_H diff --git a/inc/Platform/CAN/Frame.hpp b/inc/Platform/CAN/Frame.hpp deleted file mode 100644 index e58aa06..0000000 --- a/inc/Platform/CAN/Frame.hpp +++ /dev/null @@ -1,51 +0,0 @@ -#pragma once - -#include "etl/array.h" -#include "Peripheral_Definitions.hpp" - -namespace CAN { - /** - * A CAN::Frame is a single message that is going to be sent over the CAN Bus. It could be part of collection of - * CAN::Frames composing a CAN::TPMessage, a Single Frame TP Message, or a non-TP Message. - * - * It consists of an ID which specifies the message's function, as in DDJF_OBDH + an etl::array that contains the - * message payload. A CAN::Frame is merely a carrier of information and has no functionality. - */ - class Frame { - public: - /** - * The maximum data length that is currently configured in the peripheral. - */ - static constexpr uint8_t MaxDataLength = 64; - - /** - * The right aligned ID of the message to be sent. Since the protocol doesn't make use of extended IDs, - * they should be at most 11 bits long. - * - * @note The ID here must match one of the IDs found in DDJF_OBDH. - */ - uint32_t id = 0; - - /** - * A array containing the message payload. - * - * @note Users should use data.push_back() instead of data[i] while adding items to avoid errors caused by - * copying the array to the gatekeeper queue. - */ - etl::array data = {}; - - Frame() = default; - - Frame(uint32_t id) : id(id) {}; - - Frame(uint32_t id, const etl::array &data) : id(id), data(data) {}; - - /** - * Zeroes out the current frame. Use this if you're using a single static object in a recurring function. - */ - inline void empty() { - id = 0; - data.fill(0); - } - }; -} diff --git a/inc/Platform/CAN/TPMessage.hpp b/inc/Platform/CAN/TPMessage.hpp deleted file mode 100644 index ff3d605..0000000 --- a/inc/Platform/CAN/TPMessage.hpp +++ /dev/null @@ -1,52 +0,0 @@ -#pragma once - -#include "Message.hpp" - -namespace CAN { - class TPMessage : public Message { - public: - /** - * The ID information of a CAN-TP Message, as specified in DDJF_OBDH. - */ - struct IdInfo { - NodeIDs sourceAddress; - NodeIDs destinationAddress; - bool isMulticast: 1; - }; - - IdInfo idInfo = {}; - - TPMessage() = default; - - TPMessage(IdInfo _idInfo) : idInfo(_idInfo) {}; - - TPMessage(IdInfo _idInfo, bool _isResponse) : idInfo(_idInfo) {}; - - /** - * Decodes the ID of a CAN-TP Message, and sets the idInfo field of the current message. - * @param canID The received ID. - * @return A struct containing the ID information. - */ - [[maybe_unused]] inline IdInfo decodeId(uint32_t canID) { - idInfo.sourceAddress = static_cast((canID >> 4) & 0b111); - idInfo.destinationAddress = static_cast((canID >> 1) & 0b111); - idInfo.isMulticast = canID & 0b1; - - return idInfo; - } - - /** - * Encodes the ID of a CAN-TP Message, using the already set idInfo member. - * @return The encoded ID. - */ - inline uint32_t encodeId() const { - uint16_t id = 0b0111 << 7; - - id |= idInfo.sourceAddress << 4; - id |= idInfo.destinationAddress << 1; - id |= idInfo.isMulticast; - - return id; - } - }; -} diff --git a/inc/Platform/CAN/TPProtocol.hpp b/inc/Platform/CAN/TPProtocol.hpp deleted file mode 100644 index 53cc960..0000000 --- a/inc/Platform/CAN/TPProtocol.hpp +++ /dev/null @@ -1,61 +0,0 @@ -#pragma once - -#include "CAN/ApplicationLayer.hpp" -#include "CAN/Frame.hpp" -#include "CAN/TPMessage.hpp" - -namespace CAN::TPProtocol { - /** - * Types of CAN-TP protocol frames. - */ - enum Frame : uint8_t { - Single = 0x00, First = 0x01, Consecutive = 0x02, Final = 0x03 - }; - - /** - * How many bytes of information are contained in a consecutive frame - */ - static constexpr uint8_t BytesInConsecutiveFrame = 6; - - /** - * A pointer indicating the information starting point. - */ - static constexpr uint8_t BytesStartingPoint = 2; - - /** - * The usable data length for a consecutive message. - */ - static constexpr uint8_t UsableDataLength = CAN::Frame::MaxDataLength - 1; - - /** - * Creates a TPMessage object from a single frame, and passes it over to the parse function. - * @param message A received CAN::Frame. - */ - void processSingleFrame(const CAN::Frame &message); - - /** - * Receives a collection of messages from the Gatekeeper Task's incomingQueue, and processes them. - */ - void processMultipleFrames(); - - /** - * Processes the stored messages received and acts on their content accordingly. - * @param message the complete CAN-TP message. - */ - void parseMessage(TPMessage &message); - - /** - * Splits a CAN-TP Message into a collection of CAN frames according to the TP protocol and adds them to the CAN - * Gatekeeper Task queue. - * For more information about the CAN-TP Protocol check - * https://piembsystech.com/can-tp-protocol/ - * @param message A CAN-TP message. - * @param isISR Whether the function is called from an Interrupt Service Routine. The function is simply passed to - * canGatekeeperTask->send(). - * - * @note For the consecutive frame fill loop idx + 1 is used since the first byte of each frame is already filled, - * however idx only reaches a maximum value of 62 which makes the position in the consecutiveFrame array valid. - * The message.data[] part reaches the maximum index of 62 for the first frame, continues from 63 up to 125 etc. - */ - void createCANTPMessage(const TPMessage &message, bool isISR); -} diff --git a/inc/Platform/Parameters/AcubeSATParameters.hpp b/inc/Platform/Parameters/AcubeSATParameters.hpp deleted file mode 100644 index 4e1b9d0..0000000 --- a/inc/Platform/Parameters/AcubeSATParameters.hpp +++ /dev/null @@ -1,1051 +0,0 @@ -#pragma once - -#include "Helpers/Parameter.hpp" -#include "CAN/Driver.hpp" - -namespace AcubeSATParameters { - /** - * ID enumeration of OBDH subsystem's specific parameters. - */ - enum ParameterID : uint16_t { - OBCUseRTT = 8, - OBCUseUART = 9, - OBCUseCAN = 10, - - /* OBDH Parameters */ - OBCPCBTemperature1 = 5000, - OBCPCBTemperature2 = 5001, - OBCMCUTemperature = 5002, - OBCMCUInputVoltage = 5003, - OBCMCUBootCounter = 5004, - OBCFlashInt = 5005, - OBCSRAMInt = 5006, - OBCAvailableMRAM = 5007, - OBCAvailableNAND = 5008, - OBCSpacecraftTimeRef = 5009, ///< which subsystem holds the correct time - OBCOnBoardTime = 5010, - OBCOperationalMode = 5011, - OBCMemoryPartition = 5012, - OBCReconfigurationTimer = 5013, ///< timer responsible to reset the spacecraft to a known working state unless it has been - ///< reset by a ground station pass. - OBCLastFailedEvent = 5014, - OBCMCUSystick = 5015, - OBCCANBUSLoad1 = 5016, ///< the CAN bus load is based on the used capacity (bandwidth) divided by maximum capacity - OBCCANBUSLoad2 = 5017, - OBCCANBUSActive = 5018, - OBCMCUFDIR = 5019, - OBCMCURestartSafeModeThreshold = 5020, - OBCNANDFLASHLCLThreshold = 5021, - OBCMRAMLCLThreshold = 5022, - OBCNANDFLASHON = 5023, - OBCMRAMON = 5024, - OBCNANDFLASHScrubbingFrequency = 5025, - OBCRAMScrubbingFrequency = 5026, - OBCProgramFlashScrubbingFrequency = 5027, - - /* SU */ - SUPCBTemperature1 = 4000, - SUPCBTemperature2 = 4001, - SUPCBTemperatureControlValves = 4002, - SUPCBTemperatureFlowValves = 4003, - SUPDMSTemperature = 4004, - SUGrowthMediumTemperature = 4005, - SULEDIntensity1 = 4006, - SULEDIntensity2 = 4007, - SULEDIntensity3 = 4008, - SULEDIntensity4 = 4009, - SUPressureLevelSensor1 = 4010, - SUPressureLevelSensor2 = 4011, - SUHumidityLevelSensor1 = 4012, - SUHumidityLevelSensor2 = 4013, - SUNumberOfPhotosTaken = 4014, - SUPumpFlowRate1 = 4015, - SUPumpFlowRate2 = 4016, - SUControlChamberValve1 = 4017, - SUControlChamberValve2 = 4018, - SUControlChamberValve3 = 4019, - SUControlSandwitchValve1 = 4020, - SUControlSandwitchValve2 = 4021, - SUControlSandwitchValve3 = 4022, - SUFlowValveInlet1 = 4023, - SUFlowValveInlet2 = 4024, - SUFlowValveInlet3 = 4025, - SUFlowValveOutlet1 = 4026, - SUFlowValveOutlet2 = 4027, - SUFlowValveOutlet3 = 4028, - SUFlowValveTest1 = 4029, - SUFlowValveTest2 = 4030, - SUPhotoExposureTime = 4031, - SUPhotoInterval = 4032, - SUPhotoCroppedResolution = 4033, - SUPhotoCompressionRate = 4034, - SUExperimentNumber = 4035, - SURADFET = 4036, - SUCameraTemperature = 4037, - SUMCUTemperature = 4038, - SUMCUInputVoltage = 4039, - SUMCUBootCounter = 4040, - SUFlashIntUsedPercentage = 4041, - SUFlashUsedPercentage = 4042, - SUSRAMUsedPercentage = 4043, - SUOnBoardTime = 4044, - SUNANDCurrentlyUsedPartition = 4045, - SULastFailedEvent = 4046, - SUMCUSysTick = 4047, - SUNANDFlashLCLThreshold = 4048, - SUFlowPumpFlashLCLThreshold = 4049, - SUControlPumpFlashLCLThreshold = 4050, - SUCameraLCLThreshold = 4051, - SUNANDFlashLCLOn = 4052, - SUFlowPumpFlashOn = 4053, - SUControlPumpFlashLCLOn = 4054, - SUCameraON = 4055, - SUNANDFlashScrubbingFrequency = 4056, - SURAMScrubbingFrequency = 4057, - SUProgramFlashScrubbingFrequency = 4058, - SUTemperatureFromHumiditySensor1 = 4059, - SUTemperatureFromHumiditySensor2 = 4060, - - - /* ADCS */ - ADCSUseRTT = 11, - ADCSUseUART = 12, - ADCSUseCAN = 13, - - ADCSXBodyFrameRegardingOrbitFrame = 1000, - ADCSYBodyFrameRegardingOrbitFrame = 1001, - ADCSZBodyFrameRegardingOrbitFrame = 1002, - ADCSAngularVelocityOnX = 1003, - ADCSAngularVelocityOnY = 1004, - ADCSAngularVelocityOnZ = 1005, - ADCSBDotXAxis = 1006, - ADCSBDotYAxis = 1007, - ADCSBDotZAxis = 1008, - ADCSQuaternionOrbitFrameToBodyScalar = 1009, - ADCSQuaternionOrbitFrameToBodyVectorElem1 = 1010, - ADCSQuaternionOrbitFrameToBodyVectorElem2 = 1011, - ADCSQuaternionOrbitFrameToBodyVectorElem3 = 1012, - - ADCSMagnetometerRawX = 1013, - ADCSMagnetometerRawY = 1014, - ADCSMagnetometerRawZ = 1015, - ADCSMagnetometerFrequency = 1016, - ADCSMagnetometerCycleCountX = 1017, - ADCSMagnetometerCycleCountY = 1018, - ADCSMagnetometerCycleCountZ = 1019, - ADCSMagnetometerSelfTest = 1020, - - ADCSMagnetometerISISCalibratedXAxis = 1021, - ADCSMagnetometerISISCalibratedYAxis = 1022, - ADCSMagnetometerISISCalibratedZAxis = 1023, - ADCSMagnetometerISISFilteredXAxis = 1024, - ADCSMagnetometerISISFilteredYAxis = 1025, - ADCSMagnetometerISISFilteredZAxis = 1026, - ADCSMagnetometerISISRawXAxis = 1027, - ADCSMagnetometerISISRawYAxis = 1028, - ADCSMagnetometerISISRawZAxis = 1029, - ADCSFineSunSensorRawTopLeft = 1030, - ADCSFineSunSensorRawTopRight = 1031, - ADCSFineSunSensorRawBottomLeft = 1032, - ADCSFineSunSensorRawBottomRight = 1033, - ADCSFineSunSensorFilteredTopLeft = 1034, - ADCSFineSunSensorFilteredTopRight = 1035, - ADCSFineSunSensorFilteredBottomLeft = 1036, - ADCSFineSunSensorFilteredBottomRight = 1037, - ADCSFineSunSensorAngularAlphaAngle = 1038, - ADCSFineSunSensorAngularBetaAngle = 1039, - ADCSFineSunSensorCalculatedX = 1040, - ADCSFineSunSensorCalculatedY = 1041, - ADCSFineSunSensorCalculatedZ = 1042, - - ADCSGyroscopeRateX = 1043, - ADCSGyroscopeRateY = 1044, - ADCSGyroscopeRateZ = 1045, - ADCSGyroXLOCSTRegister = 1046, - ADCSGyroXHICSTRegister = 1047, - ADCSGyroXQUADRegister = 1048, - ADCSGyroXFAULTRegister = 1049, - ADCSGyroYLOCSTRegister = 1050, - ADCSGyroYHICSTRegister = 1051, - ADCSGyroYQUADRegister = 1052, - ADCSGyroYFAULTRegister = 1053, - ADCSGyroZLOCSTRegister = 1054, - ADCSGyroZHICSTRegister = 1055, - ADCSGyroZQUADRegister = 1056, - ADCSGyroZFAULTRegister = 1057, - - ADCSMagnetorquerOnXAxisHBridgePolarity = 1058, - ADCSMagnetorquerOnYAxisHBridgePolarity = 1059, - ADCSMagnetorquerOnZAxisHBridgePolarity = 1060, - ADCSMagnetorquerOnXAxisOnOff = 1061, - ADCSMagnetorquerOnYAxisOnOff = 1062, - ADCSMagnetorquerOnZAxisOnOff = 1063, - ADCSGainBdotXAxis = 1064, - ADCSGainBdotYAxis = 1065, - ADCSGainBdotZAxis = 1066, - ADCSGainProportionalPDXAxis = 1067, - ADCSGainProportionalPDYAxis = 1068, - ADCSGainProportionalPDZAxis = 1069, - ADCSGainDerivativePDXAxis = 1070, - ADCSGainDerivativePDYAxis = 1071, - ADCSGainDerivativePDZAxis = 1072, - ADCSiMQTBoardCoilXTemperatureSensor = 1073, - ADCSiMQTBoardCoilYTemperatureSensor = 1074, - ADCSiMQTBoardCoilZTemperatureSensor = 1075, - ADCSiMQTBoardExtraTemperatureSensor = 1076, - - ADCSGyroscopeXTemperature = 1077, - ADCSGyroscopeYTemperature = 1078, - ADCSGyroscopeZTemperature = 1079, - ADCSBoardTemperature1 = 1080, - ADCSBoardTemperature2 = 1081, - - ADCSMode = 1082, - ADCSTLE = 1083, - ADCSInitialKalmanQuaternionECIFrameToBodyScalar = 1084, - ADCSInitialKalmanQuaternionECIFrameToBodyVectorElem1 = 1085, - ADCSInitialKalmanQuaternionECIFrameToBodyVectorElem2 = 1086, - ADCSInitialKalmanQuaternionECIFrameToBodyVectorElem3 = 1087, - ADCSTLEOrbitalElementsArgumentPerigee = 1088, - ADCSTLEOrbitalElementsRAAN = 1089, - ADCSTLEOrbitalElementsInclination = 1090, - ADCSTLEOrbitalElementsEccentricity = 1091, - ADCSTLEOrbitalElementsMeanAnomaly = 1092, - ADCSSGP4OrbitalElementsArgumentPerigee = 1093, - ADCSSGP4OrbitalElementsRAAN = 1094, - ADCSSGP4OrbitalElementsInclination = 1095, - ADCSSGP4OrbitalElementsMeanAnomaly = 1096, - ADCSTimeGST_JD = 1097, - ADCSDeterminationInitialMatricesQ1 = 1098, - ADCSDeterminationInitialMatricesQ2 = 1099, - ADCSDeterminationInitialMatricesQ3 = 1100, - ADCSDeterminationInitialMatricesQ4 = 1101, - ADCSDeterminationInitialMatricesQ5 = 1102, - ADCSDeterminationInitialMatricesQ6 = 1103, - ADCSDeterminationInitialMatricesQ7 = 1104, - ADCSDeterminationInitialMatricesQ8 = 1105, - ADCSDeterminationInitialMatricesQ9 = 1106, - ADCSDeterminationInitialMatricesQ10 = 1107, - ADCSDeterminationInitialMatricesR1 = 1108, - ADCSDeterminationInitialMatricesR2 = 1109, - ADCSDeterminationInitialMatricesR3 = 1110, - ADCSDeterminationInitialMatricesR4 = 1111, - ADCSDeterminationInitialMatricesR5 = 1112, - ADCSDeterminationInitialMatricesR6 = 1113, - ADCSDeterminationInitialMatricesR7 = 1114, - ADCSDeterminationInitialMatricesR8 = 1115, - ADCSDeterminationInitialMatricesR9 = 1116, - ADCSDeterminationInitialMatricesPInitial1 = 1117, - ADCSDeterminationInitialMatricesPInitial2 = 1118, - ADCSDeterminationInitialMatricesPInitial3 = 1119, - ADCSDeterminationInitialMatricesPInitial4 = 1120, - ADCSDeterminationInitialMatricesPInitial5 = 1121, - ADCSDeterminationInitialMatricesPInitial6 = 1122, - ADCSDeterminationInitialMatricesPInitial7 = 1123, - ADCSDeterminationInitialMatricesPInitial8 = 1124, - ADCSDeterminationInitialMatricesPInitial9 = 1125, - ADCSDeterminationInitialMatricesPInitial10 = 1126, - ADCSReactionWheelOn = 1127, - ADCSReactionWheelAngularVelocity = 1128, - ADCSMagnetorquerAxisAssignment = 1129, - ADCSControlProfileSwitching = 1130, - ADCSTransformationAxisXAssignment = 1131, - ADCSTransformationAxisYAssignment = 1132, - ADCSTransformationAxisZAssignment = 1133, - ADCSMagnetometerAxisAssignment = 1134, - ADCSSunSensorAxisAssignment = 1135, - ADCSGyroscopeAxisAssignment = 1136, - ADCSFrameAxisSignECIToECEF_X = 1137, - ADCSFrameAxisSignECIToECEF_Y = 1138, - ADCSFrameAxisSignECIToECEF_Z = 1139, - ADCSFrameAxisSignECIToOrbit_X = 1140, - ADCSFrameAxisSignECIToOrbit_Y = 1141, - ADCSFrameAxisSignECIToOrbit_Z = 1142, - ADCSFrameAxisSignNEDToECEF_X = 1143, - ADCSFrameAxisSignNEDToECEF_Y = 1144, - ADCSFrameAxisSignNEDToECEF_Z = 1145, - - ADCSMagnetometerSignX = 1146, - ADCSMagnetometerSignY = 1147, - ADCSMagnetometerSignZ = 1148, - - ADCSSunSensorXAxisSign = 1149, - ADCSSunSensorYAxisSign = 1150, - ADCSSunSensorZAxisSign = 1151, - - ADCSGyroSignX = 1152, - ADCSGyroSignY = 1153, - ADCSGyroSignZ = 1154, - - ADCSDetumblingNominalThresholds = 1155, - ADCSNominalDetumblingThresholds = 1156, - ADCSStandByDetumblingThresholds = 1157, - ADCSDetumblingStandByThresholds = 1158, - ADCSNominalStandByThresholds = 1159, - ADCSMagnetorquerMagneticDipoleX = 1160, - ADCSMagnetorquerMagneticDipoleY = 1161, - ADCSMagnetorquerMagneticDipoleZ = 1162, - ADCSMagnetorquerDutyCycle = 1163, - ADCSMagnetorquerCurrentX = 1164, - ADCSMagnetorquerCurrentY = 1165, - ADCSMagnetorquerCurrentZ = 1166, - ADCSMagnetorquerBDot = 1167, - ADCSReactionWheelTorque = 1168, - ADCSReactionWheelAngularAcceleration = 1169, - ADCSDesiredQuaternionOrbitToBodyScalar = 1170, - ADCSDesiredQuaternionVectorElem1 = 1171, - ADCSDesiredQuaternionVectorElem2 = 1172, - ADCSDesiredQuaternionVectorElem3 = 1173, - ADCSAngularVelocityDesiredX = 1174, - ADCSAngularVelocityDesiredY = 1175, - ADCSAngularVelocityDesiredZ = 1176, - - ADCSGyroBiasX = 1177, - ADCSGyroBiasY = 1178, - ADCSGyroBiasZ = 1179, - - ADCSSatellitePositionLatitude = 1180, - ADCSSatellitePositionLongitude = 1181, - ADCSSatellitePositionHeight = 1182, - ADCSSatellitePositionECIX = 1183, - ADCSSatellitePositionECIY = 1184, - ADCSSatellitePositionECIZ = 1185, - ADCSSatelliteLinearVelocityECIX = 1186, - ADCSSatelliteLinearVelocityECIY = 1187, - ADCSSatelliteLinearVelocityECIZ = 1188, - ADCSMagneticFieldNEDX = 1189, - ADCSMagneticFieldNEDY = 1190, - ADCSMagneticFieldNEDZ = 1191, - ADCSMagneticFieldECIX = 1192, - ADCSMagneticFieldECIY = 1193, - ADCSMagneticFieldECIZ = 1194, - ADCSSunPositionECIX = 1195, - ADCSSunPositionECIY = 1196, - ADCSSunPositionECIZ = 1197, - ADCSEclipse = 1198, - ADCSDesaturationPecentageParameter = 1199, - ADCSISISMTQModes = 1200, - ADCSMagnetorquerActuationMethod = 1201, - ADCSDutyCycleDetermination = 1202, - ADCSDutyCycleControl = 1203, - ADCSDutyCycleOther = 1204, - ADCSDesatInitialAngularVelocityParam = 1205, - - ADCSMCUTemperature = 1206, - - ADCSMCUInputVoltage = 1207, - - ADCSBootCounter = 1208, - ADCSOnBoardTime = 1209, - - ADCSMemoryPartition = 1210, - ADCSLastFailedEvent = 1211, - - ADCSSystick = 1212, - - ADCSRAMScrubbingFrequency = 1213, - ADCSProgramFlashScrubbingFrequency = 1214, - ADCSFLASHInt = 1215, - ADCSSRAMInt = 1216, - - /* EPS Parameters */ - EPSSwitch3V1 = 3000, - EPSSwitch3V2 = 3001, - EPSSwitch3V3 = 3002, - EPSSwitch3V4 = 3003, - EPSSwitch5V1 = 3004, - EPSSwitch5V2 = 3005, - EPSSwitch5V3 = 3006, - EPSSwitch5V4 = 3007, - EPSSwitch1 = 3008, - EPSSwitch2 = 3009, - EPSSwitch3 = 3010, - EPSSwitch4 = 3011, - EPSSwitch5 = 3012, - EPSCurrentForRail3V1 = 3013, - EPSCurrentForRail3V2 = 3014, - EPSCurrentForRail3V3 = 3015, - EPSCurrentForRail3V4 = 3016, - EPSCurrentForRail5V1 = 3017, - EPSCurrentForRail5V2 = 3018, - EPSCurrentForRail5V3 = 3019, - EPSCurrentForRail5V4 = 3020, - EPSCurrentForRail1 = 3021, - EPSCurrentForRail2 = 3022, - EPSCurrentForRail3 = 3023, - EPSCurrentForRail4 = 3024, - EPSCurrentForRail5 = 3025, - EPSVoltageForEachRail3V1 = 3026, - EPSVoltageForEachRail3V2 = 3027, - EPSVoltageForEachRail3V3 = 3028, - EPSVoltageForEachRail3V4 = 3029, - EPSVoltageForEachRail5V1 = 3030, - EPSVoltageForEachRail5V2 = 3031, - EPSVoltageForEachRail5V3 = 3032, - EPSVoltageForEachRail5V4 = 3033, - EPSVoltageForEachRail12V1 = 3034, - EPSVoltageForEachRail12V2 = 3035, - EPSVoltageForEachRail12V3 = 3036, - EPSVoltageForEachRail12V4 = 3037, - EPSPanelVoltageXPlus = 3038, - EPSPanelVoltageXMinus = 3039, - EPSPanelVoltageYPlus = 3040, - EPSPanelVoltageYMinus = 3041, - EPSPanelVoltageZ = 3042, - EPSPanelCurrentXPlus = 3043, - EPSPanelCurrentXMinus = 3044, - EPSPanelCurrentYPlus = 3045, - EPSPanelCurrentYMinus = 3046, - EPSPanelCurrentZ = 3047, - EPSBatteryPackVoltage = 3048, - EPSPanelTemperatureXPlus = 3049, - EPSPanelTemperatureXMinus = 3050, - EPSPanelTemperatureYPlus = 3051, - EPSPanelTemperatureYMinus = 3052, - EPSPanelTemperatureZ = 3053, - EPSPCBTemperatureSensor1 = 3054, - EPSPCBTemperatureSensor2 = 3055, - EPSBatteryTemperatureSensor1 = 3056, - EPSBatteryTemperatureSensor2 = 3057, - - /* COMMS Parameters */ - COMMSUHFBandPATemperature = 2000, - COMMSSBandPATemperature = 2001, - COMMSPCBTemperature = 2002, - COMMSAntennaDeploymentStatus = 2003, - COMMSDataRateUHFTX = 2004, - COMMSDataRateUHFRX = 2005, - COMMSSymbolRateSBand = 2006, - COMMSCWInterval = 2007, - COMMSGMSKBeaconInterval = 2008, - COMMSUHFBandTXPower = 2009, - COMMSSBandTXPower = 2010, - COMMSChannelNumberUHFBand = 2011, - COMMSChannelNumberSBand = 2012, - COMMSLNAGain = 2013, - COMMSPAGainUHFBand = 2014, - COMMSPAGainSBand = 2015, - COMMSVGAGain = 2016, - COMMSRSSI = 2017, - COMMSUHFBandTXOnOff = 2018, - COMMSUHFBandRXOnOff = 2019, - COMMSSBandTXOnOff = 2020, - COMMSPacketsRejectedCOMMS = 2021, - COMMSInvalidHMAC = 2022, - COMMSInvalidPacketStructure = 2023, - COMMSInvalidSpacecraftID = 2024, - COMMSFrameSequenceCounter = 2025, - COMMSPCBTemperature1 = 2026, - COMMSPCBTemperature2 = 2027, - COMMSMCUTemperature = 2028, - COMMSMCUInputVoltage = 2029, - COMMSMCUBootCounter = 2030, - COMMSOnBoardTime = 2031, - COMMSNANDCurrentlyUsedMemoryPartition = 2032, - COMMSLastFailedEvent = 2033, - COMMSMCUSystick = 2034, - COMMSFlashInt = 2035, - COMMSSRAMInt = 2036 - }; - - /******************* OBDH ENUMS *******************/ - enum SpacecraftTimeRef : uint8_t { - Spacecraft = 0, - GroundStation = 1 - }; - - enum OperationalMode : uint8_t { - CommissioningMode = 0, - NominalMode = 1, - ScienceMode = 2, - SafeMode = 3 - }; - - enum MemoryPartition : uint8_t { - First = 0, - Second = 1 - }; - - enum CANBUSActive : uint8_t { - Main = 0, - Reductant = 1 - }; - - enum MCUFDIR : uint8_t { - OBC = 0, - ADCS = 1 - }; - - /******************* ADCS ENUMS *******************/ - enum ADCSModeOfOperation : uint8_t { - StandByModeADCS = 0, - DetumbingModeADCS = 1, - NominalModeADCS = 2 - }; - - enum AxisAssignment : uint8_t { - Xaxis = 0, - Yaxis = 1, - Zaxis = 2 - }; - - enum MangetorquerDutyCycle : uint8_t { - VeryHigh = 0, - High = 1, - Medium = 2, - Low = 3 - }; - - enum MagnetorquerModes : uint8_t { - Idle = 0, - SelfTest = 1, - Detumbling =2 - }; - - enum MagnetorquerActuationMethod : uint8_t { - Current = 0, - Dipole = 1, - PWM =2 - }; - - /******************* SU ENUMS *******************/ - enum CroppingResolution : uint64_t { - Default = 0 - }; - - enum CompressionRate : uint32_t { - None = 0 - }; - - enum ExprerimentNumber : uint8_t { - FirstExperiment = 0, - SecondExperiment = 1, - ThirdExperiment = 2 - }; - - /******************* COMMS ENUMS *******************/ - enum AntennaDeploymentStatus : uint8_t { - Closed = 0, - OneDoorOpen = 1, - TwoDoorOpen = 2, - ThreeDoorOpen = 3, - FullyDeployed = 4 - }; - - enum SampleRateUHFTX : uint8_t { - Rate = 0 - }; - - enum AntennaGains : uint8_t { - Gain = 0 - }; - - /******************* OBDH PARAMETERS *******************/ - inline Parameter obcUseRTT(true); - inline Parameter obcUseUART(true); - inline Parameter obcUseCAN(false); - - inline Parameter obcPCBTemperature1(0); - inline Parameter obcPCBTemperature2(0); - inline Parameter obcMCUTemperature(0); - inline Parameter obcMCUInputVoltage(0); - - inline Parameter obcMCUBootCounter(0); - inline Parameter obcFlashInt(0); - inline Parameter obcSRAMInt(0); - inline Parameter obcAvailableMRAM(0); - inline Parameter obcAvailableNAND(0); - - inline Parameter obcOnBoardTime(Time::DefaultCUC(0)); - - inline Parameter obcSpacecraftTimeRef(Spacecraft); // enum - inline Parameter obcOperationalMode(NominalMode); // enum - inline Parameter obcMemoryPartition(First); // enum - - inline Parameter obcReconfigurationTimer(0); - inline Parameter obcLastFailedEvent(0); - inline Parameter obcMCUSystick(0); - - inline Parameter obcCANBUSLoad1(0); - inline Parameter obcCANBUSLoad2(0); - - inline Parameter obcCANBUSActive(CAN::Driver::Main); // enum - inline Parameter obcMCUFDIR(OBC); // enum - - inline Parameter obcMCURestartSafeModeThreshold(0); - inline Parameter obcNANDFLASHLCLThreshold(0); - inline Parameter obcMRAMLCLThreshold(0); - inline Parameter obcNANDFLASHON(0); - inline Parameter obcNANDFlashScrubbingFrequency(0); - inline Parameter obcMRAMON(0); - inline Parameter obcRAMScrubbingFrequency(0); - inline Parameter obcProgramFlashScrubbingFrequency(0); - - /******************* SU PARAMETERS *******************/ - // MCU - inline Parameter suMCUBootCounter(0); - inline Parameter suMCUSysTick(0); - - inline Parameter suMCUTemperature(0); - inline Parameter suMCUInputVoltage(0); - - // Memory - inline Parameter suFlashIntUsedPercentage(0); - inline Parameter suFlashUsedPercentage(0); - inline Parameter suSRAMUsedPercentage(0); - - inline Parameter suNANDCurrentlyUsedPartition(First); // enum - inline Parameter suNANDFlashLclOn(0); - inline Parameter suNANDFlashLclThreshold(0); - - inline Parameter suNANDFlashScrubbingFrequency(0); - inline Parameter suRAMScrubbingFrequency(0); - inline Parameter suProgramFlashScrubbingFrequency(0); - - // Components - inline Parameter suControlPumpFlashLclOn(0); - inline Parameter suControlPumpFlashLclThreshold(0); - - inline Parameter suFlowPumpFlashOn(0); - inline Parameter suFlowPumpFlashLclThreshold(0); - - inline Parameter suCameraOn(0); - inline Parameter suCameraLCLThreshold(0); - - // Temperatures - inline Parameter suPCBTemperature1(0); - inline Parameter suPCBTemperature2(0); - - inline Parameter suPCBTemperatureControlValves(0); - inline Parameter suPCBTemperatureFlowValves(0); - - inline Parameter suCameraTemperature(0); - inline Parameter suPDMSTemperature(0); - inline Parameter suGrowthMediumTemperature(0); - - // Sensors - inline Parameter suPressureLevelSensor1(0); - inline Parameter suPressureLevelSensor2(0); - - inline Parameter suHumidityLevelSensor1(0); - inline Parameter suHumidityLevelSensor2(0); - - inline Parameter suRadfet(0); - - // Components - inline Parameter suPumpFlowRate1(0); - inline Parameter suPumpFlowRate2(0); - - inline Parameter suCcontrolChamberValve1(0); - inline Parameter suControlChamberValve2(0); - inline Parameter suControlChamberValve3(0); - - inline Parameter suControlSandwitchValve1(0); - inline Parameter suControlSandwitchValve2(0); - inline Parameter suControlSandwitchValve3(0); - - inline Parameter suFlowValveInlet1(0); - inline Parameter suFlowValveInlet2(0); - inline Parameter suFlowValveInlet3(0); - - inline Parameter suFlowValveOutlet1(0); - inline Parameter suFlowValveOutlet2(0); - inline Parameter suFlowValveOutlet3(0); - - inline Parameter suFlowValveTest1(0); - inline Parameter suFlowValveTest2(0); - - inline Parameter suLEDIntensity1(0); - inline Parameter suLEDIntensity2(0); - inline Parameter suLEDIntensity3(0); - inline Parameter suLEDIntensity4(0); - - // Photos - inline Parameter suNumberOfPhotosTaken(0); - inline Parameter suPhotoExposureTime(0); - inline Parameter suPhotoInterval(0); - inline Parameter suPhotoCroppedResolution(Default); // enum - inline Parameter suPhotoCompressionRate(None); // enum - - // Misc - inline Parameter suExperimentNumber(FirstExperiment); // enum - inline Parameter suOnBoardTime(Time::DefaultCUC(0)); - inline Parameter suLastFailedEvent(0); - - inline Parameter suTemperatureFromHumiditySensor1(0); - inline Parameter suTemperatureFromHumiditySensor2(0); - - /******************* ADCS PARAMETERS *******************/ - inline Parameter adcsUseRTT(false); - inline Parameter adcsUseUART(true); - inline Parameter adcsUseCAN(false); - - inline Parameter adcsXBodyFrameRegardingOrbitFrame(0); - inline Parameter adcsYBodyFrameRegardingOrbitFrame(0); - inline Parameter adcsZBodyFrameRegardingOrbitFrame(0); - inline Parameter adcsAngularVelocityOnX(0); - inline Parameter adcsAngularVelocityOnY(0); - inline Parameter adcsAngularVelocityOnZ(0); - inline Parameter adcsBDotXAxis(0); - inline Parameter adcsBDotYAxis(0); - inline Parameter adcsBDotZAxis(0); - inline Parameter adcsQuaternionOrbitFrameToBodyScalar(0); - inline Parameter adcsQuaternionOrbitFrameToBodyVectorElem1(0); - inline Parameter adcsQuaternionOrbitFrameToBodyVectorElem2(0); - inline Parameter adcsQuaternionOrbitFrameToBodyVectorElem3(0); - - inline Parameter adcsMagnetometerRawX(0); - inline Parameter adcsMagnetometerRawY(0); - inline Parameter adcsMagnetometerRawZ(0); - inline Parameter adcsMagnetometerFrequency(0); - inline Parameter adcsMagnetometerCycleCountX(0); - inline Parameter adcsMagnetometerCycleCountY(0); - inline Parameter adcsMagnetometerCycleCountZ(0); - inline Parameter adcsMagnetometerSelfTest(0); - - inline Parameter adcsMagnetometerISISCalibratedXAxis(0); - inline Parameter adcsMagnetometerISISCalibratedYAxis(0); - inline Parameter adcsMagnetometerISISCalibratedZAxis(0); - inline Parameter adcsMagnetometerISISFilteredXAxis(0); - inline Parameter adcsMagnetometerISISFilteredYAxis(0); - inline Parameter adcsMagnetometerISISFilteredZAxis(0); - inline Parameter adcsMagnetometerISISRawXAxis(0); - inline Parameter adcsMagnetometerISISRawYAxis(0); - inline Parameter adcsMagnetometerISISRawZAxis(0); - - inline Parameter adcsFineSunSensorRawTopLeft(0); - inline Parameter adcsFineSunSensorRawTopRight(0); - inline Parameter adcsFineSunSensorRawBottomLeft(0); - inline Parameter adcsFineSunSensorRawBottomRight(0); - inline Parameter adcsFineSunSensorFilteredTopLeft(0); - inline Parameter adcsFineSunSensorFilteredTopRight(0); - inline Parameter adcsFineSunSensorFilteredBottomLeft(0); - inline Parameter adcsFineSunSensorFilteredBottomRight(0); - inline Parameter adcsFineSunSensorAngularAlphaAngle(0); - inline Parameter adcsFineSunSensorAngularBetaAngle(0); - inline Parameter adcsFineSunSensorCalculatedX(0); - inline Parameter adcsFineSunSensorCalculatedY(0); - inline Parameter adcsFineSunSensorCalculatedZ(0); - - inline Parameter adcsGyroscopeRateX(0); - inline Parameter adcsGyroscopeRateY(0); - inline Parameter adcsGyroscopeRateZ(0); - - inline Parameter adcsGyroXLOCSTRegister(0); - inline Parameter adcsGyroXHICSTRegister(0); - inline Parameter adcsGyroXQUADRegister(0); - inline Parameter adcsGyroXFAULTRegister(0); - - inline Parameter adcsGyroYLOCSTRegister(0); - inline Parameter adcsGyroYHICSTRegister(0); - inline Parameter adcsGyroYQUADRegister(0); - inline Parameter adcsGyroYFAULTRegister(0); - - inline Parameter adcsGyroZLOCSTRegister(0); - inline Parameter adcsGyroZHICSTRegister(0); - inline Parameter adcsGyroZQUADRegister(0); - inline Parameter adcsGyroZFAULTRegister(0); - - inline Parameter adcsMagnetorquerOnXAxisHBridgePolarity(0); - inline Parameter adcsMagnetorquerOnYAxisHBridgePolarity(0); - inline Parameter adcsMagnetorquerOnZAxisHBridgePolarity(0); - inline Parameter adcsMagnetorquerOnXAxisOnOff(0); - inline Parameter adcsMagnetorquerOnYAxisOnOff(0); - inline Parameter adcsMagnetorquerOnZAxisOnOff(0); - - inline Parameter adcsGainBdotXAxis(0); - inline Parameter adcsGainBdotYAxis(0); - inline Parameter adcsGainBdotZAxis(0); - inline Parameter adcsGainProportionalPDXAxis(0); - inline Parameter adcsGainProportionalPDYAxis(0); - inline Parameter adcsGainProportionalPDZAxis(0); - inline Parameter adcsGainDerivativePDXAxis(0); - inline Parameter adcsGainDerivativePDYAxis(0); - inline Parameter adcsGainDerivativePDZAxis(0); - - inline Parameter adcsiMQTBoardCoilXTemperatureSensor(0); - inline Parameter adcsiMQTBoardCoilYTemperatureSensor(0); - inline Parameter adcsiMQTBoardCoilZTemperatureSensor(0); - inline Parameter adcsiMQTBoardExtraTemperatureSensor(0); - - inline Parameter adcsGyroscopeXTemperature(0); - inline Parameter adcsGyroscopeYTemperature(0); - inline Parameter adcsGyroscopeZTemperature(0); - - inline Parameter adcsBoardTemperature1(0); - inline Parameter adcsBoardTemperature2(0); - - inline Parameter adcsMode(StandByModeADCS); // enum - inline Parameter adcsTLE(0); - - inline Parameter adcsInitialKalmanQuaternionECIFrameToBodyScalar(0); - inline Parameter adcsInitialKalmanQuaternionECIFrameToBodyVectorElem1(0); - inline Parameter adcsInitialKalmanQuaternionECIFrameToBodyVectorElem2(0); - inline Parameter adcsInitialKalmanQuaternionECIFrameToBodyVectorElem3(0); - inline Parameter adcsTLEOrbitalElementsArgumentPerigee(0); - inline Parameter adcsTLEOrbitalElementsRAAN(0); - inline Parameter adcsTLEOrbitalElementsInclination(0); - inline Parameter adcsTLEOrbitalElementsEccentricity(0); - inline Parameter adcsTLEOrbitalElementsMeanAnomaly(0); - - inline Parameter adcsSGP4OrbitalElementsArgumentPerigee(0); - inline Parameter adcsSGP4OrbitalElementsRAAN(0); - inline Parameter adcsSGP4OrbitalElementsInclination(0); - inline Parameter adcsSGP4OrbitalElementsMeanAnomaly(0); - inline Parameter adcsTimeGST_JD(0); ///< Greenwich Sidereal Time - - inline Parameter adcsDeterminationInitialMatricesQ1(0); - inline Parameter adcsDeterminationInitialMatricesQ2(0); - inline Parameter adcsDeterminationInitialMatricesQ3(0); - inline Parameter adcsDeterminationInitialMatricesQ4(0); - inline Parameter adcsDeterminationInitialMatricesQ5(0); - inline Parameter adcsDeterminationInitialMatricesQ6(0); - inline Parameter adcsDeterminationInitialMatricesQ7(0); - inline Parameter adcsDeterminationInitialMatricesQ8(0); - inline Parameter adcsDeterminationInitialMatricesQ9(0); - inline Parameter adcsDeterminationInitialMatricesQ10(0); - inline Parameter adcsDeterminationInitialMatricesR1(0); - inline Parameter adcsDeterminationInitialMatricesR2(0); - inline Parameter adcsDeterminationInitialMatricesR3(0); - inline Parameter adcsDeterminationInitialMatricesR4(0); - inline Parameter adcsDeterminationInitialMatricesR5(0); - inline Parameter adcsDeterminationInitialMatricesR6(0); - inline Parameter adcsDeterminationInitialMatricesR7(0); - inline Parameter adcsDeterminationInitialMatricesR8(0); - inline Parameter adcsDeterminationInitialMatricesR9(0); - inline Parameter adcsDeterminationInitialMatricesPInitial1(0); - inline Parameter adcsDeterminationInitialMatricesPInitial2(0); - inline Parameter adcsDeterminationInitialMatricesPInitial3(0); - inline Parameter adcsDeterminationInitialMatricesPInitial4(0); - inline Parameter adcsDeterminationInitialMatricesPInitial5(0); - inline Parameter adcsDeterminationInitialMatricesPInitial6(0); - inline Parameter adcsDeterminationInitialMatricesPInitial7(0); - inline Parameter adcsDeterminationInitialMatricesPInitial8(0); - inline Parameter adcsDeterminationInitialMatricesPInitial9(0); - inline Parameter adcsDeterminationInitialMatricesPInitial10(0); - - inline Parameter adcsReactionWheelOn(0); - inline Parameter adcsReactionWheelAngularVelocity(0); - inline Parameter adcsControlProfileSwitching(0); - - inline Parameter adcsMagnetorquerAxisAssignment(Xaxis); // enum - inline Parameter adcsTransformationAxisXAssignment(Xaxis); // enum - inline Parameter adcsTransformationAxisYAssignment(Xaxis); // enum - inline Parameter adcsTransformationAxisZAssignment(Xaxis); // enum - inline Parameter adcsMagnetometerAxisAssignment(Xaxis); // enum - inline Parameter adcsSunSensorAxisAssignment(Xaxis); // enum - inline Parameter adcsGyroscopeAxisAssignment(Xaxis); // enum - - inline Parameter adcsFrameAxisSignECIToECEF_X(0); - inline Parameter adcsFrameAxisSignECIToECEF_Y(0); - inline Parameter adcsFrameAxisSignECIToECEF_Z(0); - inline Parameter adcsFrameAxisSignECIToOrbit_X(0); - inline Parameter adcsFrameAxisSignECIToOrbit_Y(0); - inline Parameter adcsFrameAxisSignECIToOrbit_Z(0); - inline Parameter adcsFrameAxisSignNEDToECEF_X(0); - inline Parameter adcsFrameAxisSignNEDToECEF_Y(0); - inline Parameter adcsFrameAxisSignNEDToECEF_Z(0); - - inline Parameter adcsMagnetometerSignX(0); - inline Parameter adcsMagnetometerSignY(0); - inline Parameter adcsMagnetometerSignZ(0); - - inline Parameter adcsSunSensorXAxisSign(0); - inline Parameter adcsSunSensorYAxisSign(0); - inline Parameter adcsSunSensorZAxisSign(0); - - inline Parameter adcsGyroSignX(0); - inline Parameter adcsGyroSignY(0); - inline Parameter adcsGyroSignZ(0); - - inline Parameter adcsDetumblingNominalThresholds(0); - inline Parameter adcsNominalDetumblingThresholds(0); - inline Parameter adcsStandByDetumblingThresholds(0); - inline Parameter adcsDetumblingStandByThresholds(0); - inline Parameter adcsNominalStandByThresholds(0); - inline Parameter adcsMagnetorquerMagneticDipoleX(0); - inline Parameter adcsMagnetorquerMagneticDipoleY(0); - inline Parameter adcsMagnetorquerMagneticDipoleZ(0); - - inline Parameter adcsMagnetorquerDutyCycle(Low); // enum - - inline Parameter adcsMagnetorquerCurrentX(0); - inline Parameter adcsMagnetorquerCurrentY(0); - inline Parameter adcsMagnetorquerCurrentZ(0); - - inline Parameter adcsMagnetorquerBDot(0); - inline Parameter adcsReactionWheelTorque(0); - inline Parameter adcsReactionWheelAngularAcceleration(0); - inline Parameter adcsDesiredQuaternionOrbitToBodyScalar(0); - inline Parameter adcsDesiredQuaternionVectorElem1(0); - inline Parameter adcsDesiredQuaternionVectorElem2(0); - inline Parameter adcsDesiredQuaternionVectorElem3(0); - inline Parameter adcsAngularVelocityDesiredX(0); - inline Parameter adcsAngularVelocityDesiredY(0); - inline Parameter adcsAngularVelocityDesiredZ(0); - - inline Parameter adcsGyroBiasX(0); - inline Parameter adcsGyroBiasY(0); - inline Parameter adcsGyroBiasZ(0); - - inline Parameter adcsSatellitePositionLatitude(0); - inline Parameter adcsSatellitePositionLongitude(0); - inline Parameter adcsSatellitePositionHeight(0); - - inline Parameter adcsSatellitePositionECIX(0); - inline Parameter adcsSatellitePositionECIY(0); - inline Parameter adcsSatellitePositionECIZ(0); - inline Parameter adcsSatelliteLinearVelocityECIX(0); - inline Parameter adcsSatelliteLinearVelocityECIY(0); - inline Parameter adcsSatelliteLinearVelocityECIZ(0); - inline Parameter adcsMagneticFieldNEDX(0); - inline Parameter adcsMagneticFieldNEDY(0); - inline Parameter adcsMagneticFieldNEDZ(0); - inline Parameter adcsMagneticFieldECIX(0); - inline Parameter adcsMagneticFieldECIY(0); - inline Parameter adcsMagneticFieldECIZ(0); - inline Parameter adcsSunPositionECIX(0); - inline Parameter adcsSunPositionECIY(0); - inline Parameter adcsSunPositionECIZ(0); - - inline Parameter adcsEclipse(0); - - inline Parameter adcsDesaturationPecentageParameter(0); - - inline Parameter adcsISISMTQModes(Idle); // enum - inline Parameter adcsMagnetorquerActuationMethod(Current); // enum - - inline Parameter adcsDutyCycleDetermination(0); - inline Parameter adcsDutyCycleControl(0); - inline Parameter adcsDutyCycleOther(0); - inline Parameter adcsDesatInitialAngularVelocityParam(0); - - inline Parameter adcsMCUTemperature(0); - inline Parameter adcsMCUInputVoltage(0); - inline Parameter adcsBootCounter(0); - inline Parameter adcsOnBoardTime(Time::DefaultCUC(0)); - inline Parameter adcsMemoryPartition(First); // enum - inline Parameter adcsLastFailedEvent(0); - inline Parameter adcsSystick(0); - inline Parameter adcsRAMScrubbingFrequency(0); - inline Parameter adcsProgramFlashScrubbingFrequency(0); - inline Parameter adcsSRAMInt(0); - inline Parameter adcsFlashInt(0); - - /****************** EPS PARAMETERS *******************/ - inline Parameter epsSwitch3V1(0); - inline Parameter epsSwitch3V2(0); - inline Parameter epsSwitch3V3(0); - inline Parameter epsSwitch3V4(0); - inline Parameter epsSwitch5V1(0); - inline Parameter epsSwitch5V2(0); - inline Parameter epsSwitch5V3(0); - inline Parameter epsSwitch5V4(0); - inline Parameter epsSwitch1(0); - inline Parameter epsSwitch2(0); - inline Parameter epsSwitch3(0); - inline Parameter epsSwitch4(0); - inline Parameter epsSwitch5(0); - - inline Parameter epsCurrentForRail3V1(0); - inline Parameter epsCurrentForRail3V2(0); - inline Parameter epsCurrentForRail3V3(0); - inline Parameter epsCurrentForRail3V4(0); - inline Parameter epsCurrentForRail5V1(0); - inline Parameter epsCurrentForRail5V2(0); - inline Parameter epsCurrentForRail5V3(0); - inline Parameter epsCurrentForRail5V4(0); - inline Parameter epsCurrentForRail1(0); - inline Parameter epsCurrentForRail2(0); - inline Parameter epsCurrentForRail3(0); - inline Parameter epsCurrentForRail4(0); - inline Parameter epsCurrentForRail5(0); - - inline Parameter epsVoltageForEachRail3V1(0); - inline Parameter epsVoltageForEachRail3V2(0); - inline Parameter epsVoltageForEachRail3V3(0); - inline Parameter epsVoltageForEachRail3V4(0); - inline Parameter epsVoltageForEachRail5V1(0); - inline Parameter epsVoltageForEachRail5V2(0); - inline Parameter epsVoltageForEachRail5V3(0); - inline Parameter epsVoltageForEachRail5V4(0); - inline Parameter epsVoltageForEachRail12V1(0); - inline Parameter epsVoltageForEachRail12V2(0); - inline Parameter epsVoltageForEachRail12V3(0); - inline Parameter epsVoltageForEachRail12V4(0); - - inline Parameter epsPanelVoltageXPlus(0); - inline Parameter epsPanelVoltageXMinus(0); - inline Parameter epsPanelVoltageYPlus(0); - inline Parameter epsPanelVoltageYMinus(0); - inline Parameter epsPanelVoltageZ(0); - - inline Parameter epsPanelCurrentXPlus(0); - inline Parameter epsPanelCurrentXMinus(0); - inline Parameter epsPanelCurrentYPlus(0); - inline Parameter epsPanelCurrentYMinus(0); - inline Parameter epsPanelCurrentZ(0); - - inline Parameter epsBatteryPackVoltage(0); - - inline Parameter epsPanelTemperatureXPlus(0); - inline Parameter epsPanelTemperatureXMinus(0); - inline Parameter epsPanelTemperatureYPlus(0); - inline Parameter epsPanelTemperatureYMinus(0); - inline Parameter epsPanelTemperatureZ(0); - - inline Parameter epsPCBTemperatureSensor1(0); - inline Parameter epsPCBTemperatureSensor2(0); - - inline Parameter epsBatteryTemperatureSensor1(0); - inline Parameter epsBatteryTemperatureSensor2(0); - - /****************** COMMS PARAMETERS *******************/ - inline Parameter commsUHFBandPATemperature(0); - inline Parameter commsSBandPATemperature(0); - inline Parameter commsPCBTemperature(0); - - inline Parameter commsAntennaDeploymentStatus(Closed); // enum - - inline Parameter commsDataRateUHFTX(Rate); // enum - inline Parameter commsDataRateUHFRX(0); - inline Parameter commsSymbolRateSBand(0); - inline Parameter commsCWInterval(0); - inline Parameter commsGMSKBeaconInterval(0); - inline Parameter commsUHFBandTXPower(0); - inline Parameter commsSBandTXPower(0); - inline Parameter commsChannelNumberUHFBand(0); - inline Parameter commsChannelNumberSBand(0); - - inline Parameter commsLNAGain(Gain); // enum - inline Parameter commsPAGainUHFBand(Gain); // enum - inline Parameter commsPAGainSBand(Gain); // enum - - inline Parameter commsVGAGain(0); - inline Parameter commsRSSI(0); - - inline Parameter commsUHFBandTXOnOff(0); - inline Parameter commsUHFBandRXOnOff(0); - inline Parameter commsSBandTXOnOff(0); - - inline Parameter commsPacketsRejectedCOMMS(0); - inline Parameter commsInvalidHMAC(0); - inline Parameter commsInvalidPacketStructure(0); - inline Parameter commsInvalidSpacecraftID(0); - inline Parameter commsFrameSequenceCounter(0); - - inline Parameter commsPCBTemperature1(0); - inline Parameter commsPCBTemperature2(0); - inline Parameter commsMCUTemperature(0); - inline Parameter commsMCUInputVoltage(0); - - inline Parameter commsMCUBootCounter(0); - inline Parameter commsOnBoardTime(Time::DefaultCUC(0)); - - inline Parameter commsNANDCurrentlyUsedMemoryPartition(First); // enum - - inline Parameter commsLastFailedEvent(0); - inline Parameter commsMCUSystick(0); - inline Parameter commsFlashInt(0); - inline Parameter commsSRAMInt(0); -} diff --git a/inc/Platform/Parameters/BootCounter.hpp b/inc/Platform/Parameters/BootCounter.hpp deleted file mode 100644 index 5d31877..0000000 --- a/inc/Platform/Parameters/BootCounter.hpp +++ /dev/null @@ -1,48 +0,0 @@ -#pragma once - -#include "device.h" -#include "Definitions.hpp" -/** - * The BootCounter namespace contains the functionality for the Boot Counter parameter. In this - * implementation ATSAMV71Q21's General Purpose Backup Registers (GPBR) were used. GPBR were chosen - * because the contents are saved after a software MCU reset which is needed for testing purposes. - * However, these registers reset at first power-up and on each power loss. As a result, a different - * non-volatile memory will be used in the satellite's final software. - */ -namespace BootCounter { - /** - * This function is used to read from a GPBR. - * @param registerIndex which one of the \ref BackupRegisters to read from. - * @return the 32-bit data inside the register. - */ - inline uint32_t GPBRRead(BackupRegisters registerIndex) { - return GPBR_REGS->SYS_GPBR[registerIndex]; - } - - /** - * This function is used to write inside a GPBR. - * @param registerIndex which one of the \ref BackupRegisters to write to. - * @param data the 32-bit data to store inside the register. - */ - inline void GPBRWrite(BackupRegisters registerIndex, uint32_t data) { - GPBR_REGS->SYS_GPBR[registerIndex] = data; - } - - /** - * Function that clears the \ref BackupRegisters. - */ - void clearRegisters(); - - /** - * Checks the value of the \ref UnexpectedResetRegister. If the \ref softwareResetValue value is stored, a - * software reset is detected and the function returns. Otherwise, a hardware reset is detected - * so both the \ref UnexpectedResetRegister and \ref BootCounterRegister are set to their initial values. - */ - void setRegisters(); - - /** - * Increments the boot counter. - * If the counter limit is reached, the registers are cleared. - */ - void incrementBootCounter(); -} diff --git a/inc/Platform/Parameters/Definitions.hpp b/inc/Platform/Parameters/Definitions.hpp deleted file mode 100644 index fbb3a24..0000000 --- a/inc/Platform/Parameters/Definitions.hpp +++ /dev/null @@ -1,80 +0,0 @@ -#pragma once - -#include "etl/String.hpp" -#include "time.h" - -namespace BootCounter { - /** - * Enumeration of the General Purpose Backup Registers (GPBR) used in the boot counter parameter - * implementation. - */ - enum BackupRegisters : uint8_t { - /** - * Defines which one of the eight backup registers will be used to distinguish software from - * hardware resets. - */ - UnexpectedResetRegister = 0, - /** - * Defines which one of the eight backup registers will be used to save the boot counter variable. - */ - BootCounterRegister = 1 - }; - - /** - * When this value is detected inside the \ref UnexpectedResetRegister a software reset is acknowledged, - * otherwise an unexpected reset has occurred. - */ - inline const uint8_t SoftwareResetValue = 1; - - /** - * Defines the backup register's value after it is cleared. - */ - inline const uint8_t ClearRegisterValue = 0; - - /** - * A counter limit for hardware reset simulation. - * @see incrementBootCounter - */ - inline const uint16_t BootCounterLimit = 1000; -} - -/** - * Number of bytes used for the basic time units of the CUC header for the RTC transform - */ -inline constexpr uint8_t CUCSecondsBytes = 4; - -/** - * Number of bytes used for the fractional time units of the CUC header for the RTC transform - */ -inline constexpr uint8_t CUCFractionalBytes = 0; - -/** - * Contains initial epoch values for spacecraft time - */ -inline const tm EpochTime = {.tm_sec = 0, .tm_min = 0, .tm_hour = 0, .tm_mday = 1, .tm_mon = 0, .tm_year = 2022}; - -namespace LogSource { - /** - * The maximum number of letters in a string representation of a subsystem's name. - */ - inline constexpr uint8_t MaximumLettersInSubsystemName = 8; - - /** - * The maximum number of Logging Sources - */ - inline constexpr uint8_t NumberOfLogSources = 5; - - /** - * The subsystem to be used, if no other source is defined using the stream operator. - */ - extern String currentSubsystem; -} - -namespace CAN { - /** - * CAN Nodes, as specified in DDJF_OBDH. - */ - enum NodeIDs : uint8_t { - OBC = 0x0, COMMS = 0x1, ADCS = 0x2, SU = 0x3, ExternalMCU = 0x4 - }; -} diff --git a/inc/Platform/TaskInitialization.hpp b/inc/Platform/TaskInitialization.hpp deleted file mode 100644 index 25a1316..0000000 --- a/inc/Platform/TaskInitialization.hpp +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once - -#include "FreeRTOS.h" -#include "SEGGER_RTT.h" -#include "TimeKeepingTask.hpp" -#include "MCUTemperatureTask.hpp" -#include "AmbientTemperatureTask.hpp" -#include "UARTGatekeeperTask.hpp" -#include "WatchdogTask.hpp" -#include "CANGatekeeperTask.hpp" -#include "CANTestTask.hpp" - -void initializeTasks(); diff --git a/lib/cobs-c b/lib/cobs-c deleted file mode 160000 index 76bc5d0..0000000 --- a/lib/cobs-c +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 76bc5d064cea427ac0e82475185e1899d842ab73 diff --git a/src/FreeRTOSTasks/AmbientTemperatureTask.cpp b/src/FreeRTOSTasks/AmbientTemperatureTask.cpp deleted file mode 100644 index b95079b..0000000 --- a/src/FreeRTOSTasks/AmbientTemperatureTask.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include "AmbientTemperatureTask.hpp" - -void AmbientTemperatureTask::execute() { - uint8_t numberOfDisconnectedSensors = 0; - - for (auto &sensor: sensors) { - if (not sensor.isDeviceConnected()) { - LOG_ERROR << "Temperature sensor with address " << sensor.getI2CUserAddress() - << " was disconnected"; - numberOfDisconnectedSensors++; - } - } - - if (numberOfDisconnectedSensors == NumberOfTemperatureSensors) { - LOG_ERROR << "Suspending ambient temperature task"; - vTaskSuspend(taskHandle); - } - - while (true) { - for (uint8_t sensorCounter = 0; sensorCounter < NumberOfTemperatureSensors; sensorCounter++) { - if (not sensors[sensorCounter].isDeviceConnected()) { - LOG_ERROR << "Temperature sensor with address " << sensors[sensorCounter].getI2CUserAddress() - << " was disconnected"; - continue; - } - ambientTemperature[sensorCounter] = sensors[sensorCounter].getTemperature(); - LOG_INFO << "Sensor with address" << sensors[sensorCounter].getI2CUserAddress() << - " responded with ambient temperature = " << ambientTemperature[sensorCounter]; - } - - CommonParameters::boardTemperature1.setValue(ambientTemperature[0]); - CommonParameters::boardTemperature2.setValue(ambientTemperature[1]); - vTaskDelay(pdMS_TO_TICKS(DelayMs)); - } -} diff --git a/src/FreeRTOSTasks/CANGatekeeperTask.cpp b/src/FreeRTOSTasks/CANGatekeeperTask.cpp deleted file mode 100644 index af62374..0000000 --- a/src/FreeRTOSTasks/CANGatekeeperTask.cpp +++ /dev/null @@ -1,40 +0,0 @@ -#include "CAN/Driver.hpp" -#include "CAN/Frame.hpp" -#include "CANGatekeeperTask.hpp" - -CANGatekeeperTask::CANGatekeeperTask() : Task("CANGatekeeperTask") { - CAN::Driver::initialize(); - - outgoingQueue = xQueueCreateStatic(CAN::FrameQueueSize, sizeof(CAN::Frame), outgoingQueueStorageArea, - &outgoingQueueBuffer); - vQueueAddToRegistry(outgoingQueue, "CAN Outgoing"); - - incomingQueue = xQueueCreateStatic(CAN::FrameQueueSize, sizeof(CAN::Frame), incomingQueueStorageArea, - &incomingQueueBuffer); - vQueueAddToRegistry(incomingQueue, "CAN Incoming"); -} - -void CANGatekeeperTask::execute() { -#ifdef OBC_EQM_LCL - LCLDefinitions::lclArray[LCLDefinitions::CAN1].enableLCL(); - LCLDefinitions::lclArray[LCLDefinitions::CAN2].enableLCL(); -#endif - - PIO_PinWrite(CAN::CAN_SILENT_1, false); - PIO_PinWrite(CAN::CAN_SILENT_2, false); - - CAN::Frame message = {}; - - while (true) { - if(xTaskGetTickCount() - lastTransmissionTime > 8000) { - LOG_ERROR << "Resetting CAN LCLs"; - LCLDefinitions::lclArray[LCLDefinitions::CAN1].enableLCL(); - LCLDefinitions::lclArray[LCLDefinitions::CAN2].enableLCL(); - MCAN0_Initialize(); - MCAN1_Initialize(); - } - xQueueReceive(outgoingQueue, &message, portMAX_DELAY); - - CAN::Driver::send(message); - } -} diff --git a/src/FreeRTOSTasks/CANTestTask.cpp b/src/FreeRTOSTasks/CANTestTask.cpp deleted file mode 100644 index abfd436..0000000 --- a/src/FreeRTOSTasks/CANTestTask.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include "CANTestTask.hpp" -#include "CANGatekeeperTask.hpp" - -void CANTestTask::execute() { - CAN::Frame frame = {CAN::NodeID}; - for (auto i = 0; i < CAN::Frame::MaxDataLength; i++) { - frame.data.at(i) = i; - } - - while (true) { - CAN::Application::sendPingMessage(CAN::ADCS, false); - canGatekeeperTask->send(frame); - vTaskDelay(pdMS_TO_TICKS(2000)); - } -} \ No newline at end of file diff --git a/src/FreeRTOSTasks/MCUTemperatureTask.cpp b/src/FreeRTOSTasks/MCUTemperatureTask.cpp deleted file mode 100644 index 7e560d2..0000000 --- a/src/FreeRTOSTasks/MCUTemperatureTask.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include "MCUTemperatureTask.hpp" - -void MCUTemperatureTask::execute() { - AFEC0_ConversionStart(); - while (true) { - AFEC0_ConversionStart(); - vTaskDelay(pdMS_TO_TICKS(1)); - uint16_t ADCconversion = AFEC0_ChannelResultGet(AFEC_CH11); - float voltageConversion = static_cast(ADCconversion) * PositiveVoltageReference / MaxADCValue; - const float MCUtemperature = - (voltageConversion - TypicalVoltageAt25) / TemperatureSensitivity + ReferenceTemperature; - LOG_DEBUG << "The temperature of the MCU is: " << MCUtemperature << " degrees Celsius"; - CommonParameters::mcuTemperature.setValue(MCUtemperature); - vTaskDelay(pdMS_TO_TICKS(delayMs)); - } -} diff --git a/src/FreeRTOSTasks/TimeKeepingTask.cpp b/src/FreeRTOSTasks/TimeKeepingTask.cpp deleted file mode 100644 index 06eb4b9..0000000 --- a/src/FreeRTOSTasks/TimeKeepingTask.cpp +++ /dev/null @@ -1,46 +0,0 @@ -#include "TimeKeepingTask.hpp" - -void TimeKeepingTask::execute() { - static tm dateTime; - setEpoch(dateTime); - RTC_TimeSet(&dateTime); - - while (true) { - RTC_TimeGet(&dateTime); - setTimePlatformParameters(dateTime); - printOnBoardTime(); - vTaskDelay(pdMS_TO_TICKS(DelayMs)); - } -} - -void TimeKeepingTask::printOnBoardTime() { - UTCTimestamp timestamp = CommonParameters::time.getValue().toUTCtimestamp(); - etl::string<29> printTime = "Time:"; - etl::to_string(timestamp.hour, printTime, true); - printTime += "-"; - etl::to_string(timestamp.minute, printTime, true); - printTime += "-"; - etl::to_string(timestamp.second, printTime, true); - printTime += " -- "; - etl::to_string(timestamp.day, printTime, true); - printTime += "/"; - etl::to_string(timestamp.month, printTime, true); - printTime += "/"; - etl::to_string(timestamp.year, printTime, true); - LOG_DEBUG << printTime.data(); -} - -void TimeKeepingTask::setTimePlatformParameters(tm &dateTime) { - UTCTimestamp timeUTC(dateTime.tm_year + yearBase, dateTime.tm_mon + 1, dateTime.tm_mday, dateTime.tm_hour, dateTime.tm_min, dateTime.tm_sec); - Time::DefaultCUC timeCUC(timeUTC); - CommonParameters::time.setValue(timeCUC); -} - -void TimeKeepingTask::setEpoch(tm &dateTime) { - dateTime.tm_sec = EpochTime.tm_sec; - dateTime.tm_min = EpochTime.tm_min; - dateTime.tm_hour = EpochTime.tm_hour; - dateTime.tm_mday = EpochTime.tm_mday; - dateTime.tm_mon = EpochTime.tm_mon; - dateTime.tm_year = EpochTime.tm_year - yearBase; -} diff --git a/src/FreeRTOSTasks/UARTGatekeeperTask.cpp b/src/FreeRTOSTasks/UARTGatekeeperTask.cpp deleted file mode 100644 index 4cb01c9..0000000 --- a/src/FreeRTOSTasks/UARTGatekeeperTask.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include "UARTGatekeeperTask.hpp" - -UARTGatekeeperTask::UARTGatekeeperTask() : Task("UARTGatekeeperTask") { - xUartQueue = xQueueCreateStatic(UARTQueueSize, sizeof(etl::string), ucQueueStorageArea, - &xStaticQueue); -} - -void UARTGatekeeperTask::execute() { - etl::string output; - const void *txRegisterAddress = const_cast(reinterpret_cast(&UART_PERIPHERAL_REGISTER)); - while (true) { - xQueueReceive(xUartQueue, &output, portMAX_DELAY); - output.repair(); - - if constexpr (LogsAreCOBSEncoded) { - auto cobsEncoded = COBSencode(output); - XDMAC_ChannelTransfer(XDMAC_CHANNEL_0, cobsEncoded.data(), txRegisterAddress, cobsEncoded.size()); - } else { - XDMAC_ChannelTransfer(XDMAC_CHANNEL_0, output.data(), txRegisterAddress, output.size()); - } - vTaskDelay(60); - } -} diff --git a/src/FreeRTOSTasks/WatchdogTask.cpp b/src/FreeRTOSTasks/WatchdogTask.cpp deleted file mode 100644 index 7e0f9f0..0000000 --- a/src/FreeRTOSTasks/WatchdogTask.cpp +++ /dev/null @@ -1,9 +0,0 @@ -#include "WatchdogTask.hpp" - -void WatchdogTask::execute() { - while (true) { - WDT_Clear(); - LOG_DEBUG << "Watchdog reset"; - vTaskDelay(pdMS_TO_TICKS(WatchdogWindow)); - } -} diff --git a/src/Platform/CAN/ApplicationLayer.cpp b/src/Platform/CAN/ApplicationLayer.cpp deleted file mode 100644 index 058f396..0000000 --- a/src/Platform/CAN/ApplicationLayer.cpp +++ /dev/null @@ -1,262 +0,0 @@ -#include "CAN/ApplicationLayer.hpp" -#include "CAN/Driver.hpp" -#include "CAN/TPMessage.hpp" -#include "CAN/TPProtocol.hpp" -#include "CANGatekeeperTask.hpp" - -namespace CAN::Application { - Driver::ActiveBus switchBus(Driver::ActiveBus newBus) { - AcubeSATParameters::obcCANBUSActive.setValue(newBus); - return AcubeSATParameters::obcCANBUSActive.getValue(); - } - - void sendPingMessage(NodeIDs destinationAddress, bool isMulticast) { - TPMessage message = {{NodeID, destinationAddress, isMulticast}}; - - message.appendUint8(Ping); - - CAN::TPProtocol::createCANTPMessage(message, false); - } - - void sendPongMessage() { - TPMessage message = {{NodeID, OBC, false}}; - - message.appendUint8(Pong); - - CAN::TPProtocol::createCANTPMessage(message, true); - } - - void sendHeartbeatMessage() { - canGatekeeperTask->send({MessageIDs::Heartbeat + CAN::NodeID}, false); - } - - void sendBusSwitchoverMessage() { - Driver::ActiveBus newBus = Driver::Redundant; - if (AcubeSATParameters::obcCANBUSActive.getValue() == Driver::Redundant) { - newBus = Driver::Main; - } - - etl::array data = {switchBus(newBus)}; - - canGatekeeperTask->send({MessageIDs::BusSwitchover + CAN::NodeID, data}, false); - } - - void sendBusSwitchoverMessage(Driver::ActiveBus newBus) { - etl::array data = {switchBus(newBus)}; - - canGatekeeperTask->send({MessageIDs::BusSwitchover + CAN::NodeID, data}, false); - } - - void sendUTCTimeMessageWithElapsedTicks() { - auto now = TimeGetter::getCurrentTimeDefaultCUC(); - - const std::chrono::duration msOfDay = now.asDuration() % millisecondsPerDay; - - uint32_t ticksOfDay = static_cast(msOfDay.count() / 100); - - UTCTimestamp utc = now.toUTCtimestamp(); - etl::array data = {0, 0, static_cast(ticksOfDay), - static_cast(ticksOfDay >> 8), - static_cast(ticksOfDay >> 16), - static_cast(ticksOfDay >> 24), - static_cast(utc.day), - static_cast(utc.day >> 8)}; - - canGatekeeperTask->send({MessageIDs::UTCTime + CAN::NodeID, data}, false); - } - - void createSendParametersMessage(NodeIDs destinationAddress, bool isMulticast, - const etl::array ¶meterIDs, bool isISR) { - TPMessage message = {{CAN::NodeID, destinationAddress, isMulticast}}; - - message.appendUint8(MessageIDs::SendParameters); - message.appendUint16(parameterIDs.size()); - for (auto parameterID: parameterIDs) { - if (Services.parameterManagement.getParameter(parameterID)) { - message.append(parameterID); - Services.parameterManagement.getParameter(parameterID)->get().appendValueToMessage(message); - } - else if (parameterID == 0 ) { - continue; - } - else { - LOG_ERROR << "Requested parameter that doesn't exist! ID: " << parameterID; - } - } - - CAN::TPProtocol::createCANTPMessage(message, isISR); - } - - void createRequestParametersMessage(NodeIDs destinationAddress, bool isMulticast, - const etl::array ¶meterIDs, - bool isISR) { - TPMessage message = {{CAN::NodeID, destinationAddress, isMulticast}}; - - message.appendUint8(MessageIDs::RequestParameters); - message.appendUint16(parameterIDs.size()); - - if constexpr (Logger::isLogged(Logger::debug)) { - String<128> logString = "Requesting parameters with ID: "; - for (auto parameterID: parameterIDs) { - if (parameterID == 0) { - continue; - } - etl::to_string(parameterID, logString, true); - message.append(parameterID); - } - LOG_DEBUG << logString.c_str(); - } else { - for (auto parameterID: parameterIDs) { - message.append(parameterID); - } - } - - CAN::TPProtocol::createCANTPMessage(message, isISR); - } - - void createPerformFunctionMessage(NodeIDs destinationAddress, bool isMulticast, - const etl::string &functionId, - const etl::map &arguments, - bool isISR) { - TPMessage message = {{CAN::NodeID, destinationAddress, isMulticast}}; - - message.appendUint8(MessageIDs::PerformFunction); - - message.appendString(functionId); - - message.appendUint16(arguments.size()); - - for (auto argument: arguments) { - message.appendUint8(argument.first); - message.appendUint64(argument.second); - } - - CAN::TPProtocol::createCANTPMessage(message, isISR); - } - - void createEventReportMessage(NodeIDs destinationAddress, bool isMulticast, EventReportType type, uint16_t eventID, - const Message &eventData, bool isISR) { - TPMessage message = {{CAN::NodeID, destinationAddress, isMulticast}}; - - message.appendUint8(MessageIDs::EventReport); - message.appendEnum8(type); - message.appendUint16(eventID); - message.appendMessage(eventData, eventData.dataSize); - - CAN::TPProtocol::createCANTPMessage(message, isISR); - } - - void createPacketMessage(NodeIDs destinationAddress, bool isMulticast, const etl::string<128> &incomingMessage, Message::PacketType packetType, bool isISR) { - TPMessage message = {{CAN::NodeID, destinationAddress, isMulticast}}; - - if (packetType == Message::TM) { - message.appendUint8(MessageIDs::TMPacket); - } else { - message.appendUint8(MessageIDs::TCPacket); - } - - message.appendString(incomingMessage); - - CAN::TPProtocol::createCANTPMessage(message, isISR); - } - - void - createCCSDSPacketMessage(NodeIDs destinationAddress, bool isMulticast, const Message &incomingMessage, bool isISR) { - TPMessage message = {{CAN::NodeID, destinationAddress, isMulticast}}; - - auto ccsdsMessage = MessageParser::compose(incomingMessage); - - message.appendUint8(MessageIDs::CCSDSPacket); - message.appendString(ccsdsMessage); - - CAN::TPProtocol::createCANTPMessage(message, isISR); - } - - void createLogMessage(NodeIDs destinationAddress, bool isMulticast, const String &log, - bool isISR) { - TPMessage message = {{CAN::NodeID, destinationAddress, isMulticast}}; - - message.appendUint8(MessageIDs::LogMessage); - message.appendString(log); - - CAN::TPProtocol::createCANTPMessage(message, isISR); - } - - void parseMessage(const CAN::Frame &message) { - uint32_t id = filterMessageID(message.id); - if (id == Heartbeat) { -// registerHeartbeat(); - } else if (id == BusSwitchover) { - switchBus(static_cast(message.data[0])); - } else if (id == UTCTime) { -// registerUTCTime(); - } - } - - void parseSendParametersMessage(TPMessage &message) { - uint8_t messageType = message.readUint8(); - if (not ErrorHandler::assertInternal(messageType == SendParameters, ErrorHandler::UnknownMessageType)) { - return; - } - uint16_t parameterCount = message.readUint16(); - - for (uint16_t idx = 0; idx < parameterCount; idx++) { - uint16_t parameterID = message.readUint16(); - if (Services.parameterManagement.parameterExists(parameterID)) { - if constexpr (Logger::isLogged(Logger::debug)) { - String<64> logString = "The value for parameter with ID "; - etl::to_string(parameterID, logString, true); - logString.append(" was "); - - auto parameter = Services.parameterManagement.getParameter(parameterID); - etl::to_string(parameter->get().getValueAsDouble(), logString, true); - - parameter->get().setValueFromMessage(message); - logString.append(" and is now "); - etl::to_string(parameter->get().getValueAsDouble(), logString, true); - - LOG_DEBUG << logString.c_str(); - } else { - Services.parameterManagement.getParameter(parameterID)->get().setValueFromMessage(message); - } - } - } - } - - void parseRequestParametersMessage(TPMessage &message) { - uint8_t messageType = message.readUint8(); - if (not ErrorHandler::assertInternal(messageType == RequestParameters, ErrorHandler::UnknownMessageType)) { - return; - } - uint16_t parameterCount = message.readUint16(); - etl::array parameterIDs = {}; - - for (uint16_t idx = 0; idx < parameterCount; idx++) { - parameterIDs[idx] = message.readUint16(); - } - - createSendParametersMessage(message.idInfo.sourceAddress, message.idInfo.isMulticast, parameterIDs, true); - } - - void parseTMMessage(TPMessage &message) { - uint8_t messageType = message.readUint8(); - if (not ErrorHandler::assertInternal(messageType == TMPacket, ErrorHandler::UnknownMessageType)) { - return; - } - - String logString = message.data + 1; - - LOG_DEBUG << logString.c_str(); - } - - void parseTCMessage(TPMessage &message) { - uint8_t messageType = message.readUint8(); - if (not ErrorHandler::assertInternal(messageType == TCPacket, ErrorHandler::UnknownMessageType)) { - return; - } - - Message teleCommand = MessageParser::parseECSSTC(message.data + 1); - - MessageParser::execute(teleCommand); - } -} diff --git a/src/Platform/CAN/Driver.cpp b/src/Platform/CAN/Driver.cpp deleted file mode 100644 index c0fa1fd..0000000 --- a/src/Platform/CAN/Driver.cpp +++ /dev/null @@ -1,212 +0,0 @@ -#include "CAN/Driver.hpp" -#include "CAN/TPProtocol.hpp" -#include "CANGatekeeperTask.hpp" -#include "Logger.hpp" - -uint8_t CAN::Driver::convertDlcToLength(uint8_t dlc) { - static constexpr uint8_t msgLength[] = {0U, 1U, 2U, 3U, 4U, 5U, 6U, 7U, 8U, 12U, 16U, 20U, 24U, 32U, 48U, 64U}; - return msgLength[dlc]; -} - -uint8_t CAN::Driver::convertLengthToDLC(uint8_t length) { - uint8_t dlc; - - if (length <= 8U) { - dlc = length; - } else if (length <= 12U) { - dlc = 0x9U; - } else if (length <= 16U) { - dlc = 0xAU; - } else if (length <= 20U) { - dlc = 0xBU; - } else if (length <= 24U) { - dlc = 0xCU; - } else if (length <= 32U) { - dlc = 0xDU; - } else if (length <= 48U) { - dlc = 0xEU; - } else { - dlc = 0xFU; - } - return dlc; -} - -void CAN::Driver::mcan0TxFifoCallback(uintptr_t context) { - uint32_t status = MCAN0_ErrorGet() & MCAN_PSR_LEC_Msk; - bool isStatusOk = (status == MCAN_ERROR_NONE) || (status == MCAN_ERROR_LEC_NO_CHANGE); - auto appState = static_cast(context); - - if (appState == Transmit && not isStatusOk) { - LOG_ERROR << "Could not transmit CAN message. The status is " << status; - return; - } - - canGatekeeperTask->lastTransmissionTime = xTaskGetTickCount(); -} - -void CAN::Driver::mcan0RxFifo0Callback(uint8_t numberOfMessages, uintptr_t context) { - uint32_t status = MCAN0_ErrorGet() & MCAN_PSR_LEC_Msk; - bool isStatusOk = (status == MCAN_ERROR_NONE) || (status == MCAN_ERROR_LEC_NO_CHANGE); - auto appState = static_cast(context); - - if (not(isStatusOk && appState == Receive)) { - return; - } - - for (size_t messageNumber = 0; messageNumber < numberOfMessages; messageNumber++) { - memset(&rxFifo0, 0x0, (numberOfMessages * MCAN0_RX_FIFO0_ELEMENT_SIZE)); - if (MCAN0_MessageReceiveFifo(MCAN_RX_FIFO_0, 1, &rxFifo0)) { - if (rxFifo0.data[0] >> 6 == CAN::TPProtocol::Frame::Single) { - TPProtocol::processSingleFrame(getFrame(rxFifo0)); - continue; - } - - canGatekeeperTask->addToIncoming(getFrame(rxFifo0)); - - if (rxFifo0.data[0] >> 6 == CAN::TPProtocol::Frame::Final) { - CAN::TPProtocol::processMultipleFrames(); - } - } - } -} - -void CAN::Driver::mcan0RxFifo1Callback(uint8_t numberOfMessages, uintptr_t context) { - uint32_t status = MCAN0_ErrorGet() & MCAN_PSR_LEC_Msk; - bool isStatusOk = (status == MCAN_ERROR_NONE) || (status == MCAN_ERROR_LEC_NO_CHANGE); - auto appState = static_cast(context); - - if (not(isStatusOk && appState == Receive)) { - return; - } - - for (size_t messageNumber = 0; messageNumber < numberOfMessages; messageNumber++) { - memset(&rxFifo1, 0x0, MCAN0_RX_FIFO0_ELEMENT_SIZE); - if (MCAN0_MessageReceiveFifo(MCAN_RX_FIFO_1, 1, &rxFifo1)) { - logMessage(rxFifo1, Main); - CAN::Application::parseMessage(getFrame(rxFifo1)); - } - } -} - -void CAN::Driver::mcan1TxFifoCallback(uintptr_t context) { - uint32_t status = MCAN1_ErrorGet() & MCAN_PSR_LEC_Msk; - bool isStatusOk = (status == MCAN_ERROR_NONE) || (status == MCAN_ERROR_LEC_NO_CHANGE); - auto appState = static_cast(context); - - if (appState == Transmit && not isStatusOk) { - LOG_ERROR << "Could not transmit CAN message. The status is " << status; - return; - } - - canGatekeeperTask->lastTransmissionTime = xTaskGetTickCount(); -} - -void CAN::Driver::mcan1RxFifo0Callback(uint8_t numberOfMessages, uintptr_t context) { - uint32_t status = MCAN1_ErrorGet() & MCAN_PSR_LEC_Msk; - bool isStatusOk = (status == MCAN_ERROR_NONE) || (status == MCAN_ERROR_LEC_NO_CHANGE); - auto appState = static_cast(context); - - if (not(isStatusOk && appState == Receive)) { - return; - } - - for (size_t messageNumber = 0; messageNumber < numberOfMessages; messageNumber++) { - memset(&rxFifo0, 0x0, (numberOfMessages * MCAN1_RX_FIFO0_ELEMENT_SIZE)); - if (MCAN1_MessageReceiveFifo(MCAN_RX_FIFO_0, 1, &rxFifo0)) { - if (rxFifo0.data[0] >> 6 == CAN::TPProtocol::Frame::Single) { - TPProtocol::processSingleFrame(getFrame(rxFifo0)); - continue; - } - - canGatekeeperTask->addToIncoming(getFrame(rxFifo0)); - - if (rxFifo0.data[0] >> 6 == CAN::TPProtocol::Frame::Final) { - CAN::TPProtocol::processMultipleFrames(); - } - } - } -} - -void CAN::Driver::mcan1RxFifo1Callback(uint8_t numberOfMessages, uintptr_t context) { - uint32_t status = MCAN1_ErrorGet() & MCAN_PSR_LEC_Msk; - bool isStatusOk = (status == MCAN_ERROR_NONE) || (status == MCAN_ERROR_LEC_NO_CHANGE); - auto appState = static_cast(context); - - if (not(isStatusOk && appState == Receive)) { - return; - } - - for (size_t messageNumber = 0; messageNumber < numberOfMessages; messageNumber++) { - memset(&rxFifo1, 0x0, MCAN1_RX_FIFO0_ELEMENT_SIZE); - if (MCAN1_MessageReceiveFifo(MCAN_RX_FIFO_1, 1, &rxFifo1)) { - logMessage(rxFifo1, Redundant); - CAN::Application::parseMessage(getFrame(rxFifo1)); - } - } -} - -void CAN::Driver::send(const CAN::Frame &message) { - using namespace CAN; - - memset(&Driver::txFifo, 0, MCAN1_TX_FIFO_BUFFER_ELEMENT_SIZE); - - Driver::txFifo.brs = 1; - Driver::txFifo.fdf = 1; - Driver::txFifo.xtd = 0; - Driver::txFifo.id = Driver::writeId(message.id); - Driver::txFifo.dlc = Driver::convertLengthToDLC(message.data.size()); - - std::copy(message.data.begin(), message.data.end(), Driver::txFifo.data); - - if (AcubeSATParameters::obcCANBUSActive.getValue() == Main) { - MCAN0_MessageTransmitFifo(1, &Driver::txFifo); - } else { - MCAN1_MessageTransmitFifo(1, &Driver::txFifo); - } -} - -void CAN::Driver::logMessage(const MCAN_RX_BUFFER &rxBuf, ActiveBus incomingBus) { - auto message = String("CAN Message: "); - if (incomingBus == Main) { - message.append("MCAN0 "); - } else { - message.append("MCAN1 "); - } - uint32_t id = readId(rxBuf.id); - const uint8_t msgLength = convertDlcToLength(rxBuf.dlc); - message.append("ID : "); - etl::to_string(id, message, etl::format_spec().hex(), true); - message.append(" Length : "); - etl::to_string(msgLength, message, true); - message.append(" Data : "); - for (uint8_t idx = 0; idx < msgLength; idx++) { - etl::to_string(rxBuf.data[idx], message, true); - message.append(" "); - } - LOG_INFO << message.c_str(); -} - -CAN::Frame CAN::Driver::getFrame(const MCAN_RX_BUFFER &rxBuffer) { - CAN::Frame frame; - const uint8_t messageLength = convertDlcToLength(rxBuffer.dlc); - - frame.id = readId(rxBuffer.id); - for (uint8_t idx = 0; idx < messageLength; idx++) { - frame.data.at(idx) = rxBuffer.data[idx]; - } - - return frame; -} - -void CAN::Driver::initialize() { - MCAN0_MessageRAMConfigSet(CAN::Driver::mcan0MessageRAM); - MCAN1_MessageRAMConfigSet(CAN::Driver::mcan1MessageRAM); - - MCAN0_TxFifoCallbackRegister(CAN::Driver::mcan0TxFifoCallback, CAN::Driver::Transmit); - MCAN0_RxFifoCallbackRegister(MCAN_RX_FIFO_0, CAN::Driver::mcan0RxFifo0Callback, CAN::Driver::Receive); - MCAN0_RxFifoCallbackRegister(MCAN_RX_FIFO_1, CAN::Driver::mcan0RxFifo1Callback, CAN::Driver::Receive); - - MCAN1_TxFifoCallbackRegister(CAN::Driver::mcan1TxFifoCallback, CAN::Driver::Transmit); - MCAN1_RxFifoCallbackRegister(MCAN_RX_FIFO_0, CAN::Driver::mcan1RxFifo0Callback, CAN::Driver::Receive); - MCAN1_RxFifoCallbackRegister(MCAN_RX_FIFO_1, CAN::Driver::mcan1RxFifo1Callback, CAN::Driver::Receive); -} diff --git a/src/Platform/CAN/TPProtocol.cpp b/src/Platform/CAN/TPProtocol.cpp deleted file mode 100644 index a73d039..0000000 --- a/src/Platform/CAN/TPProtocol.cpp +++ /dev/null @@ -1,156 +0,0 @@ -#include "CAN/TPProtocol.hpp" -#include "CANGatekeeperTask.hpp" - -using namespace CAN; - -void TPProtocol::processSingleFrame(const CAN::Frame &message) { - TPMessage tpMessage; - tpMessage.decodeId(message.id); - - if (not (tpMessage.idInfo.isMulticast or tpMessage.idInfo.destinationAddress == NodeID)) { - return; - } - - size_t messageSize = message.data[0] & 0b111111; - for (size_t idx = 1; idx <= messageSize; idx++) { - tpMessage.appendUint8(message.data[idx]); - } - - parseMessage(tpMessage); -} - -void TPProtocol::processMultipleFrames() { - TPMessage message; - uint8_t incomingMessagesCount = canGatekeeperTask->getIncomingMessagesCount(); - uint16_t dataLength = 0; - bool receivedFirstFrame = false; - - for (uint8_t messageCounter = 0; messageCounter < incomingMessagesCount; messageCounter++) { - CAN::Frame frame = canGatekeeperTask->getFromQueue(); - auto frameType = static_cast(frame.data[0] >> 6); - - if (not receivedFirstFrame) { - if (frameType == First) { - message.decodeId(frame.id); - dataLength = ((frame.data[0] & 0b111111) << 8) | frame.data[1]; - receivedFirstFrame = true; - } - } else { - uint8_t consecutiveFrameCount = frame.data[0] & 0b111111; - if (not ErrorHandler::assertInternal(messageCounter == consecutiveFrameCount, - ErrorHandler::InternalErrorType::UnacceptablePacket)) { //TODO: Add a more appropriate enum value - canGatekeeperTask->emptyIncomingQueue(); - return; - } - - for (size_t idx = 1; idx < CAN::Frame::MaxDataLength; idx++) { - message.appendUint8(frame.data[idx]); - if (message.dataSize >= dataLength) { - break; - } - } - } - } - - if (not (message.idInfo.isMulticast or message.idInfo.destinationAddress == NodeID)) { - return; - } - - parseMessage(message); -} - -void TPProtocol::parseMessage(TPMessage &message) { - uint8_t messageType = static_cast(message.data[0]); - switch (messageType) { - case CAN::Application::SendParameters: - CAN::Application::parseSendParametersMessage(message); - break; - case CAN::Application::RequestParameters: - CAN::Application::parseRequestParametersMessage(message); - break; - case CAN::Application::PerformFunction: - break; //todo: use ST[08] to execute the perform function command - case CAN::Application::EventReport: - break; //todo: use the Event Report service - case CAN::Application::TMPacket: - CAN::Application::parseTMMessage(message); - break; - case CAN::Application::TCPacket: - CAN::Application::parseTCMessage(message); - break; - case CAN::Application::CCSDSPacket: - break; //todo send this to comms? idk - case CAN::Application::Ping: { - auto senderID = static_cast(message.idInfo.sourceAddress); - auto senderName = CAN::Application::nodeIdToString.at(senderID); - LOG_DEBUG << "Received ping from " << senderName.c_str(); - CAN::Application::sendPongMessage(); - } - break; - case CAN::Application::Pong: { - auto senderID = static_cast(message.idInfo.sourceAddress); - auto senderName = CAN::Application::nodeIdToString.at(senderID); - LOG_DEBUG << "Received pong from " << senderName.c_str(); - } - break; - case CAN::Application::LogMessage: { - auto senderID = static_cast(message.idInfo.sourceAddress); - auto senderName = CAN::Application::nodeIdToString.at(senderID); - String logSource = "Incoming Log from "; - logSource.append(senderName); - logSource.append(": "); - auto logData = String(message.data + 1, message.dataSize - 1); - LOG_DEBUG << logSource.c_str() << logData.c_str(); - } - break; - default: - ErrorHandler::reportInternalError(ErrorHandler::UnknownMessageType); - break; - } -} - -void TPProtocol::createCANTPMessage(const TPMessage &message, bool isISR) { - size_t messageSize = message.dataSize; - uint32_t id = message.encodeId(); - // Data fits in a Single Frame - if (messageSize <= UsableDataLength) { - etl::array data = { - static_cast(((Single << 6) & 0xFF) | (messageSize & 0b111111))}; - for (size_t idx = 0; idx < messageSize; idx++) { - data.at(idx + 1) = message.data[idx]; - } - canGatekeeperTask->send({id, data}, isISR); - - return; - } - - // First Frame - { - // 4 MSB bits is the Frame Type identifier and the 4 LSB are the leftmost 4 bits of the data length. - uint8_t firstByte = (First << 6) | ((messageSize >> 8) & 0b111111); - // Rest of the data length. - uint8_t secondByte = messageSize & 0xFF; - - etl::array firstFrame = {firstByte, secondByte}; - - canGatekeeperTask->send({id, firstFrame}, isISR); - } - - // Consecutive Frames - uint8_t totalConsecutiveFramesNeeded = ceil(static_cast(messageSize) / UsableDataLength); - for (uint8_t currentConsecutiveFrameCount = 1; - currentConsecutiveFrameCount <= totalConsecutiveFramesNeeded; currentConsecutiveFrameCount++) { - - uint8_t firstByte = (Consecutive << 6) | (currentConsecutiveFrameCount & 0b111111); - if (currentConsecutiveFrameCount == totalConsecutiveFramesNeeded) { - firstByte = ((Final << 6) & 0xFF) | (currentConsecutiveFrameCount & 0b111111); - } - etl::array consecutiveFrame = {firstByte}; - - for (uint8_t idx = 0; idx < UsableDataLength; idx++) { - consecutiveFrame.at(idx + 1) = message.data[idx + UsableDataLength * (currentConsecutiveFrameCount - 1)]; - } - - canGatekeeperTask->send({id, consecutiveFrame}, isISR); - } -} diff --git a/src/Platform/Logger.cpp b/src/Platform/Logger.cpp deleted file mode 100644 index beae0e5..0000000 --- a/src/Platform/Logger.cpp +++ /dev/null @@ -1,78 +0,0 @@ -#include -#include -#include -#include -#include -#include "FreeRTOS.h" -#include "task.h" -#include "queue.h" -#include "SEGGER_RTT.h" -#include "ServicePool.hpp" -#include "UARTGatekeeperTask.hpp" - -void Logger::log(Logger::LogLevel level, etl::istring &message) { - etl::string levelString; - etl::string time; - - if (level <= Logger::trace) { - levelString.append("trace"); - } else if (level <= Logger::debug) { - levelString.append("debug"); - } else if (level <= Logger::info) { - levelString.append("info"); - } else if (level <= Logger::notice) { - levelString.append("notice"); - } else if (level <= Logger::warning) { - levelString.append("warning"); - } else if (level <= Logger::error) { - levelString.append("error"); - } else { - levelString = "emergency"; - } - - while (levelString.available()) { - levelString.append(" "); - } - - etl::to_string(xTaskGetTickCount(), time, format.width(MaxTickCountStringSize), 0); - - etl::string output; - output.append(time.c_str()); - output.append(" ["); - output.append(levelString.c_str()); - output.append("] "); - - etl::string subsystemString = LogSource::currentSubsystem; - if (LogSource::currentSubsystem.empty()) { - subsystemString = "None "; - } - while (subsystemString.available()) { - subsystemString.append(" "); - } - output.append(subsystemString.c_str()); - - output.append(message.c_str()); - output.append("\n"); - - if (CommonParameters::useRTT.getValue()) { - SEGGER_RTT_printf(0, output.c_str()); - } - if (CommonParameters::useUART.getValue()) { - if (uartGatekeeperTask) { - uartGatekeeperTask->addToQueue(output); - } - } - if (CommonParameters::useCAN.getValue()) { - Services.dummyService.logAsECSSMessage(output); - } -} - -template<> -void convertValueToString(String& message, char* value) { - message.append(value); -} - -template<> -void convertValueToString(String& message, const char* value) { - message.append(value); -} diff --git a/src/Platform/Parameters/BootCounter.cpp b/src/Platform/Parameters/BootCounter.cpp deleted file mode 100644 index 270e85a..0000000 --- a/src/Platform/Parameters/BootCounter.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include "BootCounter.hpp" - -namespace BootCounter { - void clearRegisters() { - GPBRWrite(UnexpectedResetRegister, ClearRegisterValue); - GPBRWrite(BootCounterRegister, ClearRegisterValue); - } - - void setRegisters() { - if (GPBRRead(UnexpectedResetRegister) == SoftwareResetValue) { - return; - } - - GPBRWrite(UnexpectedResetRegister, SoftwareResetValue); - GPBRWrite(BootCounterRegister, ClearRegisterValue); - } - - void incrementBootCounter() { - if (GPBRRead(BootCounterRegister) > BootCounterLimit) { - clearRegisters(); - } - setRegisters(); - GPBRWrite(BootCounterRegister, GPBRRead(BootCounterRegister) + 1); - } -} diff --git a/src/Platform/TaskInitialization.cpp b/src/Platform/TaskInitialization.cpp deleted file mode 100644 index 37354f4..0000000 --- a/src/Platform/TaskInitialization.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include "TaskInitialization.hpp" - -void initializeTasks() { - uartGatekeeperTask.emplace(); - timeKeepingTask.emplace(); - ambientTemperatureTask.emplace(); - watchdogTask.emplace(); - mcuTemperatureTask.emplace(); - - ambientTemperatureTask->createTask(); - mcuTemperatureTask->createTask(); - timeKeepingTask->createTask(); - uartGatekeeperTask->createTask(); - watchdogTask->createTask(); -} diff --git a/src/Platform/TimeGetter.cpp b/src/Platform/TimeGetter.cpp deleted file mode 100644 index be2dced..0000000 --- a/src/Platform/TimeGetter.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "Helpers/TimeGetter.hpp" -#include "CommonParameters.hpp" - -UTCTimestamp TimeGetter::getCurrentTimeUTC() { - return getCurrentTimeDefaultCUC().toUTCtimestamp(); -} - -Time::DefaultCUC TimeGetter::getCurrentTimeDefaultCUC() { - return CommonParameters::time.getValue(); -} \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index ad0a2d1..3a77333 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -39,14 +39,14 @@ extern "C" void main_cpp() { housekeepingTask.emplace(); canGatekeeperTask.emplace(); canTestTask.emplace(); -// nandTask.emplace(); + //nandTask.emplace(); mramTask.emplace(); tcHandlingTask->createTask(); housekeepingTask->createTask(); canGatekeeperTask->createTask(); canTestTask->createTask(); -// nandTask->createTask(); + //nandTask->createTask(); mramTask->createTask(); vTaskStartScheduler();