This commit is contained in:
@ -1,6 +1,11 @@
|
||||
add_subdirectory(csp)
|
||||
add_subdirectory(utility)
|
||||
add_subdirectory(callbacks)
|
||||
add_subdirectory(boardtest)
|
||||
add_subdirectory(devices)
|
||||
add_subdirectory(fsfwconfig)
|
||||
add_subdirectory(obc)
|
||||
add_subdirectory(obc)
|
||||
|
||||
target_sources(${OBSW_NAME} PUBLIC
|
||||
ObjectFactory.cpp
|
||||
)
|
286
linux/ObjectFactory.cpp
Normal file
286
linux/ObjectFactory.cpp
Normal file
@ -0,0 +1,286 @@
|
||||
#include "ObjectFactory.h"
|
||||
|
||||
#include <fsfw/power/PowerSwitchIF.h>
|
||||
#include <fsfw_hal/common/gpio/GpioCookie.h>
|
||||
#include <fsfw_hal/common/gpio/GpioIF.h>
|
||||
#include <fsfw_hal/common/gpio/gpioDefinitions.h>
|
||||
#include <fsfw_hal/linux/spi/SpiComIF.h>
|
||||
#include <fsfw_hal/linux/spi/SpiCookie.h>
|
||||
#include <linux/callbacks/gpioCallbacks.h>
|
||||
#include <mission/devices/Max31865PT1000Handler.h>
|
||||
#include <mission/devices/SusHandler.h>
|
||||
#include <mission/system/RtdFdir.h>
|
||||
#include <mission/system/SusAssembly.h>
|
||||
#include <mission/system/SusFdir.h>
|
||||
#include <mission/system/TcsBoardAssembly.h>
|
||||
|
||||
#include "OBSWConfig.h"
|
||||
#include "devConf.h"
|
||||
#include "devices/addresses.h"
|
||||
#include "devices/gpioIds.h"
|
||||
|
||||
void ObjectFactory::createSunSensorComponents(GpioIF* gpioComIF, SpiComIF* spiComIF,
|
||||
PowerSwitchIF* pwrSwitcher, std::string spiDev) {
|
||||
using namespace gpio;
|
||||
GpioCookie* gpioCookieSus = new GpioCookie();
|
||||
GpioCallback* susgpio = nullptr;
|
||||
|
||||
susgpio = new GpioCallback("Chip select SUS 0", Direction::OUT, Levels::HIGH,
|
||||
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
|
||||
gpioCookieSus->addGpio(gpioIds::CS_SUS_0, susgpio);
|
||||
susgpio = new GpioCallback("Chip select SUS 1", Direction::OUT, Levels::HIGH,
|
||||
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
|
||||
gpioCookieSus->addGpio(gpioIds::CS_SUS_1, susgpio);
|
||||
susgpio = new GpioCallback("Chip select SUS 2", Direction::OUT, Levels::HIGH,
|
||||
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
|
||||
gpioCookieSus->addGpio(gpioIds::CS_SUS_2, susgpio);
|
||||
susgpio = new GpioCallback("Chip select SUS 3", Direction::OUT, Levels::HIGH,
|
||||
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
|
||||
gpioCookieSus->addGpio(gpioIds::CS_SUS_3, susgpio);
|
||||
susgpio = new GpioCallback("Chip select SUS 4", Direction::OUT, Levels::HIGH,
|
||||
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
|
||||
gpioCookieSus->addGpio(gpioIds::CS_SUS_4, susgpio);
|
||||
susgpio = new GpioCallback("Chip select SUS 5", Direction::OUT, Levels::HIGH,
|
||||
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
|
||||
gpioCookieSus->addGpio(gpioIds::CS_SUS_5, susgpio);
|
||||
susgpio = new GpioCallback("Chip select SUS 6", Direction::OUT, Levels::HIGH,
|
||||
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
|
||||
gpioCookieSus->addGpio(gpioIds::CS_SUS_6, susgpio);
|
||||
susgpio = new GpioCallback("Chip select SUS 7", Direction::OUT, Levels::HIGH,
|
||||
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
|
||||
gpioCookieSus->addGpio(gpioIds::CS_SUS_7, susgpio);
|
||||
susgpio = new GpioCallback("Chip select SUS 8", Direction::OUT, Levels::HIGH,
|
||||
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
|
||||
gpioCookieSus->addGpio(gpioIds::CS_SUS_8, susgpio);
|
||||
susgpio = new GpioCallback("Chip select SUS 9", Direction::OUT, Levels::HIGH,
|
||||
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
|
||||
gpioCookieSus->addGpio(gpioIds::CS_SUS_9, susgpio);
|
||||
susgpio = new GpioCallback("Chip select SUS 10", Direction::OUT, Levels::HIGH,
|
||||
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
|
||||
gpioCookieSus->addGpio(gpioIds::CS_SUS_10, susgpio);
|
||||
susgpio = new GpioCallback("Chip select SUS 11", Direction::OUT, Levels::HIGH,
|
||||
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
|
||||
gpioCookieSus->addGpio(gpioIds::CS_SUS_11, susgpio);
|
||||
|
||||
gpioComIF->addGpios(gpioCookieSus);
|
||||
|
||||
#if OBSW_ADD_SUN_SENSORS == 1
|
||||
SusFdir* fdir = nullptr;
|
||||
std::array<SusHandler*, 12> susHandlers = {};
|
||||
SpiCookie* spiCookie =
|
||||
new SpiCookie(addresses::SUS_0, gpioIds::CS_SUS_0, spiDev, SUS::MAX_CMD_SIZE,
|
||||
spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ);
|
||||
susHandlers[0] = new SusHandler(objects::SUS_0, 0, objects::SPI_COM_IF, spiCookie);
|
||||
fdir = new SusFdir(objects::SUS_0);
|
||||
susHandlers[0]->setParent(objects::SUS_BOARD_ASS);
|
||||
susHandlers[0]->setCustomFdir(fdir);
|
||||
|
||||
spiCookie = new SpiCookie(addresses::SUS_1, gpioIds::CS_SUS_1, spiDev, SUS::MAX_CMD_SIZE,
|
||||
spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ);
|
||||
susHandlers[1] = new SusHandler(objects::SUS_1, 1, objects::SPI_COM_IF, spiCookie);
|
||||
fdir = new SusFdir(objects::SUS_1);
|
||||
susHandlers[1]->setParent(objects::SUS_BOARD_ASS);
|
||||
susHandlers[1]->setCustomFdir(fdir);
|
||||
|
||||
spiCookie = new SpiCookie(addresses::SUS_2, gpioIds::CS_SUS_2, spiDev, SUS::MAX_CMD_SIZE,
|
||||
spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ);
|
||||
susHandlers[2] = new SusHandler(objects::SUS_2, 2, objects::SPI_COM_IF, spiCookie);
|
||||
fdir = new SusFdir(objects::SUS_2);
|
||||
susHandlers[2]->setParent(objects::SUS_BOARD_ASS);
|
||||
susHandlers[2]->setCustomFdir(fdir);
|
||||
|
||||
spiCookie = new SpiCookie(addresses::SUS_3, gpioIds::CS_SUS_3, spiDev, SUS::MAX_CMD_SIZE,
|
||||
spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ);
|
||||
susHandlers[3] = new SusHandler(objects::SUS_3, 3, objects::SPI_COM_IF, spiCookie);
|
||||
fdir = new SusFdir(objects::SUS_3);
|
||||
susHandlers[3]->setParent(objects::SUS_BOARD_ASS);
|
||||
susHandlers[3]->setCustomFdir(fdir);
|
||||
|
||||
spiCookie = new SpiCookie(addresses::SUS_4, gpioIds::CS_SUS_4, spiDev, SUS::MAX_CMD_SIZE,
|
||||
spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ);
|
||||
susHandlers[4] = new SusHandler(objects::SUS_4, 4, objects::SPI_COM_IF, spiCookie);
|
||||
fdir = new SusFdir(objects::SUS_4);
|
||||
susHandlers[4]->setParent(objects::SUS_BOARD_ASS);
|
||||
susHandlers[4]->setCustomFdir(fdir);
|
||||
|
||||
spiCookie = new SpiCookie(addresses::SUS_5, gpioIds::CS_SUS_5, spiDev, SUS::MAX_CMD_SIZE,
|
||||
spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ);
|
||||
susHandlers[5] = new SusHandler(objects::SUS_5, 5, objects::SPI_COM_IF, spiCookie);
|
||||
fdir = new SusFdir(objects::SUS_5);
|
||||
susHandlers[5]->setParent(objects::SUS_BOARD_ASS);
|
||||
susHandlers[5]->setCustomFdir(fdir);
|
||||
|
||||
spiCookie = new SpiCookie(addresses::SUS_6, gpioIds::CS_SUS_6, spiDev, SUS::MAX_CMD_SIZE,
|
||||
spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ);
|
||||
susHandlers[6] = new SusHandler(objects::SUS_6, 6, objects::SPI_COM_IF, spiCookie);
|
||||
fdir = new SusFdir(objects::SUS_6);
|
||||
susHandlers[6]->setParent(objects::SUS_BOARD_ASS);
|
||||
susHandlers[6]->setCustomFdir(fdir);
|
||||
|
||||
spiCookie = new SpiCookie(addresses::SUS_7, gpioIds::CS_SUS_7, spiDev, SUS::MAX_CMD_SIZE,
|
||||
spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ);
|
||||
susHandlers[7] = new SusHandler(objects::SUS_7, 7, objects::SPI_COM_IF, spiCookie);
|
||||
fdir = new SusFdir(objects::SUS_7);
|
||||
susHandlers[7]->setParent(objects::SUS_BOARD_ASS);
|
||||
susHandlers[7]->setCustomFdir(fdir);
|
||||
|
||||
spiCookie = new SpiCookie(addresses::SUS_8, gpioIds::CS_SUS_8, spiDev, SUS::MAX_CMD_SIZE,
|
||||
spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ);
|
||||
susHandlers[8] = new SusHandler(objects::SUS_8, 8, objects::SPI_COM_IF, spiCookie);
|
||||
fdir = new SusFdir(objects::SUS_8);
|
||||
susHandlers[8]->setParent(objects::SUS_BOARD_ASS);
|
||||
susHandlers[8]->setCustomFdir(fdir);
|
||||
|
||||
spiCookie = new SpiCookie(addresses::SUS_9, gpioIds::CS_SUS_9, spiDev, SUS::MAX_CMD_SIZE,
|
||||
spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ);
|
||||
susHandlers[9] = new SusHandler(objects::SUS_9, 9, objects::SPI_COM_IF, spiCookie);
|
||||
fdir = new SusFdir(objects::SUS_9);
|
||||
susHandlers[9]->setParent(objects::SUS_BOARD_ASS);
|
||||
susHandlers[9]->setCustomFdir(fdir);
|
||||
|
||||
spiCookie = new SpiCookie(addresses::SUS_10, gpioIds::CS_SUS_10, spiDev, SUS::MAX_CMD_SIZE,
|
||||
spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ);
|
||||
susHandlers[10] = new SusHandler(objects::SUS_10, 10, objects::SPI_COM_IF, spiCookie);
|
||||
fdir = new SusFdir(objects::SUS_10);
|
||||
susHandlers[10]->setParent(objects::SUS_BOARD_ASS);
|
||||
susHandlers[10]->setCustomFdir(fdir);
|
||||
|
||||
spiCookie = new SpiCookie(addresses::SUS_11, gpioIds::CS_SUS_11, spiDev, SUS::MAX_CMD_SIZE,
|
||||
spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ);
|
||||
susHandlers[11] = new SusHandler(objects::SUS_11, 11, objects::SPI_COM_IF, spiCookie);
|
||||
fdir = new SusFdir(objects::SUS_11);
|
||||
susHandlers[11]->setParent(objects::SUS_BOARD_ASS);
|
||||
susHandlers[11]->setCustomFdir(fdir);
|
||||
|
||||
for (auto& sus : susHandlers) {
|
||||
if (sus != nullptr) {
|
||||
#if OBSW_TEST_SUS == 1
|
||||
sus->setStartUpImmediately();
|
||||
sus->setToGoToNormalMode(true);
|
||||
#endif
|
||||
#if OBSW_DEBUG_SUS == 1
|
||||
sus->enablePeriodicPrintout(true, 3);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
std::array<object_id_t, 12> susIds = {objects::SUS_0, objects::SUS_1, objects::SUS_2,
|
||||
objects::SUS_3, objects::SUS_4, objects::SUS_5,
|
||||
objects::SUS_6, objects::SUS_7, objects::SUS_8,
|
||||
objects::SUS_9, objects::SUS_10, objects::SUS_11};
|
||||
SusAssHelper susAssHelper = SusAssHelper(susIds);
|
||||
auto susAss =
|
||||
new SusAssembly(objects::SUS_BOARD_ASS, objects::NO_OBJECT, pwrSwitcher, susAssHelper);
|
||||
static_cast<void>(susAss);
|
||||
#endif /* OBSW_ADD_SUN_SENSORS == 1 */
|
||||
}
|
||||
|
||||
void ObjectFactory::createRtdComponents(std::string spiDev, GpioIF* gpioComIF,
|
||||
PowerSwitchIF* pwrSwitcher) {
|
||||
using namespace gpio;
|
||||
GpioCookie* rtdGpioCookie = new GpioCookie;
|
||||
|
||||
GpioCallback* gpioRtdIc0 = new GpioCallback("Chip select RTD IC0", Direction::OUT, Levels::HIGH,
|
||||
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
|
||||
rtdGpioCookie->addGpio(gpioIds::RTD_IC_3, gpioRtdIc0);
|
||||
GpioCallback* gpioRtdIc1 = new GpioCallback("Chip select RTD IC1", Direction::OUT, Levels::HIGH,
|
||||
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
|
||||
rtdGpioCookie->addGpio(gpioIds::RTD_IC_4, gpioRtdIc1);
|
||||
GpioCallback* gpioRtdIc2 = new GpioCallback("Chip select RTD IC2", Direction::OUT, Levels::HIGH,
|
||||
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
|
||||
rtdGpioCookie->addGpio(gpioIds::RTD_IC_5, gpioRtdIc2);
|
||||
GpioCallback* gpioRtdIc3 = new GpioCallback("Chip select RTD IC3", Direction::OUT, Levels::HIGH,
|
||||
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
|
||||
rtdGpioCookie->addGpio(gpioIds::RTD_IC_6, gpioRtdIc3);
|
||||
GpioCallback* gpioRtdIc4 = new GpioCallback("Chip select RTD IC4", Direction::OUT, Levels::HIGH,
|
||||
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
|
||||
rtdGpioCookie->addGpio(gpioIds::RTD_IC_7, gpioRtdIc4);
|
||||
GpioCallback* gpioRtdIc5 = new GpioCallback("Chip select RTD IC5", Direction::OUT, Levels::HIGH,
|
||||
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
|
||||
rtdGpioCookie->addGpio(gpioIds::RTD_IC_8, gpioRtdIc5);
|
||||
GpioCallback* gpioRtdIc6 = new GpioCallback("Chip select RTD IC6", Direction::OUT, Levels::HIGH,
|
||||
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
|
||||
rtdGpioCookie->addGpio(gpioIds::RTD_IC_9, gpioRtdIc6);
|
||||
GpioCallback* gpioRtdIc7 = new GpioCallback("Chip select RTD IC7", Direction::OUT, Levels::HIGH,
|
||||
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
|
||||
rtdGpioCookie->addGpio(gpioIds::RTD_IC_10, gpioRtdIc7);
|
||||
GpioCallback* gpioRtdIc8 = new GpioCallback("Chip select RTD IC8", Direction::OUT, Levels::HIGH,
|
||||
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
|
||||
rtdGpioCookie->addGpio(gpioIds::RTD_IC_11, gpioRtdIc8);
|
||||
GpioCallback* gpioRtdIc9 = new GpioCallback("Chip select RTD IC9", Direction::OUT, Levels::HIGH,
|
||||
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
|
||||
rtdGpioCookie->addGpio(gpioIds::RTD_IC_12, gpioRtdIc9);
|
||||
GpioCallback* gpioRtdIc10 = new GpioCallback("Chip select RTD IC10", Direction::OUT, Levels::HIGH,
|
||||
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
|
||||
rtdGpioCookie->addGpio(gpioIds::RTD_IC_13, gpioRtdIc10);
|
||||
GpioCallback* gpioRtdIc11 = new GpioCallback("Chip select RTD IC11", Direction::OUT, Levels::HIGH,
|
||||
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
|
||||
rtdGpioCookie->addGpio(gpioIds::RTD_IC_14, gpioRtdIc11);
|
||||
GpioCallback* gpioRtdIc12 = new GpioCallback("Chip select RTD IC12", Direction::OUT, Levels::HIGH,
|
||||
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
|
||||
rtdGpioCookie->addGpio(gpioIds::RTD_IC_15, gpioRtdIc12);
|
||||
GpioCallback* gpioRtdIc13 = new GpioCallback("Chip select RTD IC13", Direction::OUT, Levels::HIGH,
|
||||
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
|
||||
rtdGpioCookie->addGpio(gpioIds::RTD_IC_16, gpioRtdIc13);
|
||||
GpioCallback* gpioRtdIc14 = new GpioCallback("Chip select RTD IC14", Direction::OUT, Levels::HIGH,
|
||||
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
|
||||
rtdGpioCookie->addGpio(gpioIds::RTD_IC_17, gpioRtdIc14);
|
||||
GpioCallback* gpioRtdIc15 = new GpioCallback("Chip select RTD IC15", Direction::OUT, Levels::HIGH,
|
||||
&gpioCallbacks::spiCsDecoderCallback, gpioComIF);
|
||||
rtdGpioCookie->addGpio(gpioIds::RTD_IC_18, gpioRtdIc15);
|
||||
|
||||
gpioComIF->addGpios(rtdGpioCookie);
|
||||
|
||||
#if OBSW_ADD_RTD_DEVICES == 1
|
||||
static constexpr uint8_t NUMBER_RTDS = 16;
|
||||
std::array<std::pair<address_t, gpioId_t>, NUMBER_RTDS> cookieArgs = {{
|
||||
{addresses::RTD_IC_3, gpioIds::RTD_IC_3},
|
||||
{addresses::RTD_IC_4, gpioIds::RTD_IC_4},
|
||||
{addresses::RTD_IC_5, gpioIds::RTD_IC_5},
|
||||
{addresses::RTD_IC_6, gpioIds::RTD_IC_6},
|
||||
{addresses::RTD_IC_7, gpioIds::RTD_IC_7},
|
||||
{addresses::RTD_IC_8, gpioIds::RTD_IC_8},
|
||||
{addresses::RTD_IC_9, gpioIds::RTD_IC_9},
|
||||
{addresses::RTD_IC_10, gpioIds::RTD_IC_10},
|
||||
{addresses::RTD_IC_11, gpioIds::RTD_IC_11},
|
||||
{addresses::RTD_IC_12, gpioIds::RTD_IC_12},
|
||||
{addresses::RTD_IC_13, gpioIds::RTD_IC_13},
|
||||
{addresses::RTD_IC_14, gpioIds::RTD_IC_14},
|
||||
{addresses::RTD_IC_15, gpioIds::RTD_IC_15},
|
||||
{addresses::RTD_IC_16, gpioIds::RTD_IC_16},
|
||||
{addresses::RTD_IC_17, gpioIds::RTD_IC_17},
|
||||
{addresses::RTD_IC_18, gpioIds::RTD_IC_18},
|
||||
}};
|
||||
std::array<object_id_t, NUMBER_RTDS> rtdIds = {
|
||||
objects::RTD_IC_3, objects::RTD_IC_4, objects::RTD_IC_5, objects::RTD_IC_6,
|
||||
objects::RTD_IC_7, objects::RTD_IC_8, objects::RTD_IC_9, objects::RTD_IC_10,
|
||||
objects::RTD_IC_11, objects::RTD_IC_12, objects::RTD_IC_13, objects::RTD_IC_14,
|
||||
objects::RTD_IC_15, objects::RTD_IC_16, objects::RTD_IC_17, objects::RTD_IC_18};
|
||||
std::array<SpiCookie*, NUMBER_RTDS> rtdCookies = {};
|
||||
std::array<Max31865PT1000Handler*, NUMBER_RTDS> rtds = {};
|
||||
RtdFdir* rtdFdir = nullptr;
|
||||
for (uint8_t idx = 0; idx < NUMBER_RTDS; idx++) {
|
||||
rtdCookies[idx] =
|
||||
new SpiCookie(cookieArgs[idx].first, cookieArgs[idx].second, spiDev,
|
||||
Max31865Definitions::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED);
|
||||
rtds[idx] = new Max31865PT1000Handler(rtdIds[idx], objects::SPI_COM_IF, rtdCookies[idx]);
|
||||
rtds[idx]->setParent(objects::TCS_BOARD_ASS);
|
||||
rtdFdir = new RtdFdir(rtdIds[idx]);
|
||||
rtds[idx]->setCustomFdir(rtdFdir);
|
||||
rtds[idx]->setDeviceIdx(idx + 3);
|
||||
}
|
||||
|
||||
#if OBSW_TEST_RTD == 1
|
||||
for (auto& rtd : rtds) {
|
||||
if (rtd != nullptr) {
|
||||
rtd->setStartUpImmediately();
|
||||
rtd->setInstantNormal(true);
|
||||
}
|
||||
}
|
||||
#endif // OBSW_TEST_RTD == 1
|
||||
TcsBoardHelper helper(rtdIds);
|
||||
TcsBoardAssembly* tcsBoardAss =
|
||||
new TcsBoardAssembly(objects::TCS_BOARD_ASS, objects::NO_OBJECT, pwrSwitcher,
|
||||
pcduSwitches::Switches::PDU1_CH0_TCS_BOARD_3V3, helper);
|
||||
static_cast<void>(tcsBoardAss);
|
||||
#endif // OBSW_ADD_RTD_DEVICES == 1
|
||||
}
|
15
linux/ObjectFactory.h
Normal file
15
linux/ObjectFactory.h
Normal file
@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
class GpioIF;
|
||||
class SpiComIF;
|
||||
class PowerSwitchIF;
|
||||
|
||||
namespace ObjectFactory {
|
||||
|
||||
void createSunSensorComponents(GpioIF* gpioComIF, SpiComIF* spiComIF, PowerSwitchIF* pwrSwitcher,
|
||||
std::string spiDev);
|
||||
void createRtdComponents(std::string spiDev, GpioIF* gpioComIF, PowerSwitchIF* pwrSwitcher);
|
||||
|
||||
} // namespace ObjectFactory
|
@ -3,9 +3,14 @@
|
||||
|
||||
#include "OBSWConfig.h"
|
||||
|
||||
#if defined(XIPHOS_Q7S)
|
||||
#ifdef XIPHOS_Q7S
|
||||
#include "busConf.h"
|
||||
#endif
|
||||
|
||||
#ifdef RASPBERRY_PI
|
||||
#include <bsp_linux_board/definitions.h>
|
||||
#endif
|
||||
|
||||
#include <fsfw_hal/common/gpio/GpioIF.h>
|
||||
#include <fsfw_hal/linux/spi/SpiCookie.h>
|
||||
#include <test/testtasks/TestTask.h>
|
||||
|
3
linux/callbacks/CMakeLists.txt
Normal file
3
linux/callbacks/CMakeLists.txt
Normal file
@ -0,0 +1,3 @@
|
||||
target_sources(${OBSW_NAME} PRIVATE
|
||||
gpioCallbacks.cpp
|
||||
)
|
431
linux/callbacks/gpioCallbacks.cpp
Normal file
431
linux/callbacks/gpioCallbacks.cpp
Normal file
@ -0,0 +1,431 @@
|
||||
#include "gpioCallbacks.h"
|
||||
|
||||
#include "devices/gpioIds.h"
|
||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||
#include "fsfw_hal/common/gpio/GpioCookie.h"
|
||||
#include "fsfw_hal/common/gpio/GpioIF.h"
|
||||
|
||||
void gpioCallbacks::spiCsDecoderCallback(gpioId_t gpioId, gpio::GpioOperation gpioOp,
|
||||
gpio::Levels value, void* args) {
|
||||
GpioIF* gpioIF = reinterpret_cast<GpioIF*>(args);
|
||||
if (gpioIF == nullptr) {
|
||||
sif::debug << "spiCsDecoderCallback: No gpioComIF specified. Call initSpiCsDecoder "
|
||||
<< "to specify gpioComIF" << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
/* Reading is not supported by the callback function */
|
||||
if (gpioOp == gpio::GpioOperation::READ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (value == gpio::Levels::HIGH) {
|
||||
switch (gpioId) {
|
||||
case (gpioIds::RTD_IC_3): {
|
||||
disableDecoderTcsIc1(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::RTD_IC_4): {
|
||||
disableDecoderTcsIc1(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::RTD_IC_5): {
|
||||
disableDecoderTcsIc1(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::RTD_IC_6): {
|
||||
disableDecoderTcsIc1(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::RTD_IC_7): {
|
||||
disableDecoderTcsIc1(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::RTD_IC_8): {
|
||||
disableDecoderTcsIc1(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::RTD_IC_9): {
|
||||
disableDecoderTcsIc1(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::RTD_IC_10): {
|
||||
disableDecoderTcsIc1(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::RTD_IC_11): {
|
||||
disableDecoderTcsIc2(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::RTD_IC_12): {
|
||||
disableDecoderTcsIc2(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::RTD_IC_13): {
|
||||
disableDecoderTcsIc2(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::RTD_IC_14): {
|
||||
disableDecoderTcsIc2(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::RTD_IC_15): {
|
||||
disableDecoderTcsIc2(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::RTD_IC_16): {
|
||||
disableDecoderTcsIc2(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::RTD_IC_17): {
|
||||
disableDecoderTcsIc2(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::RTD_IC_18): {
|
||||
disableDecoderTcsIc2(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::CS_SUS_0): {
|
||||
disableDecoderInterfaceBoardIc1(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::CS_SUS_1): {
|
||||
disableDecoderInterfaceBoardIc1(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::CS_SUS_2): {
|
||||
disableDecoderInterfaceBoardIc1(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::CS_SUS_3): {
|
||||
disableDecoderInterfaceBoardIc1(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::CS_SUS_4): {
|
||||
disableDecoderInterfaceBoardIc1(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::CS_SUS_5): {
|
||||
disableDecoderInterfaceBoardIc1(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::CS_SUS_6): {
|
||||
disableDecoderInterfaceBoardIc2(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::CS_SUS_7): {
|
||||
disableDecoderInterfaceBoardIc2(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::CS_SUS_8): {
|
||||
disableDecoderInterfaceBoardIc2(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::CS_SUS_9): {
|
||||
disableDecoderInterfaceBoardIc2(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::CS_SUS_10): {
|
||||
disableDecoderInterfaceBoardIc2(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::CS_SUS_11): {
|
||||
disableDecoderInterfaceBoardIc2(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::CS_RW1): {
|
||||
disableRwDecoder(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::CS_RW2): {
|
||||
disableRwDecoder(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::CS_RW3): {
|
||||
disableRwDecoder(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::CS_RW4): {
|
||||
disableRwDecoder(gpioIF);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
sif::debug << "spiCsDecoderCallback: Invalid gpio id " << gpioId << std::endl;
|
||||
}
|
||||
} else if (value == gpio::Levels::LOW) {
|
||||
switch (gpioId) {
|
||||
case (gpioIds::RTD_IC_3): {
|
||||
selectY7(gpioIF);
|
||||
enableDecoderTcsIc1(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::RTD_IC_4): {
|
||||
selectY6(gpioIF);
|
||||
enableDecoderTcsIc1(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::RTD_IC_5): {
|
||||
selectY5(gpioIF);
|
||||
enableDecoderTcsIc1(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::RTD_IC_6): {
|
||||
selectY4(gpioIF);
|
||||
enableDecoderTcsIc1(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::RTD_IC_7): {
|
||||
selectY3(gpioIF);
|
||||
enableDecoderTcsIc1(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::RTD_IC_8): {
|
||||
selectY2(gpioIF);
|
||||
enableDecoderTcsIc1(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::RTD_IC_9): {
|
||||
selectY1(gpioIF);
|
||||
enableDecoderTcsIc1(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::RTD_IC_10): {
|
||||
selectY0(gpioIF);
|
||||
enableDecoderTcsIc1(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::RTD_IC_11): {
|
||||
selectY7(gpioIF);
|
||||
enableDecoderTcsIc2(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::RTD_IC_12): {
|
||||
selectY6(gpioIF);
|
||||
enableDecoderTcsIc2(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::RTD_IC_13): {
|
||||
selectY5(gpioIF);
|
||||
enableDecoderTcsIc2(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::RTD_IC_14): {
|
||||
selectY4(gpioIF);
|
||||
enableDecoderTcsIc2(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::RTD_IC_15): {
|
||||
selectY3(gpioIF);
|
||||
enableDecoderTcsIc2(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::RTD_IC_16): {
|
||||
selectY2(gpioIF);
|
||||
enableDecoderTcsIc2(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::RTD_IC_17): {
|
||||
selectY1(gpioIF);
|
||||
enableDecoderTcsIc2(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::RTD_IC_18): {
|
||||
selectY0(gpioIF);
|
||||
enableDecoderTcsIc2(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::CS_SUS_0): {
|
||||
selectY0(gpioIF);
|
||||
enableDecoderInterfaceBoardIc1(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::CS_SUS_1): {
|
||||
selectY1(gpioIF);
|
||||
enableDecoderInterfaceBoardIc1(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::CS_SUS_2): {
|
||||
selectY2(gpioIF);
|
||||
enableDecoderInterfaceBoardIc1(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::CS_SUS_3): {
|
||||
selectY3(gpioIF);
|
||||
enableDecoderInterfaceBoardIc1(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::CS_SUS_4): {
|
||||
selectY4(gpioIF);
|
||||
enableDecoderInterfaceBoardIc1(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::CS_SUS_5): {
|
||||
selectY5(gpioIF);
|
||||
enableDecoderInterfaceBoardIc1(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::CS_SUS_6): {
|
||||
selectY0(gpioIF);
|
||||
enableDecoderInterfaceBoardIc2(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::CS_SUS_7): {
|
||||
selectY1(gpioIF);
|
||||
enableDecoderInterfaceBoardIc2(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::CS_SUS_8): {
|
||||
selectY2(gpioIF);
|
||||
enableDecoderInterfaceBoardIc2(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::CS_SUS_9): {
|
||||
selectY3(gpioIF);
|
||||
enableDecoderInterfaceBoardIc2(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::CS_SUS_10): {
|
||||
selectY4(gpioIF);
|
||||
enableDecoderInterfaceBoardIc2(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::CS_SUS_11): {
|
||||
selectY5(gpioIF);
|
||||
enableDecoderInterfaceBoardIc2(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::CS_RW1): {
|
||||
selectY0(gpioIF);
|
||||
enableRwDecoder(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::CS_RW2): {
|
||||
selectY1(gpioIF);
|
||||
enableRwDecoder(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::CS_RW3): {
|
||||
selectY2(gpioIF);
|
||||
enableRwDecoder(gpioIF);
|
||||
break;
|
||||
}
|
||||
case (gpioIds::CS_RW4): {
|
||||
selectY3(gpioIF);
|
||||
enableRwDecoder(gpioIF);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
sif::debug << "spiCsDecoderCallback: Invalid gpio id " << gpioId << std::endl;
|
||||
}
|
||||
} else {
|
||||
sif::debug << "spiCsDecoderCallback: Invalid value. Must be 0 or 1" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void gpioCallbacks::enableDecoderTcsIc1(GpioIF* gpioIF) {
|
||||
gpioIF->pullLow(gpioIds::SPI_MUX_BIT_0);
|
||||
gpioIF->pullHigh(gpioIds::SPI_MUX_BIT_1);
|
||||
gpioIF->pullLow(gpioIds::SPI_MUX_BIT_2);
|
||||
}
|
||||
|
||||
void gpioCallbacks::enableDecoderTcsIc2(GpioIF* gpioIF) {
|
||||
gpioIF->pullHigh(gpioIds::SPI_MUX_BIT_2);
|
||||
gpioIF->pullLow(gpioIds::SPI_MUX_BIT_0);
|
||||
gpioIF->pullHigh(gpioIds::SPI_MUX_BIT_1);
|
||||
}
|
||||
|
||||
void gpioCallbacks::enableDecoderInterfaceBoardIc1(GpioIF* gpioIF) {
|
||||
gpioIF->pullHigh(gpioIds::SPI_MUX_BIT_0);
|
||||
gpioIF->pullLow(gpioIds::SPI_MUX_BIT_1);
|
||||
gpioIF->pullLow(gpioIds::SPI_MUX_BIT_2);
|
||||
}
|
||||
|
||||
void gpioCallbacks::enableDecoderInterfaceBoardIc2(GpioIF* gpioIF) {
|
||||
gpioIF->pullHigh(gpioIds::SPI_MUX_BIT_0);
|
||||
gpioIF->pullLow(gpioIds::SPI_MUX_BIT_1);
|
||||
gpioIF->pullHigh(gpioIds::SPI_MUX_BIT_2);
|
||||
}
|
||||
|
||||
void gpioCallbacks::disableDecoderTcsIc1(GpioIF* gpioIF) {
|
||||
gpioIF->pullHigh(gpioIds::SPI_MUX_BIT_0);
|
||||
gpioIF->pullHigh(gpioIds::SPI_MUX_BIT_1);
|
||||
gpioIF->pullLow(gpioIds::SPI_MUX_BIT_2);
|
||||
}
|
||||
|
||||
void gpioCallbacks::disableDecoderTcsIc2(GpioIF* gpioIF) {
|
||||
// DO NOT CHANGE THE ORDER HERE
|
||||
gpioIF->pullHigh(gpioIds::SPI_MUX_BIT_0);
|
||||
gpioIF->pullLow(gpioIds::SPI_MUX_BIT_2);
|
||||
gpioIF->pullHigh(gpioIds::SPI_MUX_BIT_1);
|
||||
}
|
||||
|
||||
void gpioCallbacks::disableDecoderInterfaceBoardIc1(GpioIF* gpioIF) {
|
||||
gpioIF->pullHigh(gpioIds::SPI_MUX_BIT_0);
|
||||
gpioIF->pullHigh(gpioIds::SPI_MUX_BIT_1);
|
||||
gpioIF->pullLow(gpioIds::SPI_MUX_BIT_2);
|
||||
}
|
||||
|
||||
void gpioCallbacks::disableDecoderInterfaceBoardIc2(GpioIF* gpioIF) {
|
||||
gpioIF->pullHigh(gpioIds::SPI_MUX_BIT_0);
|
||||
gpioIF->pullHigh(gpioIds::SPI_MUX_BIT_1);
|
||||
gpioIF->pullLow(gpioIds::SPI_MUX_BIT_2);
|
||||
}
|
||||
|
||||
void gpioCallbacks::enableRwDecoder(GpioIF* gpioIF) { gpioIF->pullHigh(gpioIds::EN_RW_CS); }
|
||||
|
||||
void gpioCallbacks::disableRwDecoder(GpioIF* gpioIF) { gpioIF->pullLow(gpioIds::EN_RW_CS); }
|
||||
|
||||
void gpioCallbacks::selectY0(GpioIF* gpioIF) {
|
||||
gpioIF->pullLow(gpioIds::SPI_MUX_BIT_3);
|
||||
gpioIF->pullLow(gpioIds::SPI_MUX_BIT_4);
|
||||
gpioIF->pullLow(gpioIds::SPI_MUX_BIT_5);
|
||||
}
|
||||
|
||||
void gpioCallbacks::selectY1(GpioIF* gpioIF) {
|
||||
gpioIF->pullHigh(gpioIds::SPI_MUX_BIT_3);
|
||||
gpioIF->pullLow(gpioIds::SPI_MUX_BIT_4);
|
||||
gpioIF->pullLow(gpioIds::SPI_MUX_BIT_5);
|
||||
}
|
||||
|
||||
void gpioCallbacks::selectY2(GpioIF* gpioIF) {
|
||||
gpioIF->pullLow(gpioIds::SPI_MUX_BIT_3);
|
||||
gpioIF->pullHigh(gpioIds::SPI_MUX_BIT_4);
|
||||
gpioIF->pullLow(gpioIds::SPI_MUX_BIT_5);
|
||||
}
|
||||
|
||||
void gpioCallbacks::selectY3(GpioIF* gpioIF) {
|
||||
gpioIF->pullHigh(gpioIds::SPI_MUX_BIT_3);
|
||||
gpioIF->pullHigh(gpioIds::SPI_MUX_BIT_4);
|
||||
gpioIF->pullLow(gpioIds::SPI_MUX_BIT_5);
|
||||
}
|
||||
|
||||
void gpioCallbacks::selectY4(GpioIF* gpioIF) {
|
||||
gpioIF->pullLow(gpioIds::SPI_MUX_BIT_3);
|
||||
gpioIF->pullLow(gpioIds::SPI_MUX_BIT_4);
|
||||
gpioIF->pullHigh(gpioIds::SPI_MUX_BIT_5);
|
||||
}
|
||||
|
||||
void gpioCallbacks::selectY5(GpioIF* gpioIF) {
|
||||
gpioIF->pullHigh(gpioIds::SPI_MUX_BIT_3);
|
||||
gpioIF->pullLow(gpioIds::SPI_MUX_BIT_4);
|
||||
gpioIF->pullHigh(gpioIds::SPI_MUX_BIT_5);
|
||||
}
|
||||
|
||||
void gpioCallbacks::selectY6(GpioIF* gpioIF) {
|
||||
gpioIF->pullLow(gpioIds::SPI_MUX_BIT_3);
|
||||
gpioIF->pullHigh(gpioIds::SPI_MUX_BIT_4);
|
||||
gpioIF->pullHigh(gpioIds::SPI_MUX_BIT_5);
|
||||
}
|
||||
|
||||
void gpioCallbacks::selectY7(GpioIF* gpioIF) {
|
||||
gpioIF->pullHigh(gpioIds::SPI_MUX_BIT_3);
|
||||
gpioIF->pullHigh(gpioIds::SPI_MUX_BIT_4);
|
||||
gpioIF->pullHigh(gpioIds::SPI_MUX_BIT_5);
|
||||
}
|
||||
|
||||
void gpioCallbacks::disableAllDecoder(GpioIF* gpioIF) {
|
||||
gpioIF->pullLow(gpioIds::SPI_MUX_BIT_2);
|
||||
gpioIF->pullLow(gpioIds::SPI_MUX_BIT_0);
|
||||
gpioIF->pullLow(gpioIds::SPI_MUX_BIT_1);
|
||||
gpioIF->pullLow(gpioIds::EN_RW_CS);
|
||||
}
|
66
linux/callbacks/gpioCallbacks.h
Normal file
66
linux/callbacks/gpioCallbacks.h
Normal file
@ -0,0 +1,66 @@
|
||||
#pragma once
|
||||
|
||||
#include <fsfw_hal/common/gpio/gpioDefinitions.h>
|
||||
|
||||
class GpioIF;
|
||||
|
||||
namespace gpioCallbacks {
|
||||
|
||||
/**
|
||||
* @brief This function implements the decoding to multiply gpios by using the decoder
|
||||
* chips SN74LVC138APWR on the TCS board and the interface board.
|
||||
*/
|
||||
void spiCsDecoderCallback(gpioId_t gpioId, gpio::GpioOperation gpioOp, gpio::Levels value,
|
||||
void* args);
|
||||
|
||||
/**
|
||||
* @brief This function sets mux bits 1-3 to a state which will only enable the decoder
|
||||
* on the TCS board which is named to IC1 in the schematic.
|
||||
*/
|
||||
void enableDecoderTcsIc1(GpioIF* gpioIF);
|
||||
|
||||
/**
|
||||
* @brief This function sets mux bits 1-3 to a state which will only enable the decoder
|
||||
* on the TCS board which is named to IC2 in the schematic.
|
||||
*/
|
||||
void enableDecoderTcsIc2(GpioIF* gpioIF);
|
||||
|
||||
/**
|
||||
* @brief This function sets mux bits 1-3 to a state which will only enable the decoder
|
||||
* on the inteface board board which is named to IC21 in the schematic.
|
||||
*/
|
||||
void enableDecoderInterfaceBoardIc1(GpioIF* gpioIF);
|
||||
|
||||
/**
|
||||
* @brief This function sets mux bits 1-3 to a state which will only enable the decoder
|
||||
* on the inteface board board which is named to IC22 in the schematic.
|
||||
*/
|
||||
void enableDecoderInterfaceBoardIc2(GpioIF* gpioIF);
|
||||
|
||||
void disableDecoderTcsIc1(GpioIF* gpioIF);
|
||||
void disableDecoderTcsIc2(GpioIF* gpioIF);
|
||||
void disableDecoderInterfaceBoardIc1(GpioIF* gpioIF);
|
||||
void disableDecoderInterfaceBoardIc2(GpioIF* gpioIF);
|
||||
|
||||
/**
|
||||
* @brief Enables the reaction wheel chip select decoder (IC3).
|
||||
*/
|
||||
void enableRwDecoder(GpioIF* gpioIF);
|
||||
void disableRwDecoder(GpioIF* gpioIF);
|
||||
|
||||
/**
|
||||
* @brief This function disables all decoder.
|
||||
*/
|
||||
void disableAllDecoder(GpioIF* gpioIF);
|
||||
|
||||
/** The following functions enable the appropriate channel of the currently enabled decoder */
|
||||
void selectY0(GpioIF* gpioIF);
|
||||
void selectY1(GpioIF* gpioIF);
|
||||
void selectY2(GpioIF* gpioIF);
|
||||
void selectY3(GpioIF* gpioIF);
|
||||
void selectY4(GpioIF* gpioIF);
|
||||
void selectY5(GpioIF* gpioIF);
|
||||
void selectY6(GpioIF* gpioIF);
|
||||
void selectY7(GpioIF* gpioIF);
|
||||
|
||||
} // namespace gpioCallbacks
|
@ -1541,6 +1541,6 @@ class LatchupStatusReport : public StaticLocalDataSet<LATCHUP_RPT_SET_ENTRIES> {
|
||||
lp_var_t<uint32_t> isSet =
|
||||
lp_var_t<uint32_t>(sid.objectId, PoolIds::LATCHUP_RPT_TIME_IS_SET, this);
|
||||
};
|
||||
} // namespace PLOC_SPV
|
||||
} // namespace supv
|
||||
|
||||
#endif /* MISSION_DEVICES_DEVICEDEFINITIONS_PLOCSVPDEFINITIONS_H_ */
|
||||
|
@ -1,9 +1,9 @@
|
||||
#include "PlocMPSoCHandler.h"
|
||||
#include "linux/devices/devicedefinitions/PlocSupervisorDefinitions.h"
|
||||
|
||||
#include "OBSWConfig.h"
|
||||
#include "fsfw/datapool/PoolReadGuard.h"
|
||||
#include "fsfw/globalfunctions/CRC.h"
|
||||
#include "linux/devices/devicedefinitions/PlocSupervisorDefinitions.h"
|
||||
|
||||
PlocMPSoCHandler::PlocMPSoCHandler(object_id_t objectId, object_id_t uartComIFid,
|
||||
CookieIF* comCookie, PlocMPSoCHelper* plocMPSoCHelper,
|
||||
@ -87,8 +87,8 @@ void PlocMPSoCHandler::performOperationHook() {
|
||||
}
|
||||
}
|
||||
CommandMessage message;
|
||||
for (ReturnValue_t result = commandActionHelperQueue->receiveMessage(&message); result == RETURN_OK;
|
||||
result = commandActionHelperQueue->receiveMessage(&message)) {
|
||||
for (ReturnValue_t result = commandActionHelperQueue->receiveMessage(&message);
|
||||
result == RETURN_OK; result = commandActionHelperQueue->receiveMessage(&message)) {
|
||||
result = commandActionHelper.handleReply(&message);
|
||||
if (result == RETURN_OK) {
|
||||
continue;
|
||||
@ -133,31 +133,31 @@ ReturnValue_t PlocMPSoCHandler::executeAction(ActionId_t actionId, MessageQueueI
|
||||
}
|
||||
|
||||
void PlocMPSoCHandler::doStartUp() {
|
||||
switch(powerState) {
|
||||
case PowerState::OFF:
|
||||
switch (powerState) {
|
||||
case PowerState::OFF:
|
||||
commandActionHelper.commandAction(supervisorHandler, supv::START_MPSOC);
|
||||
powerState = PowerState::BOOTING;
|
||||
break;
|
||||
case PowerState::ON:
|
||||
case PowerState::ON:
|
||||
setMode(_MODE_TO_ON);
|
||||
uartIsolatorSwitch.pullHigh();
|
||||
break;
|
||||
default:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void PlocMPSoCHandler::doShutDown() {
|
||||
switch(powerState) {
|
||||
case PowerState::ON:
|
||||
switch (powerState) {
|
||||
case PowerState::ON:
|
||||
uartIsolatorSwitch.pullLow();
|
||||
commandActionHelper.commandAction(supervisorHandler, supv::SHUTDOWN_MPSOC);
|
||||
powerState = PowerState::SHUTDOWN;
|
||||
break;
|
||||
case PowerState::OFF:
|
||||
case PowerState::OFF:
|
||||
setMode(_MODE_POWER_DOWN);
|
||||
break;
|
||||
default:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -703,64 +703,57 @@ size_t PlocMPSoCHandler::getNextReplyLength(DeviceCommandId_t commandId) {
|
||||
return replyLen;
|
||||
}
|
||||
|
||||
MessageQueueIF* PlocMPSoCHandler::getCommandQueuePtr() {
|
||||
return commandActionHelperQueue;
|
||||
}
|
||||
MessageQueueIF* PlocMPSoCHandler::getCommandQueuePtr() { return commandActionHelperQueue; }
|
||||
|
||||
void PlocMPSoCHandler::stepSuccessfulReceived(ActionId_t actionId, uint8_t step) {
|
||||
return;
|
||||
}
|
||||
void PlocMPSoCHandler::stepSuccessfulReceived(ActionId_t actionId, uint8_t step) { return; }
|
||||
|
||||
void PlocMPSoCHandler::stepFailedReceived(ActionId_t actionId, uint8_t step,
|
||||
ReturnValue_t returnCode) {
|
||||
switch (actionId) {
|
||||
case supv::START_MPSOC:
|
||||
sif::warning << "PlocMPSoCHandler::stepFailedReceived: Failed to start MPSoC"
|
||||
<< std::endl;
|
||||
powerState = PowerState::OFF;
|
||||
break;
|
||||
case supv::SHUTDOWN_MPSOC:
|
||||
triggerEvent(MPSOC_SHUTDOWN_FAILED);
|
||||
sif::warning << "PlocMPSoCHandler::stepFailedReceived: Failed to shutdown MPSoC"
|
||||
<< std::endl;
|
||||
// TODO: Setting state to on or off here?
|
||||
powerState = PowerState::ON;
|
||||
break;
|
||||
default:
|
||||
sif::debug
|
||||
<< "PlocMPSoCHandler::stepFailedReceived: Received unexpected action reply"
|
||||
<< std::endl;
|
||||
break;
|
||||
}
|
||||
ReturnValue_t returnCode) {
|
||||
switch (actionId) {
|
||||
case supv::START_MPSOC:
|
||||
sif::warning << "PlocMPSoCHandler::stepFailedReceived: Failed to start MPSoC" << std::endl;
|
||||
powerState = PowerState::OFF;
|
||||
break;
|
||||
case supv::SHUTDOWN_MPSOC:
|
||||
triggerEvent(MPSOC_SHUTDOWN_FAILED);
|
||||
sif::warning << "PlocMPSoCHandler::stepFailedReceived: Failed to shutdown MPSoC" << std::endl;
|
||||
// TODO: Setting state to on or off here?
|
||||
powerState = PowerState::ON;
|
||||
break;
|
||||
default:
|
||||
sif::debug << "PlocMPSoCHandler::stepFailedReceived: Received unexpected action reply"
|
||||
<< std::endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void PlocMPSoCHandler::dataReceived(ActionId_t actionId, const uint8_t* data, uint32_t size) {
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
void PlocMPSoCHandler::completionSuccessfulReceived(ActionId_t actionId) {
|
||||
if (actionId != supv::EXE_REPORT) {
|
||||
sif::debug << "PlocMPSoCHandler::completionSuccessfulReceived: Did not expect this action "
|
||||
<< "ID" << std::endl;
|
||||
return;
|
||||
}
|
||||
switch(powerState) {
|
||||
if (actionId != supv::EXE_REPORT) {
|
||||
sif::debug << "PlocMPSoCHandler::completionSuccessfulReceived: Did not expect this action "
|
||||
<< "ID" << std::endl;
|
||||
return;
|
||||
}
|
||||
switch (powerState) {
|
||||
case PowerState::BOOTING: {
|
||||
powerState = PowerState::ON;
|
||||
break;
|
||||
powerState = PowerState::ON;
|
||||
break;
|
||||
}
|
||||
case PowerState::SHUTDOWN: {
|
||||
powerState = PowerState::OFF;
|
||||
break;
|
||||
powerState = PowerState::OFF;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PlocMPSoCHandler::completionFailedReceived(ActionId_t actionId, ReturnValue_t returnCode) {
|
||||
handleActionCommandFailure(actionId);
|
||||
handleActionCommandFailure(actionId);
|
||||
}
|
||||
|
||||
void PlocMPSoCHandler::handleDeviceTM(const uint8_t* data, size_t dataSize,
|
||||
@ -862,27 +855,27 @@ void PlocMPSoCHandler::handleActionCommandFailure(ActionId_t actionId) {
|
||||
switch (actionId) {
|
||||
case supv::ACK_REPORT:
|
||||
case supv::EXE_REPORT:
|
||||
break;
|
||||
break;
|
||||
default:
|
||||
sif::debug << "PlocMPSoCHandler::handleActionCommandFailure: Did not expect this action ID "
|
||||
<< std::endl;
|
||||
return;
|
||||
sif::debug << "PlocMPSoCHandler::handleActionCommandFailure: Did not expect this action ID "
|
||||
<< std::endl;
|
||||
return;
|
||||
}
|
||||
switch(powerState) {
|
||||
case PowerState::BOOTING: {
|
||||
sif::warning << "PlocMPSoCHandler::handleActionCommandFailure: Failed to boot MPSoC"
|
||||
<< std::endl;
|
||||
powerState = PowerState::OFF;
|
||||
break;
|
||||
}
|
||||
case PowerState::SHUTDOWN: {
|
||||
sif::warning << "PlocMPSoCHandler::handleActionCommandFailure: Failed to shutdown MPSoC"
|
||||
<< std::endl;
|
||||
powerState = PowerState::ON;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
switch (powerState) {
|
||||
case PowerState::BOOTING: {
|
||||
sif::warning << "PlocMPSoCHandler::handleActionCommandFailure: Failed to boot MPSoC"
|
||||
<< std::endl;
|
||||
powerState = PowerState::OFF;
|
||||
break;
|
||||
}
|
||||
case PowerState::SHUTDOWN: {
|
||||
sif::warning << "PlocMPSoCHandler::handleActionCommandFailure: Failed to shutdown MPSoC"
|
||||
<< std::endl;
|
||||
powerState = PowerState::ON;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -384,7 +384,7 @@ ReturnValue_t PlocSupervisorHandler::scanForReply(const uint8_t* start, size_t r
|
||||
ReturnValue_t PlocSupervisorHandler::getSwitches(const uint8_t** switches,
|
||||
uint8_t* numberOfSwitches) {
|
||||
if (powerSwitch == power::NO_SWITCH) {
|
||||
return DeviceHandlerBase::NO_SWITCH;
|
||||
return DeviceHandlerBase::NO_SWITCH;
|
||||
}
|
||||
*numberOfSwitches = 1;
|
||||
*switches = &powerSwitch;
|
||||
@ -489,8 +489,8 @@ ReturnValue_t PlocSupervisorHandler::enableReplyInReplyMap(DeviceCommandMap::ite
|
||||
switch (command->first) {
|
||||
case supv::GET_HK_REPORT: {
|
||||
enabledReplies = 3;
|
||||
result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true,
|
||||
supv::HK_REPORT);
|
||||
result =
|
||||
DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, supv::HK_REPORT);
|
||||
if (result != RETURN_OK) {
|
||||
sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id "
|
||||
<< supv::HK_REPORT << " not in replyMap" << std::endl;
|
||||
@ -589,15 +589,15 @@ ReturnValue_t PlocSupervisorHandler::enableReplyInReplyMap(DeviceCommandMap::ite
|
||||
result =
|
||||
DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, supv::ACK_REPORT);
|
||||
if (result != RETURN_OK) {
|
||||
sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id "
|
||||
<< supv::ACK_REPORT << " not in replyMap" << std::endl;
|
||||
sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id " << supv::ACK_REPORT
|
||||
<< " not in replyMap" << std::endl;
|
||||
}
|
||||
|
||||
result =
|
||||
DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, supv::EXE_REPORT);
|
||||
if (result != RETURN_OK) {
|
||||
sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id "
|
||||
<< supv::EXE_REPORT << " not in replyMap" << std::endl;
|
||||
sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id " << supv::EXE_REPORT
|
||||
<< " not in replyMap" << std::endl;
|
||||
}
|
||||
|
||||
return RETURN_OK;
|
||||
@ -1013,7 +1013,7 @@ void PlocSupervisorHandler::prepareEmptyCmd(uint16_t apid) {
|
||||
|
||||
void PlocSupervisorHandler::prepareSelBootImageCmd(const uint8_t* commandData) {
|
||||
supv::MPSoCBootSelect packet(*commandData, *(commandData + 1), *(commandData + 2),
|
||||
*(commandData + 3));
|
||||
*(commandData + 3));
|
||||
packetToOutBuffer(packet.getWholeData(), packet.getFullSize());
|
||||
}
|
||||
|
||||
@ -1459,9 +1459,8 @@ ReturnValue_t PlocSupervisorHandler::handleMramDumpFile(DeviceCommandId_t id) {
|
||||
return MRAM_FILE_NOT_EXISTS;
|
||||
}
|
||||
std::ofstream file(activeMramFile, std::ios_base::app | std::ios_base::out);
|
||||
file.write(
|
||||
reinterpret_cast<const char*>(spacePacketBuffer + supv::SPACE_PACKET_HEADER_LENGTH),
|
||||
packetLen - 1);
|
||||
file.write(reinterpret_cast<const char*>(spacePacketBuffer + supv::SPACE_PACKET_HEADER_LENGTH),
|
||||
packetLen - 1);
|
||||
file.close();
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
@ -262,12 +262,11 @@ void PlocUpdater::commandUpdateAvailable() {
|
||||
calcImageCrc();
|
||||
|
||||
supv::UpdateInfo packet(supv::APID_UPDATE_AVAILABLE, static_cast<uint8_t>(image),
|
||||
static_cast<uint8_t>(partition), imageSize, imageCrc,
|
||||
numOfUpdatePackets);
|
||||
static_cast<uint8_t>(partition), imageSize, imageCrc, numOfUpdatePackets);
|
||||
|
||||
result = commandActionHelper.commandAction(objects::PLOC_SUPERVISOR_HANDLER,
|
||||
supv::UPDATE_AVAILABLE, packet.getWholeData(),
|
||||
packet.getFullSize());
|
||||
result =
|
||||
commandActionHelper.commandAction(objects::PLOC_SUPERVISOR_HANDLER, supv::UPDATE_AVAILABLE,
|
||||
packet.getWholeData(), packet.getFullSize());
|
||||
if (result != RETURN_OK) {
|
||||
sif::warning << "PlocUpdater::commandUpdateAvailable: Failed to send update available"
|
||||
<< " packet to supervisor handler" << std::endl;
|
||||
@ -311,9 +310,9 @@ void PlocUpdater::commandUpdatePacket() {
|
||||
}
|
||||
packet.makeCrc();
|
||||
|
||||
result = commandActionHelper.commandAction(objects::PLOC_SUPERVISOR_HANDLER,
|
||||
supv::UPDATE_IMAGE_DATA, packet.getWholeData(),
|
||||
packet.getFullSize());
|
||||
result =
|
||||
commandActionHelper.commandAction(objects::PLOC_SUPERVISOR_HANDLER, supv::UPDATE_IMAGE_DATA,
|
||||
packet.getWholeData(), packet.getFullSize());
|
||||
|
||||
if (result != RETURN_OK) {
|
||||
sif::warning << "PlocUpdater::commandUpdateAvailable: Failed to send update"
|
||||
@ -335,12 +334,10 @@ void PlocUpdater::commandUpdateVerify() {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
|
||||
supv::UpdateInfo packet(supv::APID_UPDATE_VERIFY, static_cast<uint8_t>(image),
|
||||
static_cast<uint8_t>(partition), imageSize, imageCrc,
|
||||
numOfUpdatePackets);
|
||||
static_cast<uint8_t>(partition), imageSize, imageCrc, numOfUpdatePackets);
|
||||
|
||||
result =
|
||||
commandActionHelper.commandAction(objects::PLOC_SUPERVISOR_HANDLER, supv::UPDATE_VERIFY,
|
||||
packet.getWholeData(), packet.getFullSize());
|
||||
result = commandActionHelper.commandAction(objects::PLOC_SUPERVISOR_HANDLER, supv::UPDATE_VERIFY,
|
||||
packet.getWholeData(), packet.getFullSize());
|
||||
if (result != RETURN_OK) {
|
||||
sif::warning << "PlocUpdater::commandUpdateAvailable: Failed to send update available"
|
||||
<< " packet to supervisor handler" << std::endl;
|
||||
|
@ -7,12 +7,12 @@
|
||||
#include "ArcsecJsonParamBase.h"
|
||||
#include "OBSWConfig.h"
|
||||
#include "StrHelper.h"
|
||||
#include "devices/powerSwitcherList.h"
|
||||
#include "fsfw/devicehandlers/DeviceHandlerBase.h"
|
||||
#include "fsfw/src/fsfw/serialize/SerializeAdapter.h"
|
||||
#include "fsfw/timemanager/Countdown.h"
|
||||
#include "linux/devices/devicedefinitions/StarTrackerDefinitions.h"
|
||||
#include "thirdparty/arcsec_star_tracker/common/SLIP.h"
|
||||
#include "devices/powerSwitcherList.h"
|
||||
|
||||
/**
|
||||
* @brief This is the device handler for the star tracker from arcsec.
|
||||
|
@ -44,6 +44,7 @@ debugging. */
|
||||
#define OBSW_ADD_PLOC_SUPERVISOR 0
|
||||
#define OBSW_ADD_PLOC_MPSOC 0
|
||||
#define OBSW_ADD_SUN_SENSORS 1
|
||||
#define OBSW_ADD_SUS_BOARD_ASS 1
|
||||
#define OBSW_ADD_ACS_BOARD 1
|
||||
#define OBSW_ADD_ACS_HANDLERS 1
|
||||
#define OBSW_ADD_RW 0
|
||||
@ -115,7 +116,6 @@ debugging. */
|
||||
#define OBSW_ADD_UART_TEST_CODE 0
|
||||
|
||||
#define OBSW_TEST_ACS 0
|
||||
#define OBSW_TEST_ACS_BOARD_ASS 0
|
||||
#define OBSW_DEBUG_ACS 0
|
||||
#define OBSW_TEST_SUS 0
|
||||
#define OBSW_DEBUG_SUS 0
|
||||
@ -170,6 +170,7 @@ debugging. */
|
||||
#define OBSW_ADD_SUN_SENSORS 0
|
||||
#define OBSW_ADD_MGT 0
|
||||
#define OBSW_ADD_ACS_BOARD 0
|
||||
#define OBSW_ADD_ACS_HANDLERS 0
|
||||
#define OBSW_ADD_GPS_0 0
|
||||
#define OBSW_ADD_GPS_1 0
|
||||
#define OBSW_ADD_RW 0
|
||||
|
Reference in New Issue
Block a user