2022-10-26 17:11:57 +02:00
|
|
|
#include <bsp_q7s/callbacks/q7sGpioCallbacks.h>
|
2023-07-03 17:16:51 +02:00
|
|
|
#include <bsp_q7s/objectFactory.h>
|
2023-05-11 15:05:44 +02:00
|
|
|
#include <devices/gpioIds.h>
|
2023-03-10 16:49:12 +01:00
|
|
|
#include <fsfw/storagemanager/LocalPool.h>
|
|
|
|
#include <fsfw/storagemanager/PoolManager.h>
|
2023-03-26 16:13:54 +02:00
|
|
|
#include <mission/power/gsDefs.h>
|
2023-04-06 17:01:28 +02:00
|
|
|
#include <mission/system/EiveSystem.h>
|
2022-09-27 18:54:48 +02:00
|
|
|
|
2022-05-11 01:48:26 +02:00
|
|
|
#include "OBSWConfig.h"
|
|
|
|
#include "bsp_q7s/core/CoreController.h"
|
|
|
|
#include "busConf.h"
|
|
|
|
#include "devConf.h"
|
2023-07-03 17:16:51 +02:00
|
|
|
#include "devices/addresses.h"
|
2022-09-16 12:28:39 +02:00
|
|
|
#include "eive/objects.h"
|
2022-05-11 01:48:26 +02:00
|
|
|
#include "fsfw_hal/linux/gpio/LinuxLibgpioIF.h"
|
|
|
|
#include "linux/ObjectFactory.h"
|
|
|
|
#include "linux/callbacks/gpioCallbacks.h"
|
2023-03-26 16:42:00 +02:00
|
|
|
#include "mission/genericFactory.h"
|
2023-04-06 17:01:28 +02:00
|
|
|
#include "mission/system/systemTree.h"
|
2023-03-09 01:32:27 +01:00
|
|
|
#include "mission/tmtc/tmFilters.h"
|
2022-05-11 01:48:26 +02:00
|
|
|
|
|
|
|
void ObjectFactory::produce(void* args) {
|
|
|
|
ObjectFactory::setStatics();
|
2022-05-12 19:12:12 +02:00
|
|
|
HealthTableIF* healthTable = nullptr;
|
2022-11-02 10:26:45 +01:00
|
|
|
PusTmFunnel* pusFunnel = nullptr;
|
|
|
|
CfdpTmFunnel* cfdpFunnel = nullptr;
|
2023-03-09 19:42:20 +01:00
|
|
|
StorageManagerIF* ipcStore = nullptr;
|
|
|
|
StorageManagerIF* tmStore = nullptr;
|
2023-03-09 01:32:27 +01:00
|
|
|
|
2023-03-26 15:28:00 +02:00
|
|
|
bool enableHkSets = false;
|
|
|
|
#if OBSW_ENABLE_PERIODIC_HK == 1
|
|
|
|
enableHkSets = true;
|
|
|
|
#endif
|
|
|
|
|
2023-03-09 19:42:20 +01:00
|
|
|
PersistentTmStores stores;
|
2023-07-03 16:55:45 +02:00
|
|
|
readFirmwareVersion();
|
2022-12-13 14:19:43 +01:00
|
|
|
ObjectFactory::produceGenericObjects(&healthTable, &pusFunnel, &cfdpFunnel,
|
2023-06-27 17:36:52 +02:00
|
|
|
*SdCardManager::instance(), &ipcStore, &tmStore, stores, 200,
|
|
|
|
true);
|
2022-05-11 01:48:26 +02:00
|
|
|
|
|
|
|
LinuxLibgpioIF* gpioComIF = nullptr;
|
2022-11-10 18:07:59 +01:00
|
|
|
SerialComIF* uartComIF = nullptr;
|
2022-05-11 01:48:26 +02:00
|
|
|
SpiComIF* spiMainComIF = nullptr;
|
|
|
|
I2cComIF* i2cComIF = nullptr;
|
|
|
|
PowerSwitchIF* pwrSwitcher = nullptr;
|
2023-02-16 16:08:17 +01:00
|
|
|
createCommunicationInterfaces(&gpioComIF, &uartComIF, &spiMainComIF, &i2cComIF);
|
2022-10-26 17:11:57 +02:00
|
|
|
/* Adding gpios for chip select decoding to the gpioComIf */
|
|
|
|
q7s::gpioCallbacks::initSpiCsDecoder(gpioComIF);
|
2022-05-11 01:48:26 +02:00
|
|
|
gpioCallbacks::disableAllDecoder(gpioComIF);
|
2023-06-15 08:39:06 +02:00
|
|
|
createPlI2cResetGpio(gpioComIF);
|
2022-10-26 17:11:57 +02:00
|
|
|
|
2023-04-06 18:06:56 +02:00
|
|
|
new CoreController(objects::CORE_CONTROLLER, enableHkSets);
|
2023-03-26 15:28:00 +02:00
|
|
|
createPcduComponents(gpioComIF, &pwrSwitcher, enableHkSets);
|
2023-04-06 19:23:45 +02:00
|
|
|
satsystem::EIVE_SYSTEM.setI2cRecoveryParams(pwrSwitcher);
|
2023-04-06 17:01:28 +02:00
|
|
|
|
2022-12-21 14:11:31 +01:00
|
|
|
auto* stackHandler = new Stack5VHandler(*pwrSwitcher);
|
|
|
|
|
2022-12-20 11:45:46 +01:00
|
|
|
#if OBSW_ADD_RAD_SENSORS == 1
|
2022-12-21 14:11:31 +01:00
|
|
|
createRadSensorComponent(gpioComIF, *stackHandler);
|
2022-12-20 11:45:46 +01:00
|
|
|
#endif
|
|
|
|
#if OBSW_ADD_SUN_SENSORS == 1
|
2023-02-13 11:49:26 +01:00
|
|
|
createSunSensorComponents(gpioComIF, spiMainComIF, *pwrSwitcher, q7s::SPI_DEFAULT_DEV, true);
|
2022-12-20 11:45:46 +01:00
|
|
|
#endif
|
2022-05-11 01:48:26 +02:00
|
|
|
|
|
|
|
#if OBSW_ADD_ACS_BOARD == 1
|
2023-05-11 15:05:44 +02:00
|
|
|
createAcsBoardComponents(*spiMainComIF, gpioComIF, uartComIF, *pwrSwitcher, true,
|
|
|
|
adis1650x::Type::ADIS16505);
|
2022-05-11 01:48:26 +02:00
|
|
|
#endif
|
2022-11-25 11:01:06 +01:00
|
|
|
HeaterHandler* heaterHandler;
|
|
|
|
createHeaterComponents(gpioComIF, pwrSwitcher, healthTable, heaterHandler);
|
2022-10-27 08:48:46 +02:00
|
|
|
#if OBSW_ADD_TMP_DEVICES == 1
|
2023-06-17 15:28:05 +02:00
|
|
|
std::vector<std::pair<object_id_t, address_t>> tmpDevsToAdd = {{
|
|
|
|
{objects::TMP1075_HANDLER_TCS_0, addresses::TMP1075_TCS_0},
|
|
|
|
{objects::TMP1075_HANDLER_TCS_1, addresses::TMP1075_TCS_1},
|
|
|
|
{objects::TMP1075_HANDLER_PLPCDU_0, addresses::TMP1075_PLPCDU_0},
|
|
|
|
// damaged
|
|
|
|
// {objects::TMP1075_HANDLER_PLPCDU_1, addresses::TMP1075_PLPCDU_1},
|
|
|
|
{objects::TMP1075_HANDLER_IF_BOARD, addresses::TMP1075_IF_BOARD},
|
|
|
|
}};
|
2023-07-03 17:13:11 +02:00
|
|
|
const char* tmpI2cDev = q7s::I2C_PS_EIVE;
|
|
|
|
if (core::FW_VERSION_MAJOR >= 4) {
|
|
|
|
tmpI2cDev = q7s::I2C_PL_EIVE;
|
|
|
|
}
|
|
|
|
createTmpComponents(tmpDevsToAdd, tmpI2cDev);
|
2022-10-27 08:48:46 +02:00
|
|
|
#endif
|
2022-10-12 13:56:25 +02:00
|
|
|
createSolarArrayDeploymentComponents(*pwrSwitcher, *gpioComIF);
|
2022-12-22 11:10:55 +01:00
|
|
|
createPlPcduComponents(gpioComIF, spiMainComIF, pwrSwitcher, *stackHandler);
|
2022-05-11 01:48:26 +02:00
|
|
|
#if OBSW_ADD_SYRLINKS == 1
|
|
|
|
createSyrlinksComponents(pwrSwitcher);
|
|
|
|
#endif /* OBSW_ADD_SYRLINKS == 1 */
|
2022-05-12 12:21:47 +02:00
|
|
|
createRtdComponents(q7s::SPI_DEFAULT_DEV, gpioComIF, pwrSwitcher, spiMainComIF);
|
2022-11-10 13:09:31 +01:00
|
|
|
createPayloadComponents(gpioComIF, *pwrSwitcher);
|
2022-05-11 01:48:26 +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;
|
|
|
|
}
|
2022-05-11 01:48:26 +02:00
|
|
|
#if OBSW_ADD_MGT == 1
|
2023-07-03 17:13:11 +02:00
|
|
|
createImtqComponents(pwrSwitcher, enableHkSets, battAndImtqI2cDev);
|
2022-05-11 01:48:26 +02:00
|
|
|
#endif
|
|
|
|
createReactionWheelComponents(gpioComIF, pwrSwitcher);
|
|
|
|
|
|
|
|
#if OBSW_ADD_BPX_BATTERY_HANDLER == 1
|
2023-07-03 17:13:11 +02:00
|
|
|
createBpxBatteryComponent(enableHkSets, battAndImtqI2cDev);
|
2022-05-11 01:48:26 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if OBSW_ADD_STAR_TRACKER == 1
|
|
|
|
createStrComponents(pwrSwitcher);
|
|
|
|
#endif /* OBSW_ADD_STAR_TRACKER == 1 */
|
2023-03-13 17:53:02 +01:00
|
|
|
|
2022-10-26 16:11:34 +02:00
|
|
|
#if OBSW_ADD_CCSDS_IP_CORES == 1
|
2022-11-02 10:26:45 +01:00
|
|
|
CcsdsIpCoreHandler* ipCoreHandler = nullptr;
|
2023-03-10 02:05:51 +01:00
|
|
|
CcsdsComponentArgs ccsdsArgs(*gpioComIF, *ipcStore, *tmStore, stores, *pusFunnel, *cfdpFunnel,
|
|
|
|
&ipCoreHandler);
|
2023-03-09 19:42:20 +01:00
|
|
|
createCcsdsComponents(ccsdsArgs);
|
2022-11-02 10:26:45 +01:00
|
|
|
#if OBSW_TM_TO_PTME == 1
|
2023-03-09 20:16:00 +01:00
|
|
|
if (ccsdsArgs.liveDestination != nullptr) {
|
2023-03-09 19:52:13 +01:00
|
|
|
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-09 19:52:13 +01:00
|
|
|
}
|
2022-11-02 10:26:45 +01:00
|
|
|
#endif
|
2022-10-26 16:11:34 +02:00
|
|
|
#endif /* OBSW_ADD_CCSDS_IP_CORES == 1 */
|
2022-09-27 17:36:19 +02:00
|
|
|
|
|
|
|
#if OBSW_ADD_SCEX_DEVICE == 1
|
2022-09-28 17:01:40 +02:00
|
|
|
createScexComponents(q7s::UART_SCEX_DEV, pwrSwitcher, *SdCardManager::instance(), false,
|
2023-03-18 11:17:24 +01:00
|
|
|
power::Switches::PDU1_CH5_SOLAR_CELL_EXP_5V);
|
2022-09-27 17:36:19 +02:00
|
|
|
#endif
|
2022-05-11 01:48:26 +02:00
|
|
|
/* Test Task */
|
|
|
|
#if OBSW_ADD_TEST_CODE == 1
|
|
|
|
createTestComponents(gpioComIF);
|
|
|
|
#endif /* OBSW_ADD_TEST_CODE == 1 */
|
|
|
|
|
|
|
|
createMiscComponents();
|
2023-06-18 17:36:50 +02:00
|
|
|
createThermalController(*heaterHandler, false);
|
2023-03-26 15:28:00 +02:00
|
|
|
createAcsController(true, enableHkSets);
|
2022-05-25 10:25:40 +02:00
|
|
|
satsystem::init();
|
2022-05-11 01:48:26 +02:00
|
|
|
}
|