chore: Cleanup for Demo

This commit is contained in:
CarlWachter
2024-07-05 14:06:49 +02:00
parent fd7c123a5e
commit 1f6c939630
44 changed files with 432 additions and 7326 deletions

BIN
App/Src/tasks/.DS_Store vendored Normal file

Binary file not shown.

View File

@@ -0,0 +1,45 @@
/*
* can_task.cpp
*
* Created on: 10 Dec 2023
* Author: Carl
*/
#include <sta/tacos.hpp>
#include <tasks/can_receiver.hpp>
namespace demo
{
CanReceiver::CanReceiver(uint32_t canID)
: TacosThread("CAN Receiver", osPriorityNormal)
{
setCanID(canID);
}
void CanReceiver::init()
{
}
void CanReceiver::func()
{
CanSysMsg msg;
if (CAN_queue_.get(&msg, osWaitForever))
{
STA_DEBUG_PRINTF("Received Message!\n"
"Payload Byte 0: %d\n"
"Payload Byte 1: %d\n"
"Payload Byte 2: %d\n"
"Payload Byte 3: %d\n"
"Payload Byte 4: %d\n"
"Payload Byte 5: %d\n"
"Payload Byte 6: %d\n"
"Payload Byte 7: %d\n",
msg.payload[0], msg.payload[1],
msg.payload[2], msg.payload[3],
msg.payload[4], msg.payload[5],
msg.payload[6], msg.payload[7]);
}
}
} // namespace demo

View File

@@ -0,0 +1,41 @@
/*
* can_task.cpp
*
* Created on: 10 Dec 2023
* Author: Carl
*/
#include <sta/tacos.hpp>
#include <tasks/can_spam.hpp>
namespace demo
{
CanSpam::CanSpam(uint32_t canID)
: TacosThread("CAN Spam", osPriorityNormal)
{
setCanID(canID);
}
void CanSpam::init()
{
}
void CanSpam::func()
{
CanSysMsg msg;
// Send some random stuff
msg.payload[0] = 1;
msg.payload[1] = 2;
msg.payload[2] = 3;
msg.header.sid = getCanID();
msg.header.format = 0;
sta::tacos::queueCanBusMsg(msg, 0);
STA_DEBUG_PRINTLN("Can Task sent message");
this->periodicDelay(1); // Delay to ensure 1 Hz rate.
}
} // namespace demo

View File

@@ -1,51 +0,0 @@
/*
* can_task.cpp
*
* Created on: 10 Dec 2023
* Author: Carl
*/
#include <tasks/can_task.hpp>
#include <sta/debug/debug.hpp>
#include <sta/rtos/debug/heap_stats.hpp>
#include "can.h"
#include <sta/tacos.hpp>
#include <cmsis_os2.h>
namespace demo
{
CanTask::CanTask(const char* name, uint32_t canID)
: TacosThread(name, osPriorityNormal)
{
setCanID(canID);
}
void CanTask::init()
{
}
void CanTask::func()
{
//STA_DEBUG_PRINTLN("Can Task awaiting message");
if (CAN_queue_.available() > 0)
{
// Receiving message
CanSysMsg msg;
CAN_queue_.get(&msg);
STA_DEBUG_PRINTLN("Can Task received message");
// Sending it back with one changed bit
msg.payload[1] = 3;
msg.header.sid = getCanID();
msg.header.eid = 0;
msg.header.format = 0;
sta::tacos::queueCanBusMsg(msg, 0);
STA_DEBUG_PRINTLN("Can Task sent message");
HAL_Delay(500);
}
}
} // namespace demo

View File

@@ -1,58 +0,0 @@
/*
* can_task.cpp
*
* Created on: 10 Dec 2023
* Author: Carl
*/
#include <tasks/thermo.hpp>
#include <sta/debug/debug.hpp>
#include <sta/rtos/debug/heap_stats.hpp>
#include <gpio.h>
#include <spi.h>
#include <sta/MAX31855.hpp>
#include <sta/devices/stm32/bus/spi.hpp>
#include <sta/rtos/mutex.hpp>
#include <cmsis_os2.h>
namespace demo
{
ThermoTask::ThermoTask()
: TacosThread("Thermo", osPriorityNormal)
{
}
void ThermoTask::init()
{
mutex = new sta::RtosMutex("spi2");
spi2 = new sta::STM32SPI(&hspi2, 16000000, mutex);
device_ = new sta::STM32SPIDevice(spi2, &cs_pin);
tc = new sta::MAX31855(device_); //create driver object
}
void ThermoTask::func()
{
//STA_DEBUG_HEAP_STATS();
//canController.sendFrame(txHeader, payload);
//STA_DEBUG_HEAP_STATS();
//fuck off other pins
HAL_GPIO_WritePin(GPIOE,GPIO_PIN_12, GPIO_PIN_SET);
HAL_GPIO_WritePin(GPIOB,GPIO_PIN_10, GPIO_PIN_SET);
HAL_GPIO_WritePin(GPIOE,GPIO_PIN_15, GPIO_PIN_SET);
HAL_GPIO_WritePin(GPIOE,GPIO_PIN_14, GPIO_PIN_SET);
tc->update(); // update internal values
float temperature = tc->getTemp(); //read out temperature in degrees Celsius
float referenceTemperature = tc->getReferenceTemp(); // read out reference temperature in degrees Celsius
uint8_t status = tc->getStatus(); //read out status of the update
HAL_Delay(1000);
}
} // namespace demo