Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions Components/DataBroker/Inc/DataBroker.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,17 +175,35 @@ class DataBroker {
* @brief Returns the correct Publisher object for a template type
*/
template <typename T>
static constexpr auto getPublisher(void) {
static constexpr Publisher<T>* getPublisher(void) {
if constexpr (matchType<T, IMUData>()) {
return &IMU_Data_publisher;
} else {
}
else if constexpr(matchType<T, BaroData>()){
return &Baro_Data_publisher;
}
else if constexpr(matchType<T, MagData>()){
return &Mag_Data_publisher;
}
else if constexpr(matchType<T, FilterData>()){
return &Filter_Data_publisher;
}
else if constexpr(matchType<T, GPSData>()){
return &GPS_Data_publisher;
}
else {
SOAR_ASSERT(false, "This publisher type does not exist, you must create it");
return (Publisher<T>*)nullptr;
}
}

// List of Publishers
inline static Publisher<IMUData> IMU_Data_publisher{DataBrokerMessageTypes::IMU_DATA};
inline static Publisher<MagData> Mag_Data_publisher{DataBrokerMessageTypes::MAG_DATA};
inline static Publisher<BaroData> Baro_Data_publisher{DataBrokerMessageTypes::BARO_DATA};
inline static Publisher<FilterData> Filter_Data_publisher{DataBrokerMessageTypes::FILTER_DATA};
inline static Publisher<GPSData> GPS_Data_publisher{DataBrokerMessageTypes::GPS_DATA};


};
/************************************
Expand Down
2 changes: 1 addition & 1 deletion Components/SystemTypes/DataBrokerMessageTypes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ std::string ToString(DataBrokerMessageTypes messageType);
inline std::string ToString(DataBrokerMessageTypes messageType) {
switch (messageType) {
case DataBrokerMessageTypes::IMU_DATA: {
std::string type{"IMU_DATA"};
std::string type{"IMU32G_DATA"};
return type;
}
case DataBrokerMessageTypes::GPS_DATA: {
Expand Down
59 changes: 50 additions & 9 deletions Components/SystemTypes/SensorDataTypes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,33 +26,74 @@
* @param accelY The acceleration in the Y axis relative to the sensor
* @param accelZ The acceleration in the Z axis relative to the sensor
*/
struct ACCEL_t {
int16_t x;
int16_t y;
int16_t z;
};

struct GYRO_t {
int16_t x;
int16_t y;
int16_t z;
};

struct IMUData {
uint32_t accelX;
uint32_t accelY;
uint32_t accelZ;
ACCEL_t accel;
GYRO_t gyro;
int16_t temp;
uint8_t id;
uint32_t gyroX;
uint32_t gyroY;
uint32_t gyroZ;

uint32_t accelX;
uint32_t accelY;
uint32_t accelZ;
};

/**
* @param Temperature. Can be any where from -2147483648 to 2147483647
*/
struct ThermocoupleData {
int32_t temperature;
int32_t temperature;
};

struct GPSData{
uint32_t gps;
};

struct BaroData{

struct BaroData {
uint32_t baro;
int16_t temp;
uint32_t pressure;
uint8_t id;
};

struct FilterData{
uint32_t filter;
struct FilterData {
uint32_t alt;
uint32_t velo;
uint32_t acc;

// predictions can be published later
/*
uint32_t alt_predict;
uint32_t velo_predict;
uint32_t acc_predict;
*/
};

struct MagData{
uint32_t mag;
struct MagData {
uint32_t rawX;
uint32_t rawY;
uint32_t rawZ;
float scaledX;
float scaledY;
float scaledZ;
uint32_t magX;
uint32_t magY;
uint32_t magZ;
};

#endif /* SENSORDATATYPES_HPP_ */
1 change: 1 addition & 0 deletions CubeDefines.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <cstdint> // For uint32_t, etc.
#include <cstdio> // Standard c printf, vsnprintf, etc.
#include "cmsis_os.h" // CMSIS RTOS definitions
#include "Mutex.hpp"

/* Global Functions ------------------------------------------------------------------*/
void cube_print(const char* format, ...);
Expand Down
1 change: 1 addition & 0 deletions CubeTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ void CubeTask::InitTask()
void CubeTask::Run(void * pvParams)
{
//UART Task loop

while(1) {
Command cm;

Expand Down
78 changes: 78 additions & 0 deletions Drivers/Inc/UARTTask.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*
* UARTTask.hpp
*
* Created on: Feb 4, 2026
* Author: jaddina
*/

#ifndef DRIVERS_INC_UARTTASK_HPP_
#define DRIVERS_INC_UARTTASK_HPP_

/**
******************************************************************************
* File Name : UARTTask.hpp
* Description :
******************************************************************************
*/
#ifndef SOAR_COMMS_UARTTASK_HPP_
#define SOAR_COMMS_UARTTASK_HPP_
/* Includes ------------------------------------------------------------------*/
#include "Task.hpp"
#include "SystemDefines.hpp"
#include "UARTDriver.hpp"



/* Macros ------------------------------------------------------------------*/
enum UART_TASK_COMMANDS {
UART_TASK_COMMAND_NONE = 0,
UART_TASK_COMMAND_SEND_DEBUG,
UART_TASK_COMMAND_SEND_RADIO,
UART_TASK_COMMAND_SEND_PBB,
UART_TASK_COMMAND_MAX
};


/* Class ------------------------------------------------------------------*/
class UARTTask : public Task
{
public:
static UARTTask& Inst() {
static UARTTask inst;
return inst;
}

void InitTask();

protected:
static void RunTask(void* pvParams) { UARTTask::Inst().Run(pvParams); } // Static Task Interface, passes control to the instance Run();

void Run(void* pvParams); // Main run code

void ConfigureUART();
void HandleCommand(Command& cm);

private:
UARTTask() : Task(UART_TASK_QUEUE_DEPTH_OBJS) {} // Private constructor
UARTTask(const UARTTask&); // Prevent copy-construction
UARTTask& operator=(const UARTTask&); // Prevent assignment
};


/* Utility Functions ------------------------------------------------------------------*/
namespace UARTUtils
{

}


#endif // SOAR_COMMS_UARTTASK_HPP_








#endif /* DRIVERS_INC_UARTTASK_HPP_ */
100 changes: 100 additions & 0 deletions Drivers/UARTTask.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
/*
* UARTTask.cpp
*
* Created on: Feb 4, 2026
* Author: jaddina
*/
/**
******************************************************************************
* File Name : UARTTask.cpp
* Description : UART
******************************************************************************
*/

#include "UARTTask.hpp"
#include "UARTDriver.hpp"

/**
* TODO: Currently not used, would be used for DMA buffer configuration or interrupt setup
* @brief Configures UART DMA buffers and interrupts
*
*/
void UARTTask::ConfigureUART()
{
// UART 5 - Uses polling for now (switch to DMA or interrupts once SOAR-Protocol is defined)
}

/**
* @brief Initializes UART task with the RTOS scheduler
*/
void UARTTask::InitTask()
{
// Make sure the task is not already initialized
SOAR_ASSERT(rtTaskHandle == nullptr, "Cannot initialize UART task twice");

// Start the task
BaseType_t rtValue =
xTaskCreate((TaskFunction_t)UARTTask::RunTask,
(const char*)"UARTTask",
(uint16_t)UART_TASK_STACK_DEPTH_WORDS,
(void*)this,
(UBaseType_t)UART_TASK_RTOS_PRIORITY,
(TaskHandle_t*)&rtTaskHandle);

//Ensure creation succeded
SOAR_ASSERT(rtValue == pdPASS, "UARTTask::InitTask() - xTaskCreate() failed");

// Configure DMA

}

/**
* @brief Instance Run loop for the UART Task, runs on scheduler start as long as the task is initialized.
* @param pvParams RTOS Passed void parameters, contains a pointer to the object instance, should not be used
*/
void UARTTask::Run(void * pvParams)
{
//UART Task loop
while(1) {
Command cm;

//Wait forever for a command
qEvtQueue->ReceiveWait(cm);

//Process the command
HandleCommand(cm);
}
}

/**
* @brief HandleCommand handles any command passed to the UART task primary event queue. Responsible for
* handling all commands, even if unsupported. (Unexpected commands must still be reset)
* @param cm Reference to the command object to handle
*/
void UARTTask::HandleCommand(Command& cm)
{
//Switch for the GLOBAL_COMMAND
switch (cm.GetCommand()) {
case DATA_COMMAND: {
//Switch for task specific command within DATA_COMMAND
switch (cm.GetTaskCommand()) {
case UART_TASK_COMMAND_SEND_DEBUG:
UART::Debug->Transmit(cm.GetDataPointer(), cm.GetDataSize());
break;

default:
SOAR_PRINT("UARTTask - Received Unsupported DATA_COMMAND {%d}\n", cm.GetTaskCommand());
break;
}
}
case TASK_SPECIFIC_COMMAND: {
break;
}
default:
SOAR_PRINT("UARTTask - Received Unsupported Command {%d}\n", cm.GetCommand());
break;
}

//No matter what we happens, we must reset allocated data
cm.Reset();
}