fsfw-example-stm32h7-rtems/bsp_stm32h7_rtems/main.cpp

54 lines
1.5 KiB
C++

#include "core/ObjectFactory.h"
#include "core/InitMission.h"
#include "stm32h7xx_nucleo.h"
#include "hardware_init.h"
#include "example_common/mission/utility/compile_time.h"
#include "fsfw/objectmanager/ObjectManager.h"
#include "fsfw/serviceinterface/ServiceInterface.h"
#include "fsfw/timemanager/Clock.h"
#include <rtems.h>
#include <rtems/console.h>
#include <rtems/rtems/clock.h>
#define BOARD_NAME "stm32h743zi-nucleo"
ObjectManagerIF *objectManager = nullptr;
#if FSFW_CPP_OSTREAM_ENABLED == 1
ServiceInterfaceStream sif::debug("DEBUG", true);
ServiceInterfaceStream sif::info("INFO", true);
ServiceInterfaceStream sif::warning("WARNING", true);
ServiceInterfaceStream sif::error("ERROR", true);
#endif
/**
* @brief Core function for the RTEMS BSP, called in Init function.
* @return
* @author R. Mueller
*/
int main() {
hardware_init();
printf("\n\r%s-- FSFW Example (RTEMS) --\n", sif::ANSI_COLOR_RESET);
printf("-- Compiled for %s --\n", BOARD_NAME);
printf("-- Compiled on %s %s --\n\r",__DATE__, __TIME__);
timeval timeToSet;
timeToSet.tv_sec = UNIX_TIMESTAMP;
timeToSet.tv_usec = 0;
ReturnValue_t clockStatus = Clock::setClock(&timeToSet);
if(clockStatus != HasReturnvaluesIF::RETURN_OK) {
sif::printError("Clock configuration failed!\n");
}
else {
sif::printInfo("Clock configured successfully.\n");
}
ObjectManager::instance()->setObjectFactoryFunction(ObjectFactory::produce, nullptr);
ObjectManager::instance()->initialize();
InitMission::createTasks();
}