fsfw-example-stm32h7-freertos/bsp_stm32h7_freertos/main.cpp

91 lines
1.9 KiB
C++
Raw Normal View History

2021-07-12 21:50:48 +02:00
#include "hardware_init.h"
#include "boardconfig.h"
#include "OBSWVersion.h"
#include "OBSWConfig.h"
2021-07-12 23:33:05 +02:00
#if OBSW_ADD_LWIP_COMPONENTS == 1
2021-07-12 21:50:48 +02:00
#include <lwip/init.h>
2021-07-12 23:33:05 +02:00
#endif
2021-07-12 21:50:48 +02:00
#include "core/InitMission.h"
#include "core/ObjectFactory.h"
2021-07-12 23:33:05 +02:00
#include "example_common/utility/utility.h"
2021-07-12 21:50:48 +02:00
#include <fsfw/objectmanager/ObjectManager.h>
#include <fsfw/serviceinterface/ServiceInterface.h>
#include <fsfw/tasks/TaskFactory.h>
#include "FreeRTOS.h"
#include "task.h"
#include "cmsis_os.h"
#include <cstdio>
#if FSFW_CPP_OSTREAM_ENABLED == 1
#include <iostream>
#endif
#if !defined(BOARD_NAME)
#define BOARD_NAME "unknown board"
#endif
#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
void initTask(void *parameters);
/**
* @brief Core function for the STM32 FreeRTOS BSP
* @return
* @author R. Mueller, J. Meier
*/
int main() {
performHardwareInit();
xTaskCreate(initTask, "INIT_TASK", 2048, nullptr, 9, nullptr);
/* Start scheduler */
osKernelStart();
/* Should not be reached, scheduler should now be running. */
for(;;) {}
return 0;
}
void initTask(void *parameters) {
2021-07-12 23:33:05 +02:00
#if OBSW_ADD_LWIP_COMPONENTS == 1
2021-07-12 21:50:48 +02:00
/* Initialize the LwIP stack */
lwip_init();
/* Configure the Network interface */
Netif_Config();
2021-07-12 23:33:05 +02:00
#endif
2021-07-12 21:50:48 +02:00
utility::commonInitPrint("FreeRTOS", BOARD_NAME);
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::info << "Creating objects.." << std::endl;
#else
sif::printInfo("Creating objects..\n\r");
#endif
2021-07-12 23:33:05 +02:00
ObjectManager* objManager = ObjectManager::instance();
objManager->setObjectFactoryFunction(ObjectFactory::produce, nullptr);
objManager->initialize();
2021-07-12 21:50:48 +02:00
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::info << "Creating tasks.." << std::endl;
#else
sif::printInfo("Creating tasks..\n\r");
#endif
InitMission::createTasks();
TaskFactory::instance()->deleteTask(nullptr);
}