This repository has been archived on 2021-11-24. You can view files and clone it, but cannot push or open issues or pull requests.
fsfw_example_public/bsp_stm32_freertos/core/ObjectFactory.cpp

101 lines
3.4 KiB
C++
Raw Normal View History

2021-04-27 17:22:34 +02:00
#include "ObjectFactory.h"
2021-06-11 10:51:15 +02:00
#include "OBSWConfig.h"
#include "devices/devAddresses.h"
#include "objects/systemObjectList.h"
2021-04-27 17:22:34 +02:00
#include <mission/utility/TmFunnel.h>
#include <mission/core/GenericFactory.h>
#include <common/stm32_nucleo/networking/UdpTcLwIpPollingTask.h>
#include <common/stm32_nucleo/networking/TmTcLwIpUdpBridge.h>
#include <common/stm32_nucleo/STM32TestTask.h>
#include <fsfw/datapoollocal/LocalDataPoolManager.h>
#include <fsfw/monitoring/MonitoringMessageContent.h>
#include <fsfw/storagemanager/PoolManager.h>
#include <fsfw/tmtcpacket/pus/TmPacketStored.h>
#include <fsfw/tmtcservices/CommandingServiceBase.h>
#include <fsfw/tmtcservices/PusServiceBase.h>
2021-06-10 21:31:42 +02:00
2021-06-09 23:53:44 +02:00
#if OBSW_PERFORM_L3GD20H_TEST == 1
#include "fsfw_hal/stm32h7/spi/SpiCookie.h"
#include "fsfw_hal/stm32h7/spi/SpiComIF.h"
#include "fsfw_hal/devicehandlers/GyroL3GD20Handler.h"
2021-06-10 21:31:42 +02:00
#include "fsfw_hal/stm32h7/spi/stm32h743ziSpi.h"
#include "fsfw_hal/stm32h7/spi/spiCore.h"
DMA_HandleTypeDef* txHandle = nullptr;
DMA_HandleTypeDef* rxHandle = nullptr;
2021-06-09 23:53:44 +02:00
#endif
2021-06-05 20:16:57 +02:00
void ObjectFactory::produce(void* args) {
2021-04-27 17:22:34 +02:00
/* Located inside GenericFactory source file */
Factory::setStaticFrameworkObjectIds();
#if OBSW_ADD_CORE_COMPONENTS == 1
{
LocalPool::LocalPoolConfig poolCfg = {
{100, 32}, {30, 64}, {10, 128}, {2, 1024}
};
new PoolManager(objects::TC_STORE, poolCfg);
}
{
LocalPool::LocalPoolConfig poolCfg = {
{100, 32}, {30, 64}, {10, 128}, {2, 1024}
};
new PoolManager(objects::TM_STORE, poolCfg);
}
{
LocalPool::LocalPoolConfig poolCfg = {
{100, 32}, {30, 64}, {10, 128}, {2, 1024}
};
new PoolManager(objects::IPC_STORE, poolCfg);
}
/* UDP Server */
new TmTcLwIpUdpBridge(objects::UDP_BRIDGE,
objects::CCSDS_DISTRIBUTOR, objects::TM_STORE, objects::TC_STORE);
new UdpTcLwIpPollingTask(objects::UDP_POLLING_TASK, objects::UDP_BRIDGE);
#endif /* OBSW_ADD_CORE_COMPONENTS == 1 */
ObjectFactory::produceGenericObjects();
/* Test Device Handler */
new STM32TestTask(objects::TEST_TASK, false, true);
2021-06-09 23:53:44 +02:00
#if OBSW_PERFORM_L3GD20H_TEST == 1
2021-06-10 21:31:42 +02:00
spi::MspCfgBase* mspCfg = nullptr;
2021-06-11 10:51:15 +02:00
spi::TransferModes transferMode = spi::TransferModes::DMA;
2021-06-10 21:31:42 +02:00
if(transferMode == spi::TransferModes::POLLING) {
auto typedCfg = new spi::MspPollingConfigStruct();
spi::h743zi::standardPollingCfg(*typedCfg);
mspCfg = typedCfg;
}
else if(transferMode == spi::TransferModes::INTERRUPT) {
auto typedCfg = new spi::MspIrqConfigStruct();
spi::h743zi::standardInterruptCfg(*typedCfg, IrqPriorities::HIGHEST_FREERTOS);
mspCfg = typedCfg;
}
else if(transferMode == spi::TransferModes::DMA) {
auto typedCfg = new spi::MspDmaConfigStruct();
txHandle = new DMA_HandleTypeDef();
rxHandle = new DMA_HandleTypeDef();
spi::setDmaHandles(txHandle, rxHandle);
spi::h743zi::standardDmaCfg(*typedCfg, IrqPriorities::HIGHEST_FREERTOS,
IrqPriorities::HIGHEST_FREERTOS, IrqPriorities::HIGHEST_FREERTOS);
mspCfg = typedCfg;
}
new SpiComIF(objects::SPI_COM_IF);
2021-06-11 10:51:15 +02:00
auto spiCookie = new SpiCookie(devaddress::L3GD20H, spi::SpiBus::SPI_1, transferMode, mspCfg,
3900000, spi::SpiModes::MODE_3, GPIO_PIN_14, GPIOD, 32);
2021-06-09 23:53:44 +02:00
auto gyroDevice = new GyroHandlerL3GD20H(objects::SPI_DEVICE_TEST, objects::SPI_COM_IF,
spiCookie);
gyroDevice->setStartUpImmediately();
2021-06-10 19:09:56 +02:00
gyroDevice->setGoNormalModeAtStartup();
2021-06-09 23:53:44 +02:00
#endif
2021-04-27 17:22:34 +02:00
}