185 lines
7.9 KiB
C++
185 lines
7.9 KiB
C++
#include <fsfw/health/HealthTableIF.h>
|
|
|
|
#include "OBSWConfig.h"
|
|
#include "bsp_q7s/core/CoreController.h"
|
|
#include "bsp_q7s/core/ObjectFactory.h"
|
|
#include "busConf.h"
|
|
#include "commonObjects.h"
|
|
#include "devConf.h"
|
|
#include "fsfw_hal/linux/gpio/LinuxLibgpioIF.h"
|
|
#include "linux/ObjectFactory.h"
|
|
#include "linux/callbacks/gpioCallbacks.h"
|
|
#include "mission/core/GenericFactory.h"
|
|
|
|
void ObjectFactory::produce(void* args) {
|
|
ObjectFactory::setStatics();
|
|
HealthTableIF* healthTable = nullptr;
|
|
ObjectFactory::produceGenericObjects(&healthTable);
|
|
|
|
LinuxLibgpioIF* gpioComIF = nullptr;
|
|
UartComIF* uartComIF = nullptr;
|
|
SpiComIF* spiMainComIF = nullptr;
|
|
I2cComIF* i2cComIF = nullptr;
|
|
PowerSwitchIF* pwrSwitcher = nullptr;
|
|
SpiComIF* spiRwComIF = nullptr;
|
|
createCommunicationInterfaces(&gpioComIF, &uartComIF, &spiMainComIF, &i2cComIF, &spiRwComIF);
|
|
createTmpComponents();
|
|
new CoreController(objects::CORE_CONTROLLER);
|
|
|
|
gpioCallbacks::disableAllDecoder(gpioComIF);
|
|
createPcduComponents(gpioComIF, &pwrSwitcher);
|
|
createRadSensorComponent(gpioComIF);
|
|
createSunSensorComponents(gpioComIF, spiMainComIF, pwrSwitcher, q7s::SPI_DEFAULT_DEV);
|
|
|
|
#if OBSW_ADD_ACS_BOARD == 1
|
|
createAcsBoardComponents(gpioComIF, uartComIF, pwrSwitcher);
|
|
#endif
|
|
createHeaterComponents(gpioComIF, pwrSwitcher, healthTable);
|
|
createSolarArrayDeploymentComponents();
|
|
createPlPcduComponents(gpioComIF, spiMainComIF, pwrSwitcher);
|
|
#if OBSW_ADD_SYRLINKS == 1
|
|
#if OBSW_Q7S_EM == 1
|
|
createSyrlinksComponents(nullptr);
|
|
#else
|
|
createSyrlinksComponents(pwrSwitcher);
|
|
#endif /* OBSW_Q7S_EM == 1 */
|
|
#endif /* OBSW_ADD_SYRLINKS == 1 */
|
|
createRtdComponents(q7s::SPI_DEFAULT_DEV, gpioComIF, pwrSwitcher, spiMainComIF);
|
|
createPayloadComponents(gpioComIF);
|
|
|
|
#if OBSW_ADD_MGT == 1
|
|
createImtqComponents(pwrSwitcher);
|
|
#endif
|
|
createReactionWheelComponents(gpioComIF, pwrSwitcher);
|
|
|
|
#if OBSW_ADD_BPX_BATTERY_HANDLER == 1
|
|
createBpxBatteryComponent();
|
|
#endif
|
|
|
|
#if OBSW_ADD_STAR_TRACKER == 1
|
|
createStrComponents(pwrSwitcher);
|
|
#endif /* OBSW_ADD_STAR_TRACKER == 1 */
|
|
#if OBSW_USE_CCSDS_IP_CORE == 1
|
|
createCcsdsComponents(gpioComIF);
|
|
#endif /* OBSW_USE_CCSDS_IP_CORE == 1 */
|
|
/* Test Task */
|
|
#if OBSW_ADD_TEST_CODE == 1
|
|
createTestComponents(gpioComIF);
|
|
#endif /* OBSW_ADD_TEST_CODE == 1 */
|
|
|
|
createMiscComponents();
|
|
}
|
|
|
|
void ObjectFactory::createCcsdsComponents(LinuxLibgpioIF* gpioComIF) {
|
|
using namespace gpio;
|
|
// GPIO definitions of signals connected to the virtual channel interfaces of the PTME IP Core
|
|
GpioCookie* gpioCookiePtmeIp = new GpioCookie;
|
|
GpiodRegularByLineName* gpio = nullptr;
|
|
std::stringstream consumer;
|
|
consumer.str("PAPB VC0");
|
|
gpio = new GpiodRegularByLineName(q7s::gpioNames::PAPB_BUSY_SIGNAL_VC0, consumer.str());
|
|
gpioCookiePtmeIp->addGpio(gpioIds::VC0_PAPB_BUSY, gpio);
|
|
consumer.str("PAPB VC0");
|
|
gpio = new GpiodRegularByLineName(q7s::gpioNames::PAPB_EMPTY_SIGNAL_VC0, consumer.str());
|
|
gpioCookiePtmeIp->addGpio(gpioIds::VC0_PAPB_EMPTY, gpio);
|
|
consumer.str("PAPB VC 1");
|
|
gpio = new GpiodRegularByLineName(q7s::gpioNames::PAPB_BUSY_SIGNAL_VC1, consumer.str());
|
|
gpioCookiePtmeIp->addGpio(gpioIds::VC1_PAPB_BUSY, gpio);
|
|
consumer.str("");
|
|
consumer.str("PAPB VC 1");
|
|
gpioCookiePtmeIp->addGpio(gpioIds::VC1_PAPB_EMPTY, gpio);
|
|
consumer.str("");
|
|
consumer.str("PAPB VC 2");
|
|
gpio = new GpiodRegularByLineName(q7s::gpioNames::PAPB_BUSY_SIGNAL_VC2, consumer.str());
|
|
gpioCookiePtmeIp->addGpio(gpioIds::VC2_PAPB_BUSY, gpio);
|
|
consumer.str("");
|
|
consumer.str("PAPB VC 2");
|
|
gpio = new GpiodRegularByLineName(q7s::gpioNames::PAPB_EMPTY_SIGNAL_VC2, consumer.str());
|
|
gpioCookiePtmeIp->addGpio(gpioIds::VC2_PAPB_EMPTY, gpio);
|
|
consumer.str("");
|
|
consumer.str("PAPB VC 3");
|
|
gpio = new GpiodRegularByLineName(q7s::gpioNames::PAPB_BUSY_SIGNAL_VC3, consumer.str());
|
|
gpioCookiePtmeIp->addGpio(gpioIds::VC3_PAPB_BUSY, gpio);
|
|
consumer.str("");
|
|
consumer.str("PAPB VC 3");
|
|
gpio = new GpiodRegularByLineName(q7s::gpioNames::PAPB_EMPTY_SIGNAL_VC3, consumer.str());
|
|
gpioCookiePtmeIp->addGpio(gpioIds::VC3_PAPB_EMPTY, gpio);
|
|
|
|
gpioChecker(gpioComIF->addGpios(gpioCookiePtmeIp), "PTME PAPB VCs");
|
|
|
|
// Creating virtual channel interfaces
|
|
VcInterfaceIF* vc0 =
|
|
new PapbVcInterface(gpioComIF, gpioIds::VC0_PAPB_BUSY, gpioIds::VC0_PAPB_EMPTY, q7s::UIO_PTME,
|
|
q7s::uiomapids::PTME_VC0);
|
|
VcInterfaceIF* vc1 =
|
|
new PapbVcInterface(gpioComIF, gpioIds::VC1_PAPB_BUSY, gpioIds::VC1_PAPB_EMPTY, q7s::UIO_PTME,
|
|
q7s::uiomapids::PTME_VC1);
|
|
VcInterfaceIF* vc2 =
|
|
new PapbVcInterface(gpioComIF, gpioIds::VC2_PAPB_BUSY, gpioIds::VC2_PAPB_EMPTY, q7s::UIO_PTME,
|
|
q7s::uiomapids::PTME_VC2);
|
|
VcInterfaceIF* vc3 =
|
|
new PapbVcInterface(gpioComIF, gpioIds::VC3_PAPB_BUSY, gpioIds::VC3_PAPB_EMPTY, q7s::UIO_PTME,
|
|
q7s::uiomapids::PTME_VC3);
|
|
|
|
// Creating ptme object and adding virtual channel interfaces
|
|
Ptme* ptme = new Ptme(objects::PTME);
|
|
ptme->addVcInterface(ccsds::VC0, vc0);
|
|
ptme->addVcInterface(ccsds::VC1, vc1);
|
|
ptme->addVcInterface(ccsds::VC2, vc2);
|
|
ptme->addVcInterface(ccsds::VC3, vc3);
|
|
|
|
AxiPtmeConfig* axiPtmeConfig =
|
|
new AxiPtmeConfig(objects::AXI_PTME_CONFIG, q7s::UIO_PTME, q7s::uiomapids::PTME_CONFIG);
|
|
PtmeConfig* ptmeConfig = new PtmeConfig(objects::PTME_CONFIG, axiPtmeConfig);
|
|
#if OBSW_ENABLE_SYRLINKS_TRANSMIT_TIMEOUT == 1
|
|
// Set to high value when not sending via syrlinks
|
|
static const uint32_t TRANSMITTER_TIMEOUT = 86400000; // 1 day
|
|
#else
|
|
static const uint32_t TRANSMITTER_TIMEOUT = 900000; // 15 minutes
|
|
#endif
|
|
CCSDSHandler* ccsdsHandler = new CCSDSHandler(
|
|
objects::CCSDS_HANDLER, objects::PTME, objects::CCSDS_PACKET_DISTRIBUTOR, ptmeConfig,
|
|
gpioComIF, gpioIds::RS485_EN_TX_CLOCK, gpioIds::RS485_EN_TX_DATA, TRANSMITTER_TIMEOUT);
|
|
|
|
VirtualChannel* vc = nullptr;
|
|
vc = new VirtualChannel(ccsds::VC0, common::VC0_QUEUE_SIZE, objects::CCSDS_HANDLER);
|
|
ccsdsHandler->addVirtualChannel(ccsds::VC0, vc);
|
|
vc = new VirtualChannel(ccsds::VC1, common::VC1_QUEUE_SIZE, objects::CCSDS_HANDLER);
|
|
ccsdsHandler->addVirtualChannel(ccsds::VC1, vc);
|
|
vc = new VirtualChannel(ccsds::VC2, common::VC2_QUEUE_SIZE, objects::CCSDS_HANDLER);
|
|
ccsdsHandler->addVirtualChannel(ccsds::VC2, vc);
|
|
vc = new VirtualChannel(ccsds::VC3, common::VC3_QUEUE_SIZE, objects::CCSDS_HANDLER);
|
|
ccsdsHandler->addVirtualChannel(ccsds::VC3, vc);
|
|
|
|
GpioCookie* gpioCookiePdec = new GpioCookie;
|
|
consumer.str("");
|
|
consumer << "0x" << std::hex << objects::PDEC_HANDLER;
|
|
// GPIO also low after linux boot (specified by device-tree)
|
|
gpio = new GpiodRegularByLineName(q7s::gpioNames::PDEC_RESET, consumer.str(), Direction::OUT,
|
|
Levels::LOW);
|
|
gpioCookiePdec->addGpio(gpioIds::PDEC_RESET, gpio);
|
|
|
|
gpioChecker(gpioComIF->addGpios(gpioCookiePdec), "PDEC");
|
|
|
|
new PdecHandler(objects::PDEC_HANDLER, objects::CCSDS_HANDLER, gpioComIF, gpioIds::PDEC_RESET,
|
|
q7s::UIO_PDEC_CONFIG_MEMORY, q7s::UIO_PDEC_RAM, q7s::UIO_PDEC_REGISTERS);
|
|
|
|
GpioCookie* gpioRS485Chip = new GpioCookie;
|
|
gpio = new GpiodRegularByLineName(q7s::gpioNames::RS485_EN_TX_CLOCK, "RS485 Transceiver",
|
|
Direction::OUT, Levels::LOW);
|
|
gpioRS485Chip->addGpio(gpioIds::RS485_EN_TX_CLOCK, gpio);
|
|
gpio = new GpiodRegularByLineName(q7s::gpioNames::RS485_EN_TX_DATA, "RS485 Transceiver",
|
|
Direction::OUT, Levels::LOW);
|
|
gpioRS485Chip->addGpio(gpioIds::RS485_EN_TX_DATA, gpio);
|
|
|
|
// Default configuration enables RX channels (RXEN = LOW)
|
|
gpio = new GpiodRegularByLineName(q7s::gpioNames::RS485_EN_RX_CLOCK, "RS485 Transceiver",
|
|
Direction::OUT, Levels::LOW);
|
|
gpioRS485Chip->addGpio(gpioIds::RS485_EN_RX_CLOCK, gpio);
|
|
gpio = new GpiodRegularByLineName(q7s::gpioNames::RS485_EN_RX_DATA, "RS485 Transceiver",
|
|
Direction::OUT, Levels::LOW);
|
|
gpioRS485Chip->addGpio(gpioIds::RS485_EN_RX_DATA, gpio);
|
|
|
|
gpioChecker(gpioComIF->addGpios(gpioRS485Chip), "RS485 Transceiver");
|
|
}
|