eive-obsw/bsp_q7s/em/emObjectFactory.cpp

187 lines
6.2 KiB
C++
Raw Normal View History

2022-10-26 17:11:57 +02:00
#include <bsp_q7s/callbacks/q7sGpioCallbacks.h>
2023-07-03 16:55:45 +02:00
#include <bsp_q7s/objectFactory.h>
2023-03-14 11:21:37 +01:00
#include <dummies/ComCookieDummy.h>
#include <dummies/PcduHandlerDummy.h>
2022-05-19 15:28:02 +02:00
#include <fsfw/health/HealthTableIF.h>
2022-09-15 13:15:39 +02:00
#include <fsfw/power/DummyPowerSwitcher.h>
#include <fsfw_hal/common/gpio/GpioCookie.h>
2023-03-26 16:13:54 +02:00
#include <mission/power/gsDefs.h>
2023-04-06 16:50:33 +02:00
#include <mission/system/systemTree.h>
2023-02-22 15:28:24 +01:00
#include <mission/utility/DummySdCardManager.h>
2022-05-23 18:37:04 +02:00
2021-05-17 16:53:06 +02:00
#include "OBSWConfig.h"
2022-01-17 13:48:55 +01:00
#include "bsp_q7s/core/CoreController.h"
2021-08-17 17:11:59 +02:00
#include "busConf.h"
2023-06-17 15:28:05 +02:00
#include "common/config/devices/addresses.h"
2022-01-17 13:48:55 +01:00
#include "devConf.h"
2023-03-31 12:11:31 +02:00
#include "dummies/helperFactory.h"
2022-09-16 12:28:39 +02:00
#include "eive/objects.h"
#include "fsfw_hal/linux/gpio/LinuxLibgpioIF.h"
2022-03-26 16:38:42 +01:00
#include "linux/ObjectFactory.h"
#include "linux/callbacks/gpioCallbacks.h"
2023-03-26 16:54:40 +02:00
#include "mission/genericFactory.h"
2023-03-24 21:34:03 +01:00
#include "mission/system/com/comModeTree.h"
2020-09-30 17:17:01 +02:00
2021-09-20 17:47:29 +02:00
void ObjectFactory::produce(void* args) {
2022-01-17 13:48:55 +01:00
ObjectFactory::setStatics();
2022-05-19 15:28:02 +02:00
HealthTableIF* healthTable = nullptr;
PusTmFunnel* pusFunnel = nullptr;
CfdpTmFunnel* cfdpFunnel = nullptr;
2023-03-13 17:53:02 +01:00
StorageManagerIF* ipcStore = nullptr;
StorageManagerIF* tmStore = nullptr;
2023-03-26 15:28:00 +02:00
bool enableHkSets = false;
#if OBSW_ENABLE_PERIODIC_HK == 1
enableHkSets = true;
#endif
2023-03-13 17:53:02 +01:00
PersistentTmStores stores;
2023-07-03 16:55:45 +02:00
readFirmwareVersion();
2023-02-22 18:06:34 +01:00
ObjectFactory::produceGenericObjects(&healthTable, &pusFunnel, &cfdpFunnel,
2023-06-22 16:09:24 +02:00
*SdCardManager::instance(), &ipcStore, &tmStore, stores, 200,
enableHkSets);
2022-01-17 13:48:55 +01:00
LinuxLibgpioIF* gpioComIF = nullptr;
2022-11-10 18:07:59 +01:00
SerialComIF* uartComIF = nullptr;
SpiComIF* spiMainComIF = nullptr;
2022-02-02 17:36:40 +01:00
I2cComIF* i2cComIF = nullptr;
2023-02-21 00:51:18 +01:00
createCommunicationInterfaces(&gpioComIF, &uartComIF, &spiMainComIF, &i2cComIF);
2023-06-17 17:01:01 +02:00
// Adding GPIOs for chip select decoding and initializing them.
2022-10-26 17:11:57 +02:00
q7s::gpioCallbacks::initSpiCsDecoder(gpioComIF);
gpioCallbacks::disableAllDecoder(gpioComIF);
2023-06-15 08:39:06 +02:00
createPlI2cResetGpio(gpioComIF);
// Hardware is usually not connected to EM, so we need to create dummies which replace lower
// level components.
dummy::DummyCfg dummyCfg;
dummyCfg.addCoreCtrlCfg = false;
2023-05-12 09:40:31 +02:00
dummyCfg.addCamSwitcherDummy = false;
#if OBSW_ADD_SYRLINKS == 1
dummyCfg.addSyrlinksDummies = false;
#endif
2023-05-11 15:05:44 +02:00
#if OBSW_ADD_PLOC_SUPERVISOR == 1 || OBSW_ADD_PLOC_MPSOC == 1
dummyCfg.addPlocDummies = false;
#endif
2023-06-17 15:28:05 +02:00
#if OBSW_ADD_TMP_DEVICES == 1
std::vector<std::pair<object_id_t, address_t>> tmpDevsToAdd = {{
{objects::TMP1075_HANDLER_PLPCDU_0, addresses::TMP1075_PLPCDU_0},
{objects::TMP1075_HANDLER_PLPCDU_1, addresses::TMP1075_PLPCDU_1},
{objects::TMP1075_HANDLER_IF_BOARD, addresses::TMP1075_IF_BOARD},
}};
2023-07-10 11:03:17 +02:00
createTmpComponents(tmpDevsToAdd);
2023-06-18 13:38:00 +02:00
dummy::Tmp1075Cfg tmpCfg{};
2023-06-17 17:01:01 +02:00
tmpCfg.addTcsBrd0 = true;
tmpCfg.addTcsBrd1 = true;
tmpCfg.addPlPcdu0 = false;
tmpCfg.addPlPcdu1 = false;
tmpCfg.addIfBrd = false;
dummyCfg.tmp1075Cfg = tmpCfg;
2023-06-17 15:28:05 +02:00
#endif
2022-11-21 14:01:31 +01:00
#if OBSW_ADD_GOMSPACE_PCDU == 1
dummyCfg.addPowerDummies = false;
// The ACU broke.
dummyCfg.addOnlyAcuDummy = true;
2022-11-21 14:01:31 +01:00
#endif
2023-06-29 16:40:21 +02:00
#if OBSW_ADD_STAR_TRACKER == 1
dummyCfg.addStrDummy = false;
#endif
2023-07-14 14:31:02 +02:00
#if OBSW_ADD_SCEX_DEVICE == 0
dummyCfg.addScexDummy = true;
#endif
2023-04-26 17:00:04 +02:00
#if OBSW_ADD_BPX_BATTERY_HANDLER == 1
dummyCfg.addBpxBattDummy = false;
#endif
2023-02-08 16:45:19 +01:00
#if OBSW_ADD_ACS_BOARD == 1
dummyCfg.addAcsBoardDummies = false;
#endif
2023-08-02 14:08:10 +02:00
#if OBSW_ADD_PL_PCDU == 0
dummyCfg.addPlPcduDummy = true;
#endif
2022-11-21 14:01:31 +01:00
PowerSwitchIF* pwrSwitcher = nullptr;
#if OBSW_ADD_GOMSPACE_PCDU == 0
2023-04-14 21:44:23 +02:00
pwrSwitcher = new PcduHandlerDummy(objects::PCDU_HANDLER);
2022-11-21 14:01:31 +01:00
#else
2023-03-26 15:28:00 +02:00
createPcduComponents(gpioComIF, &pwrSwitcher, enableHkSets);
2022-11-21 14:01:31 +01:00
#endif
2023-04-11 15:34:46 +02:00
satsystem::EIVE_SYSTEM.setI2cRecoveryParams(pwrSwitcher);
2021-07-19 12:44:43 +02:00
2023-05-24 11:04:07 +02:00
dummy::createDummies(dummyCfg, *pwrSwitcher, gpioComIF, enableHkSets);
2022-11-21 14:01:31 +01:00
2023-04-06 17:49:34 +02:00
new CoreController(objects::CORE_CONTROLLER, enableHkSets);
2022-09-15 13:15:39 +02:00
2023-08-02 14:08:10 +02:00
auto* stackHandler = new Stack5VHandler(*pwrSwitcher);
2023-08-17 10:27:33 +02:00
static_cast<void>(stackHandler);
2023-08-02 14:08:10 +02:00
2023-07-02 14:02:37 +02:00
// Initialize chip select to avoid SPI bus issues.
2023-05-30 09:22:59 +02:00
createRadSensorChipSelect(gpioComIF);
2023-07-02 14:02:37 +02:00
#if OBSW_ADD_ACS_BOARD == 1
2023-05-11 15:05:44 +02:00
createAcsBoardComponents(*spiMainComIF, gpioComIF, uartComIF, *pwrSwitcher, true,
adis1650x::Type::ADIS16507);
#else
// Still add all GPIOs for EM.
GpioCookie* acsBoardGpios = new GpioCookie();
createAcsBoardGpios(*acsBoardGpios);
gpioChecker(gpioComIF->addGpios(acsBoardGpios), "ACS Board");
2022-01-19 18:05:17 +01:00
#endif
2021-05-26 14:16:16 +02:00
2023-07-03 17:13:11 +02:00
const char* battAndImtqI2cDev = q7s::I2C_PL_EIVE;
if (core::FW_VERSION_MAJOR >= 4) {
battAndImtqI2cDev = q7s::I2C_PS_EIVE;
}
2023-07-19 14:38:45 +02:00
static_cast<void>(battAndImtqI2cDev);
2022-01-27 15:26:07 +01:00
#if OBSW_ADD_MGT == 1
2023-07-03 17:13:11 +02:00
createImtqComponents(pwrSwitcher, enableHkSets, battAndImtqI2cDev);
2022-01-27 15:26:07 +01:00
#endif
2022-10-26 15:30:04 +02:00
#if OBSW_ADD_SYRLINKS == 1
createSyrlinksComponents(pwrSwitcher);
#endif /* OBSW_ADD_SYRLINKS == 1 */
2022-10-26 15:30:04 +02:00
#if OBSW_ADD_RW == 1
createReactionWheelComponents(gpioComIF, pwrSwitcher);
2022-10-26 15:30:04 +02:00
#endif
2020-09-30 17:17:01 +02:00
2022-02-02 17:36:40 +01:00
#if OBSW_ADD_BPX_BATTERY_HANDLER == 1
2023-07-03 17:13:11 +02:00
createBpxBatteryComponent(enableHkSets, battAndImtqI2cDev);
2022-04-26 10:37:25 +02:00
#endif
2021-07-23 17:48:11 +02:00
2021-08-17 19:50:48 +02:00
#if OBSW_ADD_STAR_TRACKER == 1
createStrComponents(pwrSwitcher);
#endif /* OBSW_ADD_STAR_TRACKER == 1 */
2023-03-13 17:53:02 +01:00
2023-08-02 14:08:10 +02:00
#if OBSW_ADD_PL_PCDU == 1
createPlPcduComponents(gpioComIF, spiMainComIF, pwrSwitcher, *stackHandler);
#endif
2023-05-11 15:05:44 +02:00
createPayloadComponents(gpioComIF, *pwrSwitcher);
#if OBSW_ADD_CCSDS_IP_CORES == 1
CcsdsIpCoreHandler* ipCoreHandler = nullptr;
2023-03-13 17:53:02 +01:00
CcsdsComponentArgs ccsdsArgs(*gpioComIF, *ipcStore, *tmStore, stores, *pusFunnel, *cfdpFunnel,
&ipCoreHandler);
createCcsdsComponents(ccsdsArgs);
#if OBSW_TM_TO_PTME == 1
2023-03-13 17:53:02 +01:00
if (ccsdsArgs.liveDestination != nullptr) {
pusFunnel->addLiveDestination("VC0 LIVE TM", *ccsdsArgs.liveDestination, 0);
2023-06-09 18:25:59 +02:00
cfdpFunnel->addLiveDestination("VC0 LIVE TM", *ccsdsArgs.liveDestination, 0);
2023-03-13 17:53:02 +01:00
}
#endif
#endif /* OBSW_ADD_CCSDS_IP_CORES == 1 */
2022-01-17 13:48:55 +01:00
/* Test Task */
#if OBSW_ADD_TEST_CODE == 1
2022-01-17 13:48:55 +01:00
createTestComponents(gpioComIF);
#endif /* OBSW_ADD_TEST_CODE == 1 */
2022-10-20 17:16:37 +02:00
#if OBSW_ADD_SCEX_DEVICE == 1
2022-11-21 14:16:21 +01:00
createScexComponents(q7s::UART_SCEX_DEV, pwrSwitcher, *SdCardManager::instance(), false,
2023-05-10 11:24:12 +02:00
power::Switches::PDU1_CH5_SOLAR_CELL_EXP_5V);
2022-10-20 17:16:37 +02:00
#endif
2023-03-26 15:28:00 +02:00
createAcsController(true, enableHkSets);
2023-09-28 12:00:04 +02:00
createPowerController(true, enableHkSets);
2023-04-03 14:22:58 +02:00
HeaterHandler* heaterHandler;
createHeaterComponents(gpioComIF, pwrSwitcher, healthTable, heaterHandler);
createThermalController(*heaterHandler, true);
satsystem::init(true);
}