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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Ignore .pre-commit-config.yaml
.pre-commit-config.yaml

#Ignore Makefile
Makefile
# Ignore other Branch specific dirs
PeripheralDriversSubmodule/NAU7802/*
PeripheralDriversSubmodule/MX66L1G45GMI/*
8 changes: 6 additions & 2 deletions Components/IMUTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,13 @@ void IMUTask::Run(void * pvParams){
imu.Init(hspi_, LSM6DSO32_CS_PORT, LSM6DSO32_CS_PIN);

while (1) {
/* Process commands in blocking mode */
imu.ReadSensors(data);
imu_data = imu.ConvertRawMeasurementToStruct(data);
imu_data.id = 1;
DataBroker::Publish<IMUData>(&imu_data);

Command cm;
bool res = qEvtQueue->ReceiveWait(cm);
bool res = qEvtQueue->Receive(cm, 333);
if(res){

HandleCommand(cm);
Expand Down
17 changes: 10 additions & 7 deletions Components/LSM6DO32Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include "LSM6DO32Driver.h"

#include <cstring>

/* @brief Initialize the driver. Must be called before any other functions can be used.
* @param hspi_ Pointer to the SPI handle
Expand Down Expand Up @@ -77,7 +78,9 @@ void LSM6DO32_Driver::GetMultipleRegisters(LSM6DSO32_REGISTER_t startreg, int nu
transmit[0] = (uint8_t)(0b10000000 | startreg);

CSLow();
HAL_SPI_TransmitReceive(hspi, transmit, out, numBytes+1, 1000);
uint8_t temp[numBytes+1];
HAL_SPI_TransmitReceive(hspi, transmit, temp, numBytes+1, 1000);
memcpy(out, &temp[1], numBytes);
CSHigh();
}

Expand Down Expand Up @@ -122,13 +125,13 @@ const IMUData LSM6DO32_Driver::ConvertRawMeasurementToStruct(const uint8_t *buf,
}
out.temp = 25.0f + out.temp / 256.0f;

out.accel.x *= 0.732;
out.accel.y *= 0.732;
out.accel.z *= 0.732;
out.accel.x *= 0.488 / 1000.0f; //g/LSB
out.accel.y *= 0.488 / 1000.0f;
out.accel.z *= 0.488 / 1000.0f;

out.gyro.x *= 8.75;
out.gyro.y *= 8.75;
out.gyro.z *= 8.75;
out.gyro.x *= 8.75f / 1000.0f; //dps/LSB
out.gyro.y *= 8.75f / 1000.0f;
out.gyro.z *= 8.75f / 1000.0f;


return out;
Expand Down
2 changes: 2 additions & 0 deletions DMA/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Ignore txt files containing notes about DMA
DMA-NOTES.txt
14 changes: 7 additions & 7 deletions LSM6DSODriver/LSM6DSOTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,13 @@ void LSM6DSOTask::Run(void * pvParams){
imu.Init(hspi_, LSM6DSO_CS_PIN, LSM6DSO_CS_PORT);

while (1) {
/* Process commands in blocking mode */
imu.readSensors(data);
imu_data = imu.bytesToStruct(data, true, true, true);
imu_data.id = 0;
DataBroker::Publish<IMUData>(&imu_data);

Command cm;
bool res = qEvtQueue->ReceiveWait(cm);
bool res = qEvtQueue->Receive(cm, 333);
if(res){

HandleCommand(cm);
Expand Down Expand Up @@ -97,9 +101,7 @@ void LSM6DSOTask::HandleRequestCommand(uint16_t taskCommand){
switch(taskCommand){
case LSM6DSOTask::IMU_SAMPLE_AND_LOG:

imu.readSensors(data);
imu_data = imu.bytesToStruct(data, true, true, true);
imu_data.id = 0;

LogData();

default:
Expand All @@ -111,8 +113,6 @@ void LSM6DSOTask::HandleRequestCommand(uint16_t taskCommand){

void LSM6DSOTask::LogData(){


DataBroker::Publish<IMUData>(&imu_data);
osDelay(10);
Command logCommand(DATA_BROKER_COMMAND, static_cast<uint16_t>(DataBrokerMessageTypes::IMU_DATA)); //change if separate publisher
LoggingTask::Inst().GetEventQueue()->Send(logCommand);
Expand Down
12 changes: 6 additions & 6 deletions LSM6DSODriver/lsm6dso.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,13 @@ IMUData LSM6DSO_Driver::bytesToStruct(const uint8_t *raw_bytes, bool accel, bool
out.accel.z = (int16_t)(raw_bytes[i+ 5] << 8 | raw_bytes[i+ 4]);
}

out.accel.x *= 0.732; // mg/LSB
out.accel.y *= 0.732;
out.accel.z *= 0.732;
out.accel.x *= 0.488 / 1000.0f; // mg/LSB
out.accel.y *= 0.488 / 1000.0f;
out.accel.z *= 0.488 / 1000.0f;

out.gyro.x *= 8.75; //mdps/LSB
out.gyro.y *= 8.75;
out.gyro.z *= 8.75;
out.gyro.x *= 8.75f / 1000.0f; //dps/LSB
out.gyro.y *= 8.75f / 1000.0f;
out.gyro.z *= 8.75f / 1000.0f;

out.temp = 25.0f + (out.temp / 256.0f);

Expand Down
8 changes: 6 additions & 2 deletions MMC5983MA_SPI/mmc5983Task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,13 @@ void MMC5983MATask::InitTask() // RTOS Task Init
void MMC5983MATask::Run(void * pvParams) // Instance Run loop for task
{
// Handle incoming commands (optional)
// receive with 0 timeout to poll
magnetometer.triggerMeasurement();
vTaskDelay(pdMS_TO_TICKS(10));
magnetometer.readData(magData);
DataBroker::Publish<MagData>(&magData);

Command cm;
if (qEvtQueue->Receive(cm, 0)) {
if (qEvtQueue->Receive(cm, 333)) {
HandleCommand(cm);
}

Expand Down
9 changes: 7 additions & 2 deletions MS5607Driver/BaroTask07.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,14 @@ void BaroTask07::Run(void * pvParams){


while (1) {
/* Process commands in blocking mode */

data = barometer.getSample();
data.id = 0;
LogData();
DataBroker::Publish<BaroData>(&data);

Command cm;
bool res = qEvtQueue->ReceiveWait(cm);
bool res = qEvtQueue->Receive(cm, 333);
if(res){

HandleCommand(cm);
Expand Down
8 changes: 6 additions & 2 deletions MS5611Driver/BaroTask11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,13 @@ void BaroTask11::Run(void * pvParams){


while (1) {
/* Process commands in blocking mode */
data = barometer.getSample();
data.id = 1;

DataBroker::Publish<BaroData>(&data);

Command cm;
bool res = qEvtQueue->ReceiveWait(cm);
bool res = qEvtQueue->Receive(cm, 333);
if(res){

HandleCommand(cm);
Expand Down
19 changes: 17 additions & 2 deletions MX66L1G45GMI/Inc/MX66L1G45GMI.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @file MX66L1G45GMI.hpp
* @author shiva
* @date Mar 26, 2025
* @brief
* @brief Header for MX66L1G45GMI Flash Memory Driver.
********************************************************************************
*/

Expand All @@ -28,6 +28,19 @@
* TYPEDEFS
************************************/

// ---< Config Struct >---
typedef void (*MX66_WriteFunc)(const uint8_t* data, uint16_t len); // Write function pointer
typedef void (*MX66_ReadFunc)(uint8_t* data, uint16_t len); // Read function pointer
typedef void (*MX66_CSFunc)(bool state); // Chip Select function pointer
typedef void (*MX66_DelayFunc)(uint32_t ms); // Delay function pointer

struct MX66_Config {
MX66_WriteFunc Write;
MX66_ReadFunc Read;
MX66_CSFunc SetCS;
MX66_DelayFunc Delay;
};

/************************************
* CLASS DEFINITIONS
************************************/
Expand All @@ -36,10 +49,12 @@
* FUNCTION DECLARATIONS
************************************/

uint32_t MX66_ReadID(void);
uint32_t MX66_ReadID(void); // Read Manufacturer and Device ID

uint8_t MX66_ReadStatus(int reg); // Read status reg1,2,3

void MX66_Init(MX66_Config* config);

void MX66_WriteStatus(int reg, uint8_t newstatus);

void MX66_ReadSFDP(uint8_t *rData);
Expand Down
70 changes: 53 additions & 17 deletions MX66L1G45GMI/MX66L1G45GMI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,29 +42,65 @@ extern SPI_HandleTypeDef hspi1;
//-------------------------------------------------------------------------------------------------
// STM32 SPI Driver
//-------------------------------------------------------------------------------------------------
void MX66_Delay(uint32_t time)
{
HAL_Delay(time);

// Create a static instance of the config
static MX66_Config io_driver = {nullptr, nullptr, nullptr, nullptr};

// Init function
void MX66_Init(MX66_Config* config) {
if(config != nullptr) {
io_driver = *config;
}
else {
SOAR_PRINT("MX66_Init: config is nullptr!\n");
}
}

void csLOW(void)
{
HAL_GPIO_WritePin(SPI_FLASH_CS_GPIO_Port, SPI_FLASH_CS_Pin, GPIO_PIN_RESET);
// Internal Helper Wrappers


void MX66_Delay(uint32_t ms) {
if(io_driver.Delay) {
io_driver.Delay(ms);
} else {
SOAR_PRINT("[MX66 ERROR] MX66_Delay called before MX66_Init!\n");
}
}

void csHIGH(void)
{
HAL_GPIO_WritePin(SPI_FLASH_CS_GPIO_Port, SPI_FLASH_CS_Pin, GPIO_PIN_SET);

void csLOW(void) {
if(io_driver.SetCS) {
io_driver.SetCS(false);
} else {
SOAR_PRINT("[MX66 ERROR] csLOW called before MX66_Init!\n");
}
}

void SPI_Write(uint8_t *data, uint16_t len)
{
HAL_SPI_Transmit(&MX66_SPI, data, len, 2000);

void csHIGH(void) {
if(io_driver.SetCS) {
io_driver.SetCS(true);
} else {
SOAR_PRINT("[MX66 ERROR] csHIGH called before MX66_Init!\n");
}
}

void SPI_Read(uint8_t *data, uint16_t len)
{
HAL_SPI_Receive(&MX66_SPI, data, len, 5000);

void SPI_Write(uint8_t *data, uint16_t len) {
if(io_driver.Write) {
io_driver.Write(data, len);
} else {
SOAR_PRINT("[MX66 ERROR] SPI_Write called before MX66_Init!\n");
}
}


void SPI_Read(uint8_t *data, uint16_t len) {
if(io_driver.Read) {
io_driver.Read(data, len);
} else {
SOAR_PRINT("[MX66 ERROR] SPI_Read called before MX66_Init!\n");
}
}

/************************************
Expand Down Expand Up @@ -173,7 +209,7 @@ void write_enable(void)
csLOW();
SPI_Write(&tData, 1);
csHIGH();
HAL_Delay(5);
MX66_Delay(5);
}

void write_disable(void)
Expand All @@ -182,7 +218,7 @@ void write_disable(void)
csLOW();
SPI_Write(&tData, 1);
csHIGH();
HAL_Delay(5);
MX66_Delay(5);
}

void MX66_Erase_Chip(void)
Expand Down
Loading