Unverified Commit a121960e authored by Robin Mueller's avatar Robin Mueller
Browse files

apply auto-formatter

parent bbd2d759
......@@ -20,51 +20,50 @@ PayloadPeriodicTask glob::payloadTestTaskHandle("TEST_TASK", 1000);
#if VOR_ADD_UART_OBC_COM_TASK == 1
ObcComHandler glob::obcComTask("OBC_RS485_TASK", UART_TASK_PERIOD,
UartPortType::PORTA_UARTA, nullptr, 115200, true);
UartPortType::PORTA_UARTA, nullptr, 115200,
true);
#endif /* VOR_ADD_UART_TASKS == 0 */
void glob::produceObjects() {
// All objects are instantiated globally.
// All objects are instantiated globally.
}
int glob::initializeObjects() {
uint8_t initErrCounter = 0;
const char* taskName = nullptr;
int result = 0;
uint8_t initErrCounter = 0;
const char *taskName = nullptr;
int result = 0;
#if VOR_ADD_TEST_TASKS == 1
result = glob::payloadTestTaskHandle.initialize();
if(result != 0) {
initErrCounter++;
taskName = glob::payloadTestTaskHandle.getName();
VOR_CError("Object Initialization of Task %s failed\r\n", taskName);
}
glob::payloadTestTaskHandle.setInitialized();
result = glob::payloadTestTaskHandle.initialize();
if (result != 0) {
initErrCounter++;
taskName = glob::payloadTestTaskHandle.getName();
VOR_CError("Object Initialization of Task %s failed\r\n", taskName);
}
glob::payloadTestTaskHandle.setInitialized();
#if VOR_ADD_LED_TASK == 1
result = glob::ledTaskHandle.initialize();
if(result != 0) {
initErrCounter++;
taskName = glob::ledTaskHandle.getName();
VOR_CError("Object Initialization of Task %s failed\r\n", taskName);
}
glob::ledTaskHandle.setInitialized();
result = glob::ledTaskHandle.initialize();
if (result != 0) {
initErrCounter++;
taskName = glob::ledTaskHandle.getName();
VOR_CError("Object Initialization of Task %s failed\r\n", taskName);
}
glob::ledTaskHandle.setInitialized();
#endif /* VOR_ADD_TEST_TASKS == 1 */
#endif /* VOR_ADD_TEST_TASKS == 1 */
#if VOR_ADD_UART_OBC_COM_TASK == 1
result = glob::obcComTask.initialize();
if(result != 0) {
initErrCounter++;
taskName = glob::obcComTask.getName();
VOR_CError("Object Initialization of Task %s failed\r\n", taskName);
}
glob::obcComTask.setInitialized();
result = glob::obcComTask.initialize();
if (result != 0) {
initErrCounter++;
taskName = glob::obcComTask.getName();
VOR_CError("Object Initialization of Task %s failed\r\n", taskName);
}
glob::obcComTask.setInitialized();
#else
#endif
return initErrCounter;
return initErrCounter;
}
......@@ -6,18 +6,18 @@
#include "common/peripherals/UartHandler.h"
#include "common/test/LedTask.h"
#include "test/PayloadTestTask.h"
#include "mission/peripherals/ObcComHandler.h"
#include "common/test/UartTestTask.h"
#include "mission/peripherals/ObcComHandler.h"
#include "test/PayloadTestTask.h"
struct GlobParams {
GlobParams(uint64_t counter, uint16_t tcSequenceCount,
uint16_t tmSequenceCount):
counter(counter), tcSequenceCount(tcSequenceCount),
tmSequenceCount(tmSequenceCount) {};
uint64_t counter;
uint16_t tcSequenceCount;
uint16_t tmSequenceCount;
GlobParams(uint64_t counter, uint16_t tcSequenceCount,
uint16_t tmSequenceCount)
: counter(counter), tcSequenceCount(tcSequenceCount),
tmSequenceCount(tmSequenceCount){};
uint64_t counter;
uint16_t tcSequenceCount;
uint16_t tmSequenceCount;
};
namespace glob {
......@@ -47,6 +47,6 @@ void produceObjects();
*/
int initializeObjects();
}
} // namespace glob
#endif /* MISSION_CORE_GLOBALOBJECTS_H_ */
......@@ -11,35 +11,30 @@ int performOneShotOperation();
*/
int loop() {
if(glob::globparams.counter == 0) {
performOneShotOperation();
}
if (glob::globparams.counter == 0) {
performOneShotOperation();
}
// The core operation will run the periodic task handler with
// the period specified in the setup function.
// The core operation will run the periodic task handler with
// the period specified in the setup function.
#if VOR_ADD_TEST_TASKS == 1
#if VOR_ADD_LED_TASK == 1
glob::ledTaskHandle.taskCoreOperation();
glob::ledTaskHandle.taskCoreOperation();
#endif
glob::payloadTestTaskHandle.taskCoreOperation();
glob::payloadTestTaskHandle.taskCoreOperation();
#endif /* VOR_ADD_TEST_TASKS == 1 */
#if VOR_ADD_UART_TASKS == 1
glob::uartTaskHandle->taskCoreOperation();
glob::uartTaskHandle->taskCoreOperation();
#else
#if VOR_ADD_UART_TEST_TASK == 1
glob::uartTestTaskHandle.taskCoreOperation();
glob::uartTestTaskHandle.taskCoreOperation();
#endif
#endif
return 0;
return 0;
}
int performOneShotOperation() {
return 0;
}
int performOneShotOperation() { return 0; }
void VOR_SPI0_IRQHandler (void) {
}
void VOR_SPI0_IRQHandler(void) {}
void VOR_SPI1_IRQHandler (void) {
}
void VOR_SPI1_IRQHandler(void) {}
void VOR_SPI2_IRQHandler (void) {
}
void VOR_SPI2_IRQHandler(void) {}
void VOR_I2C0_MS_IRQHandler (void) {
void VOR_I2C0_MS_IRQHandler(void) {}
}
void VOR_I2C0_SL_IRQHandler(void) {}
void VOR_I2C0_SL_IRQHandler (void) {
void VOR_I2C1_MS_IRQHandler(void) {}
}
void VOR_I2C1_MS_IRQHandler (void) {
}
void VOR_I2C1_SL_IRQHandler (void) {
}
void VOR_I2C1_SL_IRQHandler(void) {}
#include "setup.h"
#include "globalObjects.h"
#include "VORConfig.h"
#include "commonConfig.h"
#include "common/setup.h"
#include "commonConfig.h"
#include "globalObjects.h"
#include "vorago/common/va108xx.h"
#include "vorago/reb/reb_log.h"
#if defined(freeRTOS)
#include <common/utility/led.h>
#include <freertos/FreeRTOS.h>
#include <freertos/task.h>
#include <common/utility/led.h>
void dumbTask(void* args);
void dumbTask(void *args);
#endif
#include <cstdio>
......@@ -26,70 +26,66 @@ static const BinaryType binType = BinaryType::NVM_2;
static const BinaryType binType = BinaryType::REGULAR;
#endif
static const char* const BOARD_STRING = "REB1";
static const char *const BOARD_STRING = "REB1";
/**
* This is called once in main before loop is called in a permanent loop.
* @param args
* @return
*/
int setup(void* args) {
common::performCommonSetup();
int setup(void *args) {
common::performCommonSetup();
#if VOR_VERBOSE_LEVEL >= 1
printf("-- SOURCE Vorago On-Board Software --\r\n");
printf("-- Built for %s board --\r\n", BOARD_STRING);
printf("-- Software version %s v%d.%d --\r\n", SW_NAME, SW_VERSION, SW_SUBVERSION);
printf("-- Compiled: %s %s --\r\n", __DATE__, __TIME__);
printf("-- Payload Binary ");
printf("-- SOURCE Vorago On-Board Software --\r\n");
printf("-- Built for %s board --\r\n", BOARD_STRING);
printf("-- Software version %s v%d.%d --\r\n", SW_NAME, SW_VERSION,
SW_SUBVERSION);
printf("-- Compiled: %s %s --\r\n", __DATE__, __TIME__);
printf("-- Payload Binary ");
if(binType == BinaryType::NVM_1) {
printf("A --\r\n");
}
else if(binType == BinaryType::NVM_2) {
printf("B --\r\n");
}
else {
printf("Regular --\r\n");
}
if (binType == BinaryType::NVM_1) {
printf("A --\r\n");
} else if (binType == BinaryType::NVM_2) {
printf("B --\r\n");
} else {
printf("Regular --\r\n");
}
#else
// Some basic output as a sanity check.
printf("\r\nVORAGO OBSW\r\n");
// Some basic output as a sanity check.
printf("\r\nVORAGO OBSW\r\n");
#endif
/* Produce all global objects */
/* Produce all global objects */
#if VOR_VERBOSE_LEVEL >= 1
VOR_CInfo("Producing global objects..\r\n");
VOR_CInfo("Producing global objects..\r\n");
#endif
glob::produceObjects();
int initResult = glob::initializeObjects();
if(initResult > 0) {
VOR_CError("setup: Counted %d failed object initializations.",
initResult);
}
glob::produceObjects();
int initResult = glob::initializeObjects();
if (initResult > 0) {
VOR_CError("setup: Counted %d failed object initializations.", initResult);
}
#if defined(freeRTOS)
xTaskCreate(&dumbTask, "TASK", 200, nullptr, 5, nullptr);
xTaskCreate(&dumbTask, "TASK", 200, nullptr, 5, nullptr);
size_t remainingRtosHeap = xPortGetFreeHeapSize();
VOR_CInfo("Remaining FreeRTOS heap: %d\n\r", (int) remainingRtosHeap);
/* Might not be used. If it is used, tasks will be used
instead of a loop(), so all tasks need to be configured.
This function will then not exit because scheduler is taking control! */
vTaskStartScheduler();
size_t remainingRtosHeap = xPortGetFreeHeapSize();
VOR_CInfo("Remaining FreeRTOS heap: %d\n\r", (int)remainingRtosHeap);
/* Might not be used. If it is used, tasks will be used
instead of a loop(), so all tasks need to be configured.
This function will then not exit because scheduler is taking control! */
vTaskStartScheduler();
#endif
return 0;
return 0;
}
#if defined(freeRTOS)
void dumbTask(void* args) {
VOR_CInfo("FreeRTOS Test..\n\r");
while(1) {
VOR_CInfo("Test\n\r");
toggleGreenLed1();
vTaskDelay(1000);
}
void dumbTask(void *args) {
VOR_CInfo("FreeRTOS Test..\n\r");
while (1) {
VOR_CInfo("Test\n\r");
toggleGreenLed1();
vTaskDelay(1000);
}
}
#endif
......@@ -3,12 +3,8 @@
#include <cstdint>
enum class BinaryType {
REGULAR,
NVM_1,
NVM_2
};
enum class BinaryType { REGULAR, NVM_1, NVM_2 };
int setup(void* args);
int setup(void *args);
#endif /* MISSION_POWER_CORE_SETUP_H_ */
#include "PayloadHighPriorityHandler.h"
void PayloadHighPriorityHandler::checkCondition() {
// check some state, for example a pin or a flag (boolean set by interrupt).
bool someCondition = true;
if(someCondition) {
performHighPriorityTask();
}
// check some state, for example a pin or a flag (boolean set by interrupt).
bool someCondition = true;
if (someCondition) {
performHighPriorityTask();
}
}
void PayloadHighPriorityHandler::performHighPriorityTask() {
// do something important here
// do something important here
}
......@@ -9,10 +9,8 @@
*/
class PayloadHighPriorityHandler {
public:
static void checkCondition();
static void performHighPriorityTask();
static void checkCondition();
static void performHighPriorityTask();
};
#endif /* MISSION_PAYLOAD_HIGHPRIO_PAYLOADHIGHPRIORITYHANDLER_H_ */
#include <mission/core/setup.h>
#include <mission/core/loop.h>
#include <mission/core/globalObjects.h>
#include <mission/core/loop.h>
#include <mission/core/setup.h>
int main(void) {
int setupResult = setup(nullptr);
if(setupResult != 0) {
// failure value for now, can be checked here.
// software reset or command to PCDU to restart?
// but be careful when doing this!
}
for(;;) {
int loopResult = loop();
glob::globparams.counter ++;
if(loopResult != 0) {
// failure value for now, can be checked here.
// software reset or command to PCDU to restart?
// but be careful when doing this!
}
}
int setupResult = setup(nullptr);
if (setupResult != 0) {
// failure value for now, can be checked here.
// software reset or command to PCDU to restart?
// but be careful when doing this!
}
for (;;) {
int loopResult = loop();
glob::globparams.counter++;
if (loopResult != 0) {
// failure value for now, can be checked here.
// software reset or command to PCDU to restart?
// but be careful when doing this!
}
}
}
......@@ -3,11 +3,11 @@
#include <va108xx.h>
#include <vorago/reb/reb_log.h>
GpioHandler::GpioHandler() {
}
GpioHandler::GpioHandler() {}
int GpioHandler::initialize() {
// Enable all required clocks
VOR_SYSCONFIG->PERIPHERAL_CLK_ENABLE |= CLK_ENABLE_GPIO | CLK_ENABLE_PORTA | CLK_ENABLE_PORTB;
return 0;
// Enable all required clocks
VOR_SYSCONFIG->PERIPHERAL_CLK_ENABLE |=
CLK_ENABLE_GPIO | CLK_ENABLE_PORTA | CLK_ENABLE_PORTB;
return 0;
}
......@@ -5,16 +5,14 @@
class GpioHandler {
public:
GpioHandler();
/**
* You need to call this before using other member functions!
* @return
*/
int initialize();
GpioHandler();
/**
* You need to call this before using other member functions!
* @return
*/
int initialize();
private:
};
#endif /* MISSION_CORE_GPIOHANDLER_H_ */
#include "ObcComHandler.h"
ObcComHandler::ObcComHandler(std::string name, uint32_t periodMs, Rs485Config cfg):
Rs485Handler(name, periodMs, cfg) {
}
ObcComHandler::ObcComHandler(std::string name, uint32_t periodMs,
Rs485Config cfg)
: Rs485Handler(name, periodMs, cfg) {}
int ObcComHandler::handlePacketParsing() {
// TODO: Scan the USLP packets and and unpack commands here
return 0;
// TODO: Scan the USLP packets and and unpack commands here
return 0;
}
......@@ -4,18 +4,16 @@
#include "VORConfig.h"
#include "common/peripherals/Rs485Handler.h"
class ObcComHandler: public Rs485Handler<
VOR_UART_OBC_MAX_PACKET_SIZE,
UART_OBC_REPLY_BUFFER_SIZE,
UART_OBC_MAX_NUMBER_OF_REPLY_QUEUE_PACKETS
> {
class ObcComHandler
: public Rs485Handler<VOR_UART_OBC_MAX_PACKET_SIZE,
UART_OBC_REPLY_BUFFER_SIZE,
UART_OBC_MAX_NUMBER_OF_REPLY_QUEUE_PACKETS> {
public:
ObcComHandler(std::string name, uint32_t periodMs, Rs485Config cfg);
ObcComHandler(std::string name, uint32_t periodMs, Rs485Config cfg);
int handlePacketParsing() override;
int handlePacketParsing() override;
private:
};
#endif /* MISSION_PERIPHERALS_SYRLINKSHANDLER_H_ */
#include "PayloadTestTask.h"
PayloadPeriodicTask::PayloadPeriodicTask(std::string name, uint32_t period,
void (*deadlineMissedFunction)(void)):
TestTask(name, period, deadlineMissedFunction) {
}
void (*deadlineMissedFunction)(void))
: TestTask(name, period, deadlineMissedFunction) {}
PayloadPeriodicTask::~PayloadPeriodicTask() {
}
PayloadPeriodicTask::~PayloadPeriodicTask() {}
int PayloadPeriodicTask::initialize() {
return 0;
}
int PayloadPeriodicTask::initialize() { return 0; }
int PayloadPeriodicTask::performOneShotAction() {
return 0;
}
int PayloadPeriodicTask::performOneShotAction() { return 0; }
int PayloadPeriodicTask::performPeriodicAction() {
//VOR_CInfo("Hallo Welt\n\r");
return 0;
}
int PayloadPeriodicTask::performActionA() {
return 0;
// VOR_CInfo("Hallo Welt\n\r");
return 0;
}
int PayloadPeriodicTask::performActionA() { return 0; }
int PayloadPeriodicTask::performActionB() {
return 0;
}
int PayloadPeriodicTask::performActionB() { return 0; }
......@@ -3,22 +3,19 @@
#include <common/test/TestTask.h>
class PayloadPeriodicTask: public TestTask {
class PayloadPeriodicTask : public TestTask {
public:
PayloadPeriodicTask(std::string name, uint32_t period,
void (*deadlineMissedFunction)(void) = nullptr);
virtual ~ PayloadPeriodicTask();
PayloadPeriodicTask(std::string name, uint32_t period,
void (*deadlineMissedFunction)(void) = nullptr);
virtual ~PayloadPeriodicTask();
int initialize() override;
int performOneShotAction() override;
int performPeriodicAction() override;
int performActionA() override;
int performActionB() override;
int initialize() override;
int performOneShotAction() override;
int performPeriodicAction() override;
int performActionA() override;
int performActionB() override;
private:
};
#endif /* MISSION_PAYLOAD_PERIODIC_PAYLOADTESTTASK_H_ */
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment